|
| 1 | +/* |
| 2 | + * Copyright 2015-2016 http://hsweb.me |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.hsweb.web.bean.po.system; |
| 18 | + |
| 19 | +public class SystemVersion implements Comparable<SystemVersion> { |
| 20 | + public String name; |
| 21 | + public String comment; |
| 22 | + public String website; |
| 23 | + public int majorVersion = 1; |
| 24 | + public int minorVersion = 0; |
| 25 | + public int revisionVersion = 0; |
| 26 | + public boolean snapshot; |
| 27 | + |
| 28 | + public String getName() { |
| 29 | + return name; |
| 30 | + } |
| 31 | + |
| 32 | + public void setName(String name) { |
| 33 | + this.name = name; |
| 34 | + } |
| 35 | + |
| 36 | + public String getComment() { |
| 37 | + return comment; |
| 38 | + } |
| 39 | + |
| 40 | + public void setComment(String comment) { |
| 41 | + this.comment = comment; |
| 42 | + } |
| 43 | + |
| 44 | + public String getWebsite() { |
| 45 | + return website; |
| 46 | + } |
| 47 | + |
| 48 | + public void setWebsite(String website) { |
| 49 | + this.website = website; |
| 50 | + } |
| 51 | + |
| 52 | + public int getMajorVersion() { |
| 53 | + return majorVersion; |
| 54 | + } |
| 55 | + |
| 56 | + public void setMajorVersion(int majorVersion) { |
| 57 | + this.majorVersion = majorVersion; |
| 58 | + } |
| 59 | + |
| 60 | + public int getMinorVersion() { |
| 61 | + return minorVersion; |
| 62 | + } |
| 63 | + |
| 64 | + public void setMinorVersion(int minorVersion) { |
| 65 | + this.minorVersion = minorVersion; |
| 66 | + } |
| 67 | + |
| 68 | + public int getRevisionVersion() { |
| 69 | + return revisionVersion; |
| 70 | + } |
| 71 | + |
| 72 | + public void setRevisionVersion(int revisionVersion) { |
| 73 | + this.revisionVersion = revisionVersion; |
| 74 | + } |
| 75 | + |
| 76 | + public boolean isSnapshot() { |
| 77 | + return snapshot; |
| 78 | + } |
| 79 | + |
| 80 | + public void setSnapshot(boolean snapshot) { |
| 81 | + this.snapshot = snapshot; |
| 82 | + } |
| 83 | + |
| 84 | + @Override |
| 85 | + public int compareTo(SystemVersion o) { |
| 86 | + if (null == o) return -1; |
| 87 | + if (o.getMajorVersion() > this.getMajorVersion()) return -1; |
| 88 | + if (o.getMajorVersion() == this.getMajorVersion()) { |
| 89 | + if (o.getMinorVersion() > this.getMinorVersion()) return -1; |
| 90 | + if (o.getMinorVersion() == this.getMinorVersion()) { |
| 91 | + if (o.getRevisionVersion() > this.getRevisionVersion()) return -1; |
| 92 | + if (o.getRevisionVersion() == this.getRevisionVersion()) return 0; |
| 93 | + return 1; |
| 94 | + } else { |
| 95 | + return 1; |
| 96 | + } |
| 97 | + } else { |
| 98 | + return 1; |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + public static void main(String[] args) { |
| 103 | + SystemVersion systemVersion = new SystemVersion(); |
| 104 | + systemVersion.setMajorVersion(2); |
| 105 | + systemVersion.setMinorVersion(2); |
| 106 | + systemVersion.setRevisionVersion(1); |
| 107 | + |
| 108 | + SystemVersion systemVersion2 = new SystemVersion(); |
| 109 | + systemVersion2.setMajorVersion(3); |
| 110 | + systemVersion2.setMinorVersion(2); |
| 111 | + systemVersion2.setRevisionVersion(1); |
| 112 | + |
| 113 | + System.out.println(systemVersion.compareTo(systemVersion2)); |
| 114 | + } |
| 115 | +} |
0 commit comments