blob: 46ccafdd89bbb2f11dfbb4e9740499ee02c6964c [file] [log] [blame]
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -08001/*
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 */
16package org.onosproject.net.group;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20import org.onosproject.core.ApplicationId;
21import org.onosproject.net.DeviceId;
22
23public class DefaultGroupDescription implements GroupDescription {
24 private final GroupDescription.Type type;
25 private final GroupBuckets buckets;
26 private final GroupKey appCookie;
27 private final ApplicationId appId;
28 private final DeviceId deviceId;
29
30 /**
31 *
32 * @param deviceId device identifier
33 * @param type type of the group
34 * @param buckets immutable list of group bucket
35 * @param appCookie immutable application cookie to be associated with the group
36 * @param appId application id
37 *
38 * NOTE: The caller of this subsystem MUST ensure the appCookie
39 * provided in this API is immutable
40 */
41 public DefaultGroupDescription(DeviceId deviceId,
42 GroupDescription.Type type,
43 GroupBuckets buckets,
44 GroupKey appCookie,
45 ApplicationId appId) {
46 this.type = checkNotNull(type);
47 this.deviceId = checkNotNull(deviceId);
48 this.buckets = checkNotNull(buckets);
49 this.appCookie = checkNotNull(appCookie);
50 this.appId = checkNotNull(appId);
51 }
52
53 /**
54 * Return type of a group object.
55 *
56 * @return GroupType group type
57 */
58 @Override
59 public GroupDescription.Type type() {
60 return this.type;
61 }
62
63 /**
64 * Return device identifier on which this group object is created.
65 *
66 * @return DeviceId device identifier
67 */
68 @Override
69 public DeviceId deviceId() {
70 return this.deviceId;
71 }
72
73 /**
74 * Return application identifier that has created this group object.
75 *
76 * @return ApplicationId application identifier
77 */
78 @Override
79 public ApplicationId appId() {
80 return this.appId;
81 }
82
83 /**
84 * Return application cookie associated with a group object.
85 *
86 * @return GroupKey application cookie
87 */
88 @Override
89 public GroupKey appCookie() {
90 return this.appCookie;
91 }
92
93 /**
94 * Return group buckets of a group.
95 *
96 * @return GroupBuckets immutable list of group bucket
97 */
98 @Override
99 public GroupBuckets buckets() {
100 return this.buckets;
101 }
102
103}