src/main/java/de/uapcore/lightpit/entities/Version.java

Fri, 22 May 2020 21:23:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 22 May 2020 21:23:57 +0200
changeset 75
33b6843fdf8a
parent 62
833e0385572a
child 86
0a658e53177c
permissions
-rw-r--r--

adds the ability to create and edit issues

universe@38 1 /*
universe@38 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@38 3 *
universe@38 4 * Copyright 2018 Mike Becker. All rights reserved.
universe@38 5 *
universe@38 6 * Redistribution and use in source and binary forms, with or without
universe@38 7 * modification, are permitted provided that the following conditions are met:
universe@38 8 *
universe@38 9 * 1. Redistributions of source code must retain the above copyright
universe@38 10 * notice, this list of conditions and the following disclaimer.
universe@38 11 *
universe@38 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@38 13 * notice, this list of conditions and the following disclaimer in the
universe@38 14 * documentation and/or other materials provided with the distribution.
universe@38 15 *
universe@38 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@38 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@38 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@38 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@38 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@38 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@38 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@38 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@38 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@38 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@38 26 * POSSIBILITY OF SUCH DAMAGE.
universe@38 27 *
universe@38 28 */
universe@37 29 package de.uapcore.lightpit.entities;
universe@37 30
universe@37 31 import java.util.Objects;
universe@37 32
universe@62 33 public final class Version implements Comparable<Version> {
universe@37 34
universe@37 35 private final int id;
universe@75 36 private Project project;
universe@37 37 private String name;
universe@37 38 /**
universe@37 39 * If we do not want versions to be ordered lexicographically we may specify an order.
universe@37 40 */
universe@59 41 private int ordinal = 0;
universe@59 42 private VersionStatus status = VersionStatus.Future;
universe@37 43
universe@59 44 public Version(int id, Project project) {
universe@37 45 this.id = id;
universe@59 46 this.project = project;
universe@37 47 }
universe@37 48
universe@37 49 public int getId() {
universe@37 50 return id;
universe@37 51 }
universe@37 52
universe@75 53 public void setProject(Project project) {
universe@75 54 this.project = project;
universe@75 55 }
universe@75 56
universe@59 57 public Project getProject() {
universe@59 58 return project;
universe@59 59 }
universe@59 60
universe@37 61 public String getName() {
universe@37 62 return name;
universe@37 63 }
universe@37 64
universe@37 65 public void setName(String name) {
universe@37 66 this.name = name;
universe@37 67 }
universe@37 68
universe@37 69 public int getOrdinal() {
universe@37 70 return ordinal;
universe@37 71 }
universe@37 72
universe@37 73 public void setOrdinal(int ordinal) {
universe@37 74 this.ordinal = ordinal;
universe@37 75 }
universe@37 76
universe@37 77 public VersionStatus getStatus() {
universe@37 78 return status;
universe@37 79 }
universe@37 80
universe@37 81 public void setStatus(VersionStatus status) {
universe@37 82 this.status = status;
universe@37 83 }
universe@37 84
universe@37 85 @Override
universe@37 86 public boolean equals(Object o) {
universe@37 87 if (this == o) return true;
universe@37 88 if (o == null || getClass() != o.getClass()) return false;
universe@37 89 Version version = (Version) o;
universe@37 90 return id == version.id;
universe@37 91 }
universe@37 92
universe@37 93 @Override
universe@37 94 public int hashCode() {
universe@37 95 return Objects.hash(id);
universe@37 96 }
universe@37 97
universe@37 98 @Override
universe@37 99 public int compareTo(Version version) {
universe@37 100 int ord = Integer.compare(this.ordinal, version.ordinal);
universe@37 101 if (ord == 0) {
universe@37 102 return this.name.compareToIgnoreCase(version.name);
universe@37 103 } else {
universe@37 104 return ord;
universe@37 105 }
universe@37 106 }
universe@37 107 }

mercurial