1 | // Copyright 2015 Georg-August-Universität Göttingen, Germany
|
---|
2 | //
|
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
4 | // you may not use this file except in compliance with the License.
|
---|
5 | // You may obtain a copy of the License at
|
---|
6 | //
|
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
8 | //
|
---|
9 | // Unless required by applicable law or agreed to in writing, software
|
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
12 | // See the License for the specific language governing permissions and
|
---|
13 | // limitations under the License.
|
---|
14 |
|
---|
15 | package de.ugoe.cs.cpdp.versions;
|
---|
16 |
|
---|
17 | import java.util.List;
|
---|
18 |
|
---|
19 | import weka.core.Instances;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Data class for software versions.
|
---|
23 | *
|
---|
24 | * @author Steffen Herbold
|
---|
25 | */
|
---|
26 | public class SoftwareVersion implements Comparable<SoftwareVersion> {
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * name of the project
|
---|
30 | */
|
---|
31 | private final String project;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * version of the project
|
---|
35 | */
|
---|
36 | private final String version;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * data of the version
|
---|
40 | */
|
---|
41 | private final Instances instances;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Review effort per instance.
|
---|
45 | */
|
---|
46 | private final List<Double> efforts;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Constructor. Creates a new version.
|
---|
50 | *
|
---|
51 | * @param project
|
---|
52 | * name of the project
|
---|
53 | * @param version
|
---|
54 | * name of the version
|
---|
55 | * @param instances
|
---|
56 | * data of the version
|
---|
57 | */
|
---|
58 | public SoftwareVersion(String project, String version, Instances instances, List<Double> efforts) {
|
---|
59 | this.project = project;
|
---|
60 | this.version = version;
|
---|
61 | this.instances = instances;
|
---|
62 | this.efforts = efforts;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * returns the project name
|
---|
67 | *
|
---|
68 | * @return project name
|
---|
69 | */
|
---|
70 | public String getProject() {
|
---|
71 | return project;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * returns the name of the version
|
---|
76 | *
|
---|
77 | * @return name of the version
|
---|
78 | */
|
---|
79 | public String getVersion() {
|
---|
80 | return version;
|
---|
81 | }
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * returns the data of the version
|
---|
85 | *
|
---|
86 | * @return data
|
---|
87 | */
|
---|
88 | public Instances getInstances() {
|
---|
89 | return new Instances(instances);
|
---|
90 | }
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * <p>
|
---|
94 | * returns the review effort of the version
|
---|
95 | * </p>
|
---|
96 | *
|
---|
97 | * @return
|
---|
98 | */
|
---|
99 | public List<Double> getEfforts() {
|
---|
100 | return efforts;
|
---|
101 | }
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Compares first based on project name and then based on version. Only string comparisons are
|
---|
105 | * performed.
|
---|
106 | *
|
---|
107 | * @see java.lang.Comparable#compareTo(java.lang.Object)
|
---|
108 | */
|
---|
109 | @Override
|
---|
110 | public int compareTo(SoftwareVersion o) {
|
---|
111 | int projectStrCmp = 0;
|
---|
112 | if (project != null) {
|
---|
113 | projectStrCmp = project.compareTo(o.project);
|
---|
114 | }
|
---|
115 | if (projectStrCmp == 0 && version != null) {
|
---|
116 | return version.compareTo(o.version);
|
---|
117 | }
|
---|
118 | else {
|
---|
119 | return projectStrCmp;
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|