EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.extract]

COVERAGE SUMMARY FOR SOURCE FILE [Equal.java]

nameclass, %method, %block, %line, %
Equal.java100% (1/1)70%  (7/10)83%  (260/313)83%  (35.5/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Equal100% (1/1)70%  (7/10)83%  (260/313)83%  (35.5/43)
compare (double, double): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
compare (float, float): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
compare (long, long): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
compare (int, int): boolean 100% (1/1)71%  (5/7)71%  (0.7/1)
$SWITCH_TABLE$com$hammurapi$extract$ComparisonResult$Type (): int [] 100% (1/1)88%  (85/97)87%  (0.9/1)
compareTo (Extractor): ComparisonResult 100% (1/1)89%  (123/138)85%  (23.9/28)
Equal (double, TimeUnit, Extractor, Extractor, boolean): void 100% (1/1)100% (10/10)100% (3/3)
compare (Object, Object): boolean 100% (1/1)100% (22/22)100% (5/5)
isIdentity (): boolean 100% (1/1)100% (3/3)100% (1/1)
newInstance (Extractor, Extractor): Extractor 100% (1/1)100% (12/12)100% (1/1)

1package com.hammurapi.extract;
2 
3import java.util.concurrent.TimeUnit;
4 
5 
6public class Equal<T, V, C> extends ComparisonPredicate<T, V, C> {
7 
8        private boolean identity;
9 
10        public Equal(
11                        double initialCost, 
12                        TimeUnit costUnit,
13                        Extractor<T, V, C> leftExtractor,
14                        Extractor<T, V, C> rightExtractor, 
15                        boolean identity) {
16                super(initialCost, costUnit, leftExtractor, rightExtractor);
17                this.identity = identity;
18        }
19 
20        @Override
21        @SuppressWarnings("unchecked")
22        public ComparisonResult compareTo(Extractor<T, Boolean, C> otherPredicate) {
23                
24                if (otherPredicate instanceof Equal) {
25                        if (equals(otherPredicate) || operandsAreReverseEqual((Equal) otherPredicate)) {
26                                return ComparisonResult.EQUAL_NM;
27                        }
28                        
29                        ComparisonResult cr = null;
30                        if (leftExtractor.equals(((ComparisonPredicate) otherPredicate).leftExtractor)) {
31                                cr = rightExtractor.compareTo(((ComparisonPredicate) otherPredicate).rightExtractor);
32                        } else if (leftExtractor.equals(((ComparisonPredicate) otherPredicate).rightExtractor)) {
33                                cr = rightExtractor.compareTo(((ComparisonPredicate) otherPredicate).leftExtractor);                                
34                        } else if (rightExtractor.equals(((ComparisonPredicate) otherPredicate).leftExtractor)) {
35                                cr = leftExtractor.compareTo(((ComparisonPredicate) otherPredicate).rightExtractor);                                
36                        } else if (rightExtractor.equals(((ComparisonPredicate) otherPredicate).rightExtractor)) {
37                                cr = leftExtractor.compareTo(((ComparisonPredicate) otherPredicate).leftExtractor);                                
38                        }
39                        
40                        if (cr!=null && cr.isOneToOneMapping()) {
41                                switch (cr.getType()) {
42                                case UNEQUAL:
43                                        return ComparisonResult.OPPOSITE_LESS_RESTRICTIVE_NM;
44                                case OPPOSITE:
45                                        return ComparisonResult.OPPOSITE_NM;
46                                }
47                        }
48                }                
49                
50                if (otherPredicate instanceof NotEqual) {
51                        NotEqual<T, V, C> op = (NotEqual<T, V, C>) otherPredicate;
52                        return operandsAreEqual(op) || operandsAreReverseEqual(op) ? ComparisonResult.OPPOSITE_NM : ComparisonResult.NOT_EQUAL_NM;
53                } 
54                
55                if (otherPredicate instanceof Not) {
56                        Not<T, C> op = (Not<T, C>) otherPredicate;
57                        ComparisonResult cr = compareTo(op.getPredicate());
58                        if (cr.isOneToOneMapping()) {
59                                switch (cr.getType()) {
60                                case EQUAL:
61                                        return ComparisonResult.OPPOSITE_NM;
62                                case OPPOSITE:
63                                        return ComparisonResult.EQUAL_NM;
64                                default:
65                                        return ComparisonResult.NOT_EQUAL_NM;
66                                }
67                        }
68                        /**
69                         * TODO Implement comparisons.
70                         * a * b ? c * d, * - can be <, <=, ==, !=, =>, >
71                         * 36 permutations. Each permutation - compare a/b, c/d 
72                         */
73                        
74                        // TODO Address mappings
75                }
76                return super.compareTo(otherPredicate);
77        }
78 
79        @Override
80        protected boolean compare(int n1, int n2) {
81                return n1==n2;
82        }
83        
84        @Override
85        protected boolean compare(Object o1, Object o2) {
86                if (identity) {
87                        return o1==o2;
88                }
89                
90                if (o1==null) {
91                        return o2==null;
92                }
93 
94                return o1.equals(o2);
95        }
96 
97        @Override
98        protected boolean compare(long n1, long n2) {
99                return n1==n2;
100        }
101 
102        @Override
103        protected boolean compare(float n1, float n2) {
104                return n1==n2;
105        }
106 
107        @Override
108        protected boolean compare(double n1, double n2) {
109                return n1==n2;
110        }
111 
112        @Override
113        protected Extractor<T, Boolean, C> newInstance(Extractor<T, V, C> leftExtractor, Extractor<T, V, C> rightExtractor) {
114                return new Equal<T,V,C>(initialCost, costUnit, leftExtractor, rightExtractor, identity);
115        }
116        
117        public boolean isIdentity() {
118                return identity;
119        }
120}

[all classes][com.hammurapi.extract]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov