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

Mon, 11 May 2020 19:09:06 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 11 May 2020 19:09:06 +0200
changeset 38
cf85ef18f231
parent 37
fecda0f466e6
child 59
c759c60507a2
permissions
-rw-r--r--

adds DAO for Project entity and save/update methods

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@37 33 public class Version implements Comparable<Version> {
universe@37 34
universe@37 35 private final int id;
universe@37 36 private String name;
universe@37 37 /**
universe@37 38 * If we do not want versions to be ordered lexicographically we may specify an order.
universe@37 39 */
universe@37 40 private int ordinal;
universe@37 41 private VersionStatus status;
universe@37 42
universe@37 43 public Version(int id) {
universe@37 44 this.id = id;
universe@37 45 }
universe@37 46
universe@37 47 public int getId() {
universe@37 48 return id;
universe@37 49 }
universe@37 50
universe@37 51 public String getName() {
universe@37 52 return name;
universe@37 53 }
universe@37 54
universe@37 55 public void setName(String name) {
universe@37 56 this.name = name;
universe@37 57 }
universe@37 58
universe@37 59 public int getOrdinal() {
universe@37 60 return ordinal;
universe@37 61 }
universe@37 62
universe@37 63 public void setOrdinal(int ordinal) {
universe@37 64 this.ordinal = ordinal;
universe@37 65 }
universe@37 66
universe@37 67 public VersionStatus getStatus() {
universe@37 68 return status;
universe@37 69 }
universe@37 70
universe@37 71 public void setStatus(VersionStatus status) {
universe@37 72 this.status = status;
universe@37 73 }
universe@37 74
universe@37 75 @Override
universe@37 76 public boolean equals(Object o) {
universe@37 77 if (this == o) return true;
universe@37 78 if (o == null || getClass() != o.getClass()) return false;
universe@37 79 Version version = (Version) o;
universe@37 80 return id == version.id;
universe@37 81 }
universe@37 82
universe@37 83 @Override
universe@37 84 public int hashCode() {
universe@37 85 return Objects.hash(id);
universe@37 86 }
universe@37 87
universe@37 88 @Override
universe@37 89 public int compareTo(Version version) {
universe@37 90 int ord = Integer.compare(this.ordinal, version.ordinal);
universe@37 91 if (ord == 0) {
universe@37 92 return this.name.compareToIgnoreCase(version.name);
universe@37 93 } else {
universe@37 94 return ord;
universe@37 95 }
universe@37 96 }
universe@37 97 }

mercurial