/
Version.java
55 lines (44 loc) · 1.15 KB
/
Version.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright The original authors
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.moditect.model;
import java.util.Objects;
/**
* Simplified version of Runtime.Version (which requires Java 9+).
*/
public class Version {
private final int feature;
private Version(int feature) {
this.feature = feature;
}
public static Version valueOf(int feature) {
return new Version(feature);
}
public static Version valueOf(Object feature) {
return new Version(Integer.parseInt(String.valueOf(feature)));
}
public int feature() {
return feature;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Version))
return false;
Version version = (Version) o;
return feature == version.feature;
}
@Override
public int hashCode() {
return Objects.hash(feature);
}
@Override
public String toString() {
return "Version " + feature;
}
}