Sleuth Kit Java Bindings (JNI) 4.14.0
Java bindings for using The Sleuth Kit
Loading...
Searching...
No Matches
VersionNumber.java
Go to the documentation of this file.
1/*
2 * Sleuth Kit Data Model
3 *
4 * Copyright 2011-2017 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.datamodel;
20
26public class VersionNumber implements Comparable<VersionNumber> {
27
28 private final int major;
29 private final int minor;
30 private final int patch;
31
32 public VersionNumber(int majorVersion, int minorVersion, int patchVersion) {
33 major = majorVersion;
34 minor = minorVersion;
35 patch = patchVersion;
36 }
37
38 public int getMajor() {
39 return major;
40 }
41
42 public int getMinor() {
43 return minor;
44 }
45
46 public int getPatch() {
47 return patch;
48 }
49
50 @Override
51 public String toString() {
52 return major + "." + minor + "." + patch;
53 }
54
55 @Override
56 public int compareTo(VersionNumber vs) {
57 int majorComp = Integer.compare(this.getMajor(), vs.getMajor());
58 if (majorComp != 0) {
59 return majorComp;
60 } else {
61 final int minorCompare = Integer.compare(this.getMinor(), vs.getMinor());
62 if (minorCompare != 0) {
63 return minorCompare;
64 } else {
65 return Integer.compare(this.getPatch(), vs.getPatch());
66 }
67 }
68 }
69
70 @Override
71 public int hashCode() {
72 int hash = 3;
73 hash = 97 * hash + this.major;
74 hash = 97 * hash + this.minor;
75 hash = 97 * hash + this.patch;
76 return hash;
77 }
78
79 @Override
80 public boolean equals(Object obj) {
81 if (this == obj) {
82 return true;
83 }
84 if (obj == null) {
85 return false;
86 }
87 if (getClass() != obj.getClass()) {
88 return false;
89 }
90 final VersionNumber other = (VersionNumber) obj;
91 return this.major == other.getMajor()
92 && this.minor == other.getMinor()
93 && this.patch == other.getPatch();
94 }
95}
VersionNumber(int majorVersion, int minorVersion, int patchVersion)

Copyright © 2011-2024 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.