blob: 6bd73a8567c5db8b8af8eda6665b4d2a6afad7c4 [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
samuel8d6b0a92015-07-11 13:22:57 +08003 *
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.net.behaviour;
17
18import java.util.Objects;
19
20import org.onosproject.net.AbstractDescription;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.SparseAnnotations;
23
24import com.google.common.base.MoreObjects;
25
26/**
27 * The default implementation of bridge.
28 */
29public final class DefaultBridgeDescription extends AbstractDescription
30 implements BridgeDescription {
31
32 private final BridgeName name;
33 private final DeviceId deviceId;
34 private final DeviceId controllerId;
35
36 public DefaultBridgeDescription(BridgeName name, DeviceId controllerId,
37 DeviceId deviceId,
38 SparseAnnotations... annotations) {
39 super(annotations);
40 this.name = name;
41 this.deviceId = deviceId;
42 this.controllerId = controllerId;
43 }
44
45 @Override
46 public BridgeName bridgeName() {
47 return name;
48 }
49
50 @Override
51 public DeviceId deviceId() {
52 return deviceId;
53 }
54
55 @Override
56 public DeviceId cotrollerDeviceId() {
57 return controllerId;
58 }
59
60 @Override
61 public int hashCode() {
62 return Objects.hash(name, deviceId, controllerId);
63 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (this == obj) {
68 return true;
69 }
70 if (obj instanceof DefaultBridgeDescription) {
71 final DefaultBridgeDescription that = (DefaultBridgeDescription) obj;
72 return this.getClass() == that.getClass()
73 && Objects.equals(this.name, that.name)
74 && Objects.equals(this.deviceId, that.deviceId)
75 && Objects.equals(this.controllerId, that.controllerId);
76 }
77 return false;
78 }
79
80 @Override
81 public String toString() {
82 return MoreObjects.toStringHelper(getClass()).add("name", name)
83 .add("deviceId", deviceId).add("controllerId", controllerId)
84 .toString();
85 }
86
87}