Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.lang.common.version

File Version.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
35% of files have more coverage

Code metrics

20
25
7
1
56
45
20
0.8
3.57
7
2.86

Classes

Class Line # Actions
Version 3 25 20
0.519230851.9%
 

Contributing tests

This file is covered by 6 tests. .

Source view

1    package io.sunshower.lang.common.version;
2   
 
3    public final class Version implements Comparable<Version> {
4    private final String value;
5    private final boolean closed;
6   
 
7  13 toggle public Version(boolean closed, String value) {
8  13 this.value = value;
9  13 this.closed = closed;
10    }
11   
 
12  2 toggle public Version(String value) {
13  2 this(true, value);
14    }
15   
 
16  6 toggle public String getValue() {
17  6 return value;
18    }
19   
 
20  7 toggle boolean isClosed() {
21  7 return closed;
22    }
23   
 
24  1 toggle @Override
25    public boolean equals(Object o) {
26  1 if (this == o) return true;
27  0 if (o == null || getClass() != o.getClass()) return false;
28   
29  0 Version version = (Version) o;
30   
31  0 if (closed != version.closed) return false;
32  0 return value != null ? value.equals(version.value) : version.value == null;
33    }
34   
 
35  0 toggle @Override
36    public int hashCode() {
37  0 int result = value != null ? value.hashCode() : 0;
38  0 result = 31 * result + (closed ? 1 : 0);
39  0 return result;
40    }
41   
 
42  3 toggle @Override
43    public int compareTo(Version o) {
44  3 if (o == null) return 1;
45   
46  3 if (this.value.equals(o.value)) {
47  2 if (this.closed && !o.closed) {
48  0 return 1;
49  2 } else if (!this.closed && o.closed) {
50  1 return -1;
51    }
52  1 return 0;
53    }
54  1 return this.value.compareTo(o.value);
55    }
56    }