blob: 124f9129eeb540c5a235309f3b1c957c4698e220 [file] [log] [blame]
SONA Project6bc5c4a2018-12-14 23:49:52 +09001/*
2 * Copyright 2019-present Open Networking Foundation
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.openstacknetworking.impl;
17
18import com.google.common.base.MoreObjects;
19import org.onosproject.openstacknetworking.api.OpenstackNetwork;
20
21import java.util.Objects;
22
23/**
24 * Default implementation of augmented network.
25 */
26public final class DefaultOpenstackNetwork implements OpenstackNetwork {
27
28 private final String networkId;
29 private final Type type;
30
31 /**
32 * A default constructor for openstack network implementation class.
33 *
34 * @param networkId network ID
35 * @param type network type
36 */
37 public DefaultOpenstackNetwork(String networkId, Type type) {
38 this.networkId = networkId;
39 this.type = type;
40 }
41
42 @Override
43 public String networkId() {
44 return networkId;
45 }
46
47 @Override
48 public Type type() {
49 return type;
50 }
51
52 @Override
53 public String toString() {
54 return MoreObjects.toStringHelper(getClass())
55 .add("networkId", networkId)
56 .add("type", type)
57 .toString();
58 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (this == obj) {
63 return true;
64 }
65 if (obj instanceof DefaultOpenstackNetwork) {
66 DefaultOpenstackNetwork that = (DefaultOpenstackNetwork) obj;
67 return Objects.equals(networkId, that.networkId) &&
68 Objects.equals(type, that.type);
69 }
70 return false;
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(networkId, type);
76 }
77}