summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
blob: 8c941ea27cb6d78f8fd101a2d5e26f69a82e9718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
 * Copyright 2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.vtnrsc;

import static com.google.common.base.MoreObjects.toStringHelper;

import java.util.Objects;

/**
 * Default implementation of  TenantNetwork interface.
 */
public final class DefaultTenantNetwork implements TenantNetwork {
    private final TenantNetworkId id;
    private final String name;
    private final boolean adminStateUp;
    private final State state;
    private final boolean shared;
    private final Type type;
    private final TenantId tenantId;
    private final boolean routerExternal;
    private final PhysicalNetwork physicalNetwork;
    private final SegmentationId segmentationId;

    /**
     * Creates a neutronNetwork element attributed to the specified provider.
     *
     * @param id  network identifier
     * @param name the network name
     * @param adminStateUp administrative state of the network
     * @param state the network state
     * @param shared indicates whether this network is shared across all
     *            tenants, By default, only administrative user can change this
     *            value
     * @param tenantId tenant identifier
     * @param routerExternal network routerExternal
     * @param type the network type
     * @param physicalNetwork physicalNetwork identifier
     * @param segmentationId segmentation identifier
     */
    public DefaultTenantNetwork(TenantNetworkId id, String name,
                                boolean adminStateUp, State state,
                                boolean shared, TenantId tenantId,
                                boolean routerExternal, Type type,
                                PhysicalNetwork physicalNetwork,
                                SegmentationId segmentationId) {
        this.id = id;
        this.name = name;
        this.adminStateUp = adminStateUp;
        this.state = state;
        this.shared = shared;
        this.type = type;
        this.tenantId = tenantId;
        this.routerExternal = routerExternal;
        this.physicalNetwork = physicalNetwork;
        this.segmentationId = segmentationId;
    }

    @Override
    public TenantNetworkId id() {
        return id;
    }

    @Override
    public String name() {
        return name;
    }

    @Override
    public boolean adminStateUp() {
        return adminStateUp;
    }

    @Override
    public State state() {
        return state;
    }

    @Override
    public boolean shared() {
        return shared;
    }

    @Override
    public TenantId tenantId() {
        return tenantId;
    }

    @Override
    public boolean routerExternal() {
        return routerExternal;
    }

    @Override
    public Type type() {
        return type;
    }

    @Override
    public PhysicalNetwork physicalNetwork() {
        return physicalNetwork;
    }

    @Override
    public SegmentationId segmentationId() {
        return segmentationId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
                            routerExternal, type, physicalNetwork,
                            segmentationId);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof DefaultTenantNetwork) {
            final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
            return Objects.equals(this.id, that.id)
                    && Objects.equals(this.name, that.name)
                    && Objects.equals(this.adminStateUp, that.adminStateUp)
                    && Objects.equals(this.state, that.state)
                    && Objects.equals(this.shared, that.shared)
                    && Objects.equals(this.tenantId, that.tenantId)
                    && Objects.equals(this.routerExternal, that.routerExternal)
                    && Objects.equals(this.type, that.type)
                    && Objects.equals(this.physicalNetwork,
                                      that.physicalNetwork)
                    && Objects.equals(this.segmentationId, that.segmentationId);
        }
        return false;
    }

    @Override
    public String toString() {
        return toStringHelper(this).add("id", id).add("name", name)
                .add("adminStateUp", adminStateUp).add("state", state)
                .add("shared", shared).add("tenantId", tenantId)
                .add("routeExternal", routerExternal).add("type", type)
                .add("physicalNetwork", physicalNetwork)
                .add("segmentationId", segmentationId).toString();
    }

}