Sat, 17 Oct 2020 19:56:50 +0200
completes feature: project components
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@37 | 36 | private String name; |
universe@134 | 37 | private String node; |
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@86 | 44 | public Version(int id) { |
universe@37 | 45 | this.id = id; |
universe@37 | 46 | } |
universe@37 | 47 | |
universe@37 | 48 | public int getId() { |
universe@37 | 49 | return id; |
universe@37 | 50 | } |
universe@37 | 51 | |
universe@37 | 52 | public String getName() { |
universe@37 | 53 | return name; |
universe@37 | 54 | } |
universe@37 | 55 | |
universe@37 | 56 | public void setName(String name) { |
universe@37 | 57 | this.name = name; |
universe@37 | 58 | } |
universe@37 | 59 | |
universe@134 | 60 | public String getNode() { |
universe@134 | 61 | return node == null ? String.valueOf(id) : node; |
universe@134 | 62 | } |
universe@134 | 63 | |
universe@134 | 64 | public void setNode(String node) { |
universe@134 | 65 | this.node = node; |
universe@134 | 66 | } |
universe@134 | 67 | |
universe@37 | 68 | public int getOrdinal() { |
universe@37 | 69 | return ordinal; |
universe@37 | 70 | } |
universe@37 | 71 | |
universe@37 | 72 | public void setOrdinal(int ordinal) { |
universe@37 | 73 | this.ordinal = ordinal; |
universe@37 | 74 | } |
universe@37 | 75 | |
universe@37 | 76 | public VersionStatus getStatus() { |
universe@37 | 77 | return status; |
universe@37 | 78 | } |
universe@37 | 79 | |
universe@37 | 80 | public void setStatus(VersionStatus status) { |
universe@37 | 81 | this.status = status; |
universe@37 | 82 | } |
universe@37 | 83 | |
universe@37 | 84 | @Override |
universe@37 | 85 | public boolean equals(Object o) { |
universe@37 | 86 | if (this == o) return true; |
universe@37 | 87 | if (o == null || getClass() != o.getClass()) return false; |
universe@37 | 88 | Version version = (Version) o; |
universe@37 | 89 | return id == version.id; |
universe@37 | 90 | } |
universe@37 | 91 | |
universe@37 | 92 | @Override |
universe@37 | 93 | public int hashCode() { |
universe@37 | 94 | return Objects.hash(id); |
universe@37 | 95 | } |
universe@37 | 96 | |
universe@37 | 97 | @Override |
universe@37 | 98 | public int compareTo(Version version) { |
universe@37 | 99 | int ord = Integer.compare(this.ordinal, version.ordinal); |
universe@37 | 100 | if (ord == 0) { |
universe@37 | 101 | return this.name.compareToIgnoreCase(version.name); |
universe@37 | 102 | } else { |
universe@37 | 103 | return ord; |
universe@37 | 104 | } |
universe@37 | 105 | } |
universe@37 | 106 | } |