EMMA Coverage Report (generated Mon Dec 10 12:01:41 GMT 2007)
[all classes][uk.co.zonetora.fj.model]

COVERAGE SUMMARY FOR SOURCE FILE [Constructor.java]

nameclass, %method, %block, %line, %
Constructor.java100% (1/1)100% (7/7)100% (120/120)100% (28/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Constructor100% (1/1)100% (7/7)100% (120/120)100% (28/28)
Constructor (ClassName): void 100% (1/1)100% (21/21)100% (6/6)
addArgument (ClassName, FieldName): void 100% (1/1)100% (10/10)100% (2/2)
addLocalField (FieldName): void 100% (1/1)100% (6/6)100% (2/2)
addSuperField (FieldName): void 100% (1/1)100% (6/6)100% (2/2)
checkFieldsAreSane (List, List): void 100% (1/1)100% (45/45)100% (10/10)
getAllReferencedClassNames (): Set 100% (1/1)100% (29/29)100% (5/5)
getReturnClassName (): Object 100% (1/1)100% (3/3)100% (1/1)

1package uk.co.zonetora.fj.model;
2 
3import java.util.ArrayList;
4import java.util.HashSet;
5import java.util.List;
6import java.util.Set;
7 
8import uk.co.zonetora.fj.passes.FJException;
9import uk.co.zonetora.fj.util.Tuple;
10import static uk.co.zonetora.fj.util.ListUtil.*;
11 
12 
13 
14public class Constructor {
15 
16        private final ClassName returnType;
17        private final List<Tuple<ClassName, FieldName>> arguments;
18        
19        private final List<FieldName> superFields;
20        private final List<FieldName> localFields;
21        
22        public Constructor(ClassName returnType) {
23                this.returnType = returnType;
24                this.superFields = new ArrayList<FieldName>();
25                this.localFields = new ArrayList<FieldName>();
26                this.arguments = new ArrayList<Tuple<ClassName,FieldName>>();
27        }
28        
29        public void addSuperField(FieldName fn) {
30                this.superFields.add(fn);
31        }
32        
33        public void addLocalField(FieldName fn) {
34                this.localFields.add(fn);
35        }
36        
37        public void addArgument(ClassName cn, FieldName fn) {
38                this.arguments.add(new Tuple<ClassName, FieldName>(cn,fn));
39        }
40 
41        public Set<ClassName> getAllReferencedClassNames() {
42                Set<ClassName> allReferencedClassNames = new HashSet<ClassName>();
43                allReferencedClassNames.add(returnType);
44                
45                for(Tuple<ClassName, FieldName> arg : arguments) {
46                        allReferencedClassNames.add(arg.getX());
47                }
48                
49                return allReferencedClassNames;
50        }
51 
52        public void checkFieldsAreSane(List<Tuple<ClassName, FieldName>> fields,
53                        List<Tuple<ClassName, FieldName>> superFields) throws FJException {
54                List<Tuple<ClassName, FieldName>> allFields = new ArrayList<Tuple<ClassName,FieldName>>();
55                allFields.addAll(superFields);
56                allFields.addAll(fields);
57                
58                if(!arguments.equals(allFields)) {
59                        throw new FJException("Constructor fields do not match parent class");
60                }
61                
62                if(!(mapFst(superFields).equals(this.superFields))){
63                        throw new FJException("Superfields in constructor do not match up");
64                }
65                
66                if(!(mapSnd(fields).equals(this.localFields))) {
67                        throw new FJException("Localfields in constructor do not mach up");
68                }
69                
70        }
71 
72        public Object getReturnClassName() {
73                return returnType;
74        }
75}
76 

[all classes][uk.co.zonetora.fj.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov