blob: 51515e018689085f0a39a859baa6ca4e72f2e36a [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;
17
18import java.util.List;
19
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * Default Networks implementation.
25 * <p>
26 * The Set/Get methods below are defined to accept and pass references because
27 * the object class is treated as a "composite" object class that holds
28 * references to various member objects and their relationships, forming a
29 * data tree. Internal routines of the TE topology manager may use the
30 * following example methods to construct and manipulate any piece of data in
31 * the data tree:
32 * <pre>
33 * newNode.getTe().setAdminStatus(), or
34 * newNode.getSupportingNodeIds().add(nodeId), etc.
35 * </pre>
36 * Same for constructors where, for example, a child list may be constructed
37 * first and passed in by reference to its parent object constructor.
38 */
39public class DefaultNetworks implements Networks, TeTopologyEventSubject {
40 private List<Network> networks;
41
42 /**
43 * Creates an instance of DefaultNetworks.
44 */
45 public DefaultNetworks() {
46 }
47
48 /**
49 * Constructor with all fields.
50 *
51 * @param networks list of networks
52 */
53 public DefaultNetworks(List<Network> networks) {
54 this.networks = networks;
55 }
56
57 @Override
58 public List<Network> networks() {
59 return networks;
60 }
61
62 /**
63 * Sets the networks.
64 *
65 * @param networks the networks to set
66 */
67 public void setNetworks(List<Network> networks) {
68 this.networks = networks;
69 }
70
71 @Override
72 public int hashCode() {
73 return Objects.hashCode(networks);
74 }
75
76 @Override
77 public boolean equals(Object object) {
78 if (this == object) {
79 return true;
80 }
81 if (object instanceof DefaultNetworks) {
82 DefaultNetworks that = (DefaultNetworks) object;
83 return Objects.equal(this.networks, that.networks);
84 }
85 return false;
86 }
87
88 @Override
89 public String toString() {
90 return MoreObjects.toStringHelper(this)
91 .add("networks", networks)
92 .toString();
93 }
94
95}