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

Last change on this file since 74 was 41, checked in by sherbold, 9 years ago
  • formatted code and added copyrights
  • Property svn:mime-type set to text/plain
File size: 2.6 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 weka.core.Instances;
18
19/**
20 * Data class for software versions.
21 *
22 * @author Steffen Herbold
23 */
24public class SoftwareVersion implements Comparable<SoftwareVersion> {
25
26    /**
27     * name of the project
28     */
29    private final String project;
30
31    /**
32     * version of the project
33     */
34    private final String version;
35
36    /**
37     * data of the version
38     */
39    private final Instances instances;
40
41    /**
42     * Constructor. Creates a new version.
43     *
44     * @param project
45     *            name of the project
46     * @param version
47     *            name of the version
48     * @param instances
49     *            data of the version
50     */
51    public SoftwareVersion(String project, String version, Instances instances) {
52        this.project = project;
53        this.version = version;
54        this.instances = instances;
55    }
56
57    /**
58     * returns the project name
59     *
60     * @return project name
61     */
62    public String getProject() {
63        return project;
64    }
65
66    /**
67     * returns the name of the version
68     *
69     * @return name of the version
70     */
71    public String getVersion() {
72        return version;
73    }
74
75    /**
76     * returns the data of the version
77     *
78     * @return data
79     */
80    public Instances getInstances() {
81        return new Instances(instances);
82    }
83
84    /**
85     * Compares first based on project name and then based on version. Only string comparisons are
86     * performed.
87     *
88     * @see java.lang.Comparable#compareTo(java.lang.Object)
89     */
90    @Override
91    public int compareTo(SoftwareVersion o) {
92        int projectStrCmp = 0;
93        if (project != null) {
94            projectStrCmp = project.compareTo(o.project);
95        }
96        if (projectStrCmp == 0 && version != null) {
97            return version.compareTo(o.version);
98        }
99        else {
100            return projectStrCmp;
101        }
102    }
103}
Note: See TracBrowser for help on using the repository browser.