blob: 646c772853a1d184464ae5fd1c3c6288d085766c [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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.tetopology.management.api.link;
17
18import com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20
21/**
22 * Represent a path element.
23 */
24public class PathElement {
25 private final long pathElementId;
26 private final ElementType type;
27
28 /**
29 * Creates an instance of PathElement.
30 *
31 * @param pathElementId path element identifier
32 * @param type path element type
33 */
34 public PathElement(long pathElementId, ElementType type) {
35 this.pathElementId = pathElementId;
36 this.type = type;
37 }
38
39 /**
40 * Returns the path element identifier.
41 *
42 * @return path element id
43 */
44 public long pathElementId() {
45 return pathElementId;
46 }
47
48 /**
49 * Returns the path element type.
50 *
51 * @return path element type
52 */
53 public ElementType type() {
54 return type;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hashCode(pathElementId, type);
60 }
61
62 @Override
63 public boolean equals(Object object) {
64 if (this == object) {
65 return true;
66 }
67 if (object instanceof PathElement) {
68 PathElement that = (PathElement) object;
69 return Objects.equal(this.pathElementId, that.pathElementId) &&
70 Objects.equal(this.type, that.type);
71 }
72 return false;
73 }
74
75 @Override
76 public String toString() {
77 return MoreObjects.toStringHelper(this)
78 .add("pathElementId", pathElementId)
79 .add("type", type)
80 .toString();
81 }
82
83}