- Timestamp:
- 09/24/15 10:59:05 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/versions/SoftwareVersion.java
r27 r41 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 1 15 package de.ugoe.cs.cpdp.versions; 2 16 … … 4 18 5 19 /** 6 * Data class for software versions. 20 * Data class for software versions. 21 * 7 22 * @author Steffen Herbold 8 23 */ 9 24 public class SoftwareVersion implements Comparable<SoftwareVersion> { 10 25 11 /** 12 * name of the project 13 */ 14 private final String project; 15 16 /** 17 * version of the project 18 */ 19 private final String version; 26 /** 27 * name of the project 28 */ 29 private final String project; 20 30 21 /** 22 * data of the version 23 */ 24 private final Instances instances; 25 26 /** 27 * Constructor. Creates a new version. 28 * @param project name of the project 29 * @param version name of the version 30 * @param instances data of the version 31 */ 32 public SoftwareVersion(String project, String version, Instances instances) { 33 this.project = project; 34 this.version = version; 35 this.instances = instances; 36 } 37 38 /** 39 * returns the project name 40 * @return project name 41 */ 42 public String getProject() { 43 return project; 44 } 45 46 /** 47 * returns the name of the version 48 * @return name of the version 49 */ 50 public String getVersion() { 51 return version; 52 } 53 54 /** 55 * returns the data of the version 56 * @return data 57 */ 58 public Instances getInstances() { 59 return new Instances(instances); 60 } 31 /** 32 * version of the project 33 */ 34 private final String version; 61 35 62 /** 63 * Compares first based on project name and then based on version. Only string comparisons are performed. 64 * @see java.lang.Comparable#compareTo(java.lang.Object) 65 */ 66 @Override 67 public int compareTo(SoftwareVersion o) { 68 int projectStrCmp = 0; 69 if( project!=null ) { 70 projectStrCmp = project.compareTo(o.project); 71 } 72 if( projectStrCmp==0 && version!=null ) { 73 return version.compareTo(o.version); 74 } else { 75 return projectStrCmp; 76 } 77 } 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 } 78 103 }
Note: See TracChangeset
for help on using the changeset viewer.