blob: 554702a74536a81d00ff36cbfba82ba8bed62d54 [file] [log] [blame]
Brian O'Connorb7baf712015-07-28 23:27:03 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.domain;
17
18import com.google.common.annotations.Beta;
19
20import java.util.Objects;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Intent domain identifier.
26 */
27@Beta
28public class IntentDomainId {
29
30 private final String id;
31
32 /**
33 * Creates an intent domain identifier from the specified string representation.
34 *
35 * @param value string value
36 * @return intent identifier
37 */
38 public static IntentDomainId valueOf(String value) {
39 return new IntentDomainId(value);
40 }
41
42 /**
43 * Constructor for serializer.
44 */
45 IntentDomainId() {
46 this.id = null;
47 }
48
49 /**
50 * Constructs the ID corresponding to a given string value.
51 *
52 * @param value the underlying value of this ID
53 */
54 IntentDomainId(String value) {
55 this.id = checkNotNull(value, "Intent domain ID cannot be null.");
56 }
57
58 @Override
59 public int hashCode() {
60 return id.hashCode();
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (obj == this) {
66 return true;
67 }
68 if (!(obj instanceof IntentDomainId)) {
69 return false;
70 }
71 IntentDomainId that = (IntentDomainId) obj;
72 return Objects.equals(this.id, that.id);
73 }
74
75 @Override
76 public String toString() {
77 return id;
78 }
79}