[86] | 1 | // Copyright 2015 Georg-August-Universität Göttingen, Germany
|
---|
[41] | 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 |
|
---|
[2] | 15 | package de.ugoe.cs.cpdp.versions;
|
---|
| 16 |
|
---|
[132] | 17 | import java.util.List;
|
---|
| 18 |
|
---|
[2] | 19 | import weka.core.Instances;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
[41] | 22 | * Data class for software versions.
|
---|
| 23 | *
|
---|
[2] | 24 | * @author Steffen Herbold
|
---|
| 25 | */
|
---|
[27] | 26 | public class SoftwareVersion implements Comparable<SoftwareVersion> {
|
---|
[2] | 27 |
|
---|
[142] | 28 | private final String dataset;
|
---|
| 29 |
|
---|
[41] | 30 | /**
|
---|
| 31 | * name of the project
|
---|
| 32 | */
|
---|
| 33 | private final String project;
|
---|
[2] | 34 |
|
---|
[41] | 35 | /**
|
---|
| 36 | * version of the project
|
---|
| 37 | */
|
---|
| 38 | private final String version;
|
---|
[27] | 39 |
|
---|
[41] | 40 | /**
|
---|
| 41 | * data of the version
|
---|
| 42 | */
|
---|
| 43 | private final Instances instances;
|
---|
[135] | 44 |
|
---|
[132] | 45 | /**
|
---|
[135] | 46 | * Review effort per instance.
|
---|
[132] | 47 | */
|
---|
| 48 | private final List<Double> efforts;
|
---|
[41] | 49 |
|
---|
| 50 | /**
|
---|
| 51 | * Constructor. Creates a new version.
|
---|
| 52 | *
|
---|
| 53 | * @param project
|
---|
| 54 | * name of the project
|
---|
| 55 | * @param version
|
---|
| 56 | * name of the version
|
---|
| 57 | * @param instances
|
---|
| 58 | * data of the version
|
---|
[136] | 59 | * @param efforts
|
---|
| 60 | * review efforts for the version
|
---|
[41] | 61 | */
|
---|
[142] | 62 | public SoftwareVersion(String dataset,
|
---|
| 63 | String project,
|
---|
[135] | 64 | String version,
|
---|
| 65 | Instances instances,
|
---|
| 66 | List<Double> efforts)
|
---|
| 67 | {
|
---|
[142] | 68 | this.dataset = dataset;
|
---|
[41] | 69 | this.project = project;
|
---|
| 70 | this.version = version;
|
---|
| 71 | this.instances = instances;
|
---|
[132] | 72 | this.efforts = efforts;
|
---|
[41] | 73 | }
|
---|
[135] | 74 |
|
---|
[142] | 75 | public String getDataset() {
|
---|
| 76 | return dataset;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[41] | 79 | /**
|
---|
| 80 | * returns the project name
|
---|
| 81 | *
|
---|
| 82 | * @return project name
|
---|
| 83 | */
|
---|
| 84 | public String getProject() {
|
---|
| 85 | return project;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | /**
|
---|
| 89 | * returns the name of the version
|
---|
| 90 | *
|
---|
| 91 | * @return name of the version
|
---|
| 92 | */
|
---|
| 93 | public String getVersion() {
|
---|
| 94 | return version;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /**
|
---|
| 98 | * returns the data of the version
|
---|
| 99 | *
|
---|
| 100 | * @return data
|
---|
| 101 | */
|
---|
| 102 | public Instances getInstances() {
|
---|
| 103 | return new Instances(instances);
|
---|
| 104 | }
|
---|
[135] | 105 |
|
---|
[132] | 106 | /**
|
---|
| 107 | * <p>
|
---|
| 108 | * returns the review effort of the version
|
---|
| 109 | * </p>
|
---|
| 110 | *
|
---|
[136] | 111 | * @return the review efforts
|
---|
[132] | 112 | */
|
---|
| 113 | public List<Double> getEfforts() {
|
---|
| 114 | return efforts;
|
---|
| 115 | }
|
---|
[41] | 116 |
|
---|
| 117 | /**
|
---|
| 118 | * Compares first based on project name and then based on version. Only string comparisons are
|
---|
| 119 | * performed.
|
---|
| 120 | *
|
---|
| 121 | * @see java.lang.Comparable#compareTo(java.lang.Object)
|
---|
| 122 | */
|
---|
| 123 | @Override
|
---|
| 124 | public int compareTo(SoftwareVersion o) {
|
---|
| 125 | int projectStrCmp = 0;
|
---|
| 126 | if (project != null) {
|
---|
| 127 | projectStrCmp = project.compareTo(o.project);
|
---|
| 128 | }
|
---|
| 129 | if (projectStrCmp == 0 && version != null) {
|
---|
| 130 | return version.compareTo(o.version);
|
---|
| 131 | }
|
---|
| 132 | else {
|
---|
| 133 | return projectStrCmp;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
[2] | 136 | }
|
---|