Skip to content

Package: PackageDescriptionFile

PackageDescriptionFile

nameinstructionbranchcomplexitylinemethod
PackageDescriptionFile()
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
PackageDescriptionFile(List, List, Integer)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
equals(Object)
M: 1 C: 27
96%
M: 4 C: 4
50%
M: 4 C: 1
20%
M: 0 C: 6
100%
M: 0 C: 1
100%
getComments()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getFormatVersion()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPackagerules()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
toString()
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: *
3: */
4: package model.packages;
5:
6: import java.util.ArrayList;
7: import java.util.List;
8:
9: import model.Comment;
10: import scanner.ScannerConstants;
11: import basic.ModelConstants;
12:
13: /**
14: * This class represents the description files for the packages.
15: *
16: * @author HFW410
17: *
18: */
19: public class PackageDescriptionFile {
20:
21:         /**
22:          * represents the formatVersion of the file.
23:          */
24:         private final Integer formatVersion;
25:         /**
26:          * represents a list of comments in the file.
27:          */
28:         private final List<Comment> comments;
29:         /**
30:          * represents the list of packagerules.
31:          */
32:         private final List<PackageRule> packagerules;
33:
34:         /**
35:          * Default constructor.
36:          */
37:         public PackageDescriptionFile() {
38:                 this.formatVersion = 1; /* TODO: use named constant */
39:                 this.comments = new ArrayList<Comment>();
40:                 this.packagerules = new ArrayList<PackageRule>();
41:         }
42:
43:         /**
44:          * @param comments
45:          * represents a list of comments.
46:          * @param packagerules
47:          * represents the list of package rules.
48:          * @param version
49:          * is the format version of the PackageDescriptionFile
50:          */
51:         public PackageDescriptionFile(final List<Comment> comments,
52:                         final List<PackageRule> packagerules, final Integer version) {
53:                 super();
54:                 this.comments = new ArrayList<Comment>(comments);
55:                 this.packagerules = new ArrayList<PackageRule>(packagerules);
56:                 this.formatVersion = version;
57:         }
58:
59:         @Override
60:         public String toString() {
61:                 return ModelConstants.PACKAGE_DESCRIPTION + this.formatVersion
62:                                 + ScannerConstants.COMMASPACE + this.comments + ScannerConstants.COMMASPACE
63:                                 + this.packagerules;
64:         }
65:
66:         /**
67:          * @return the formatVersion
68:          */
69:         public Integer getFormatVersion() {
70:                 return this.formatVersion;
71:         }
72:
73:         /**
74:          * @return the comments
75:          */
76:         public List<Comment> getComments() {
77:                 return new ArrayList<Comment>(this.comments);
78:         }
79:
80:         /**
81:          * @return the packagerules
82:          */
83:         public List<PackageRule> getPackagerules() {
84:                 return new ArrayList<PackageRule>(this.packagerules);
85:         }
86:
87:         @Override
88:         public int hashCode() {
89:                 return this.getFormatVersion().hashCode() + this.getComments().hashCode()
90:                                 + this.getPackagerules().hashCode();
91:         }
92:
93:         @Override
94:         public boolean equals(final Object obj) {
95:•                return obj instanceof PackageDescriptionFile
96:•                                && ((PackageDescriptionFile) obj).getComments().equals(this.getComments())
97:•                                && ((PackageDescriptionFile) obj).getFormatVersion().equals(
98:                                                 this.getFormatVersion())
99:                                 && ((PackageDescriptionFile) obj).getPackagerules()
100:•                                                .equals(this.getPackagerules());
101:         }
102:
103: }