blob: 25c428842953fffde8facad81872f67e7c258ce8 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
import java.util.Objects;
/**
* A host name
*
* @author mortent
*/
public class HostName implements Comparable<HostName> {
private final String name;
private HostName(String name) {
this.name = name;
}
public String value() { return name; }
/** Create a {@link HostName} with a given name */
public static HostName from(String name) {
return new HostName(name);
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof HostName)) return false;
return Objects.equals(((HostName)obj).value(), value());
}
@Override
public String toString() {
return name;
}
@Override
public int compareTo(HostName that) {
return this.name.compareTo(that.name);
}
}
|