Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /*
|
| 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 | */
|
| 16 | package org.onosproject.iptopology.api;
|
| 17 |
|
| 18 | import org.onosproject.net.AbstractAnnotated;
|
| 19 | import org.onosproject.net.Annotations;
|
| 20 | import org.onosproject.net.Element;
|
| 21 |
|
| 22 | import java.util.Objects;
|
| 23 |
|
| 24 | import static com.google.common.base.MoreObjects.toStringHelper;
|
| 25 |
|
| 26 | /**
|
| 27 | * Default Device prefix implementation.
|
| 28 | */
|
| 29 | public class DefaultDevicePrefix extends AbstractAnnotated implements DevicePrefix {
|
| 30 |
|
| 31 | private final Element element;
|
| 32 | private final PrefixIdentifier prefixIdentifier;
|
| 33 | private final PrefixTed prefixTed;
|
| 34 |
|
| 35 | /**
|
| 36 | * Creates a network device prefix attributed to the specified element.
|
| 37 | *
|
| 38 | * @param element parent network element
|
| 39 | * @param prefixIdentifier prefix identifier
|
| 40 | * @param prefixTed prefid traffic engineering parameters
|
| 41 | * @param annotations optional key/value annotations
|
| 42 | */
|
| 43 | public DefaultDevicePrefix(Element element, PrefixIdentifier prefixIdentifier,
|
| 44 | PrefixTed prefixTed, Annotations... annotations) {
|
| 45 | super(annotations);
|
| 46 | this.element = element;
|
| 47 | this.prefixIdentifier = prefixIdentifier;
|
| 48 | this.prefixTed = prefixTed;
|
| 49 | }
|
| 50 |
|
| 51 | @Override
|
| 52 | public Element element() {
|
| 53 | return element;
|
| 54 | }
|
| 55 |
|
| 56 | @Override
|
| 57 | public PrefixIdentifier prefixIdentifier() {
|
| 58 | return prefixIdentifier;
|
| 59 | }
|
| 60 |
|
| 61 | @Override
|
| 62 | public PrefixTed prefixTed() {
|
| 63 | return prefixTed;
|
| 64 | }
|
| 65 |
|
| 66 | @Override
|
| 67 | public int hashCode() {
|
| 68 | return Objects.hash(element, prefixIdentifier, prefixTed);
|
| 69 | }
|
| 70 |
|
| 71 | @Override
|
| 72 | public boolean equals(Object obj) {
|
| 73 | if (this == obj) {
|
| 74 | return true;
|
| 75 | }
|
| 76 | if (obj instanceof DefaultDevicePrefix) {
|
| 77 | final DefaultDevicePrefix other = (DefaultDevicePrefix) obj;
|
| 78 | return Objects.equals(this.element.id(), other.element.id()) &&
|
| 79 | Objects.equals(this.prefixIdentifier, other.prefixIdentifier) &&
|
| 80 | Objects.equals(this.prefixTed, other.prefixTed) &&
|
| 81 | Objects.equals(this.annotations(), other.annotations());
|
| 82 | }
|
| 83 | return false;
|
| 84 | }
|
| 85 |
|
| 86 | @Override
|
| 87 | public String toString() {
|
| 88 | return toStringHelper(this)
|
| 89 | .omitNullValues()
|
| 90 | .add("element", element.id())
|
| 91 | .add("prefixIdentifier", prefixIdentifier)
|
| 92 | .add("prefixTed", prefixTed)
|
| 93 | .toString();
|
| 94 | }
|
| 95 | } |