source: trunk/CrossPare/src/de/ugoe/cs/cpdp/versions/SoftwareVersion.java @ 140

Last change on this file since 140 was 136, checked in by sherbold, 8 years ago
  • more code documentation
  • Property svn:mime-type set to text/plain
File size: 3.2 KB
Line 
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
15package de.ugoe.cs.cpdp.versions;
16
17import java.util.List;
18
19import weka.core.Instances;
20
21/**
22 * Data class for software versions.
23 *
24 * @author Steffen Herbold
25 */
26public 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     * @param efforts
58     *            review efforts for the version
59     */
60    public SoftwareVersion(String project,
61                           String version,
62                           Instances instances,
63                           List<Double> efforts)
64    {
65        this.project = project;
66        this.version = version;
67        this.instances = instances;
68        this.efforts = efforts;
69    }
70
71    /**
72     * returns the project name
73     *
74     * @return project name
75     */
76    public String getProject() {
77        return project;
78    }
79
80    /**
81     * returns the name of the version
82     *
83     * @return name of the version
84     */
85    public String getVersion() {
86        return version;
87    }
88
89    /**
90     * returns the data of the version
91     *
92     * @return data
93     */
94    public Instances getInstances() {
95        return new Instances(instances);
96    }
97
98    /**
99     * <p>
100     * returns the review effort of the version
101     * </p>
102     *
103     * @return the review efforts
104     */
105    public List<Double> getEfforts() {
106        return efforts;
107    }
108
109    /**
110     * Compares first based on project name and then based on version. Only string comparisons are
111     * performed.
112     *
113     * @see java.lang.Comparable#compareTo(java.lang.Object)
114     */
115    @Override
116    public int compareTo(SoftwareVersion o) {
117        int projectStrCmp = 0;
118        if (project != null) {
119            projectStrCmp = project.compareTo(o.project);
120        }
121        if (projectStrCmp == 0 && version != null) {
122            return version.compareTo(o.version);
123        }
124        else {
125            return projectStrCmp;
126        }
127    }
128}
Note: See TracBrowser for help on using the repository browser.