blob: 97d8cbb6a50428eb63e2ef4aa72a2b84eb6fa966 (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.task.util.editor;
import java.util.Objects;
/**
* Represents a snapshot of the TextBuffer, between two edits (or the initial or final state)
*
* @author hakon
*/
public class Version {
private final int version;
Version() {
this(0);
}
private Version(int version) {
this.version = version;
}
public boolean isBefore(Version that) {
return version < that.version;
}
public int asInt() {
return version;
}
public Version next() {
return new Version(version + 1);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Version that = (Version) o;
return version == that.version;
}
@Override
public int hashCode() {
return Objects.hash(version);
}
@Override
public String toString() {
return String.valueOf(version);
}
}
|