blob: ee677fa2a2eb2ef369775380407bd64ab1b69e2b (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
|
package com.keuin.kbackupfabric.backup.incremental;
import com.keuin.kbackupfabric.backup.incremental.identifier.ObjectIdentifier;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.Objects;
/**
* Representing a file in a ObjectCollection.
* Immutable.
*/
public class ObjectElement implements Serializable, Comparable<ObjectElement> {
private final String name;
private final ObjectIdentifier identifier;
public ObjectElement(String name, ObjectIdentifier identifier) {
Objects.requireNonNull(name);
Objects.requireNonNull(identifier);
this.name = name;
this.identifier = identifier;
}
/**
* Get file name.
* @return the file name.
*/
public String getName() {
return name;
}
/**
* Get file identifier, which is considered to be different between files with different contents.
* @return the identifier.
*/
public ObjectIdentifier getIdentifier() {
return identifier;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ObjectElement that = (ObjectElement) o;
return name.equals(that.name) &&
identifier.equals(that.identifier);
}
@Override
public int hashCode() {
return Objects.hash(name, identifier);
}
@Override
public String toString() {
return "ObjectElement{" +
"name='" + name + '\'' +
", identifier=" + identifier +
'}';
}
@Override
public int compareTo(@NotNull ObjectElement objectElement) {
return name.compareTo(objectElement.name);
}
}
|