1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.named;
20
21 import java.util.Arrays;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.Objects;
25
26
27
28
29
30
31
32
33 public final class NamedLockKey {
34 private final String name;
35
36 private final Collection<String> resources;
37
38 private NamedLockKey(String name, Collection<String> resources) {
39 this.name = Objects.requireNonNull(name, "name");
40 this.resources = Collections.unmodifiableCollection(Objects.requireNonNull(resources, "resources"));
41 }
42
43
44
45
46
47 public String name() {
48 return name;
49 }
50
51
52
53
54
55
56
57
58 public Collection<String> resources() {
59 return resources;
60 }
61
62 @Override
63 public boolean equals(Object o) {
64 if (this == o) {
65 return true;
66 }
67 if (o == null || getClass() != o.getClass()) {
68 return false;
69 }
70 NamedLockKey that = (NamedLockKey) o;
71 return Objects.equals(name, that.name);
72 }
73
74 @Override
75 public int hashCode() {
76 return Objects.hash(name);
77 }
78
79 @Override
80 public String toString() {
81 return getClass().getSimpleName() + "{" + "name='" + name + '\'' + ", resources=" + resources + '}';
82 }
83
84 public static NamedLockKey of(String name, String... resources) {
85 return of(name, Arrays.asList(resources));
86 }
87
88 public static NamedLockKey of(String name, Collection<String> resources) {
89 return new NamedLockKey(name, resources);
90 }
91 }