blob: 776e068e46a7ccd1215cf6eba408999d6ede5bf4 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-present Open Networking Foundation
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 */
Brian O'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.incubator.net.resource.label;
jccfff0de92015-03-28 01:40:08 -070017
18import java.util.Collection;
19import java.util.Objects;
20
Brian O'Connor893b9222015-06-25 15:07:04 -040021import com.google.common.annotations.Beta;
jccfff0de92015-03-28 01:40:08 -070022import org.onosproject.net.DeviceId;
23
24import com.google.common.base.MoreObjects;
25import com.google.common.collect.ImmutableSet;
Brian O'Connor893b9222015-06-25 15:07:04 -040026
jccfff0de92015-03-28 01:40:08 -070027/**
28 * Represents for a label request.
29 */
Brian O'Connor893b9222015-06-25 15:07:04 -040030@Beta
jccfff0de92015-03-28 01:40:08 -070031public class LabelResourceRequest {
32
33 private final DeviceId deviceId;
34 private final Type type;
35 private final long applyNum;
36 private ImmutableSet<LabelResource> releaseCollection;
37
38 /**
39 * Creates LabelResourceRequest object.
40 * @param deviceId device identifier
41 * @param type request type
42 * @param applyNum apply the number of labels
43 * @param releaseCollection Set of released label
44 */
45 public LabelResourceRequest(DeviceId deviceId,
46 Type type,
47 long applyNum,
48 ImmutableSet<LabelResource> releaseCollection) {
49 this.deviceId = deviceId;
50 this.type = type;
51 this.applyNum = applyNum;
52 this.releaseCollection = releaseCollection;
53 }
54 /**
55 * Returns a device id.
56 * @return DeviceId
57 */
58 public DeviceId deviceId() {
59 return deviceId;
60 }
61
62 /**
63 * Returns request type.
64 * @return Type
65 */
66 public Type type() {
67 return type;
68 }
69
70 /**
71 * Returns apply label number.
72 * @return label number
73 */
74 public long applyNum() {
75 return applyNum;
76 }
77
78 /**
79 * Returns the collection of release labels.
80 * @return Collection of DefaultLabelResource
81 */
82 public Collection<LabelResource> releaseCollection() {
83 return releaseCollection;
84 }
85
86 /**
87 * Request type.
88 */
89 public enum Type {
90 APPLY, //apple label request
91 RELEASE //release label request
92 }
93
94 @Override
95 public int hashCode() {
96 return Objects.hash(this.deviceId, this.applyNum, this.type,
97 this.releaseCollection);
98 }
99
100 @Override
101 public boolean equals(Object obj) {
102 if (obj instanceof LabelResourceRequest) {
103 LabelResourceRequest that = (LabelResourceRequest) obj;
104 return Objects.equals(this.deviceId, that.deviceId)
105 && Objects.equals(this.applyNum, that.applyNum)
106 && Objects.equals(this.type, that.type)
107 && Objects.equals(this.releaseCollection,
108 that.releaseCollection);
109 }
110 return false;
111 }
112
113 @Override
114 public String toString() {
115 return MoreObjects.toStringHelper(this).add("deviceId", this.deviceId)
116 .add("applyNum", this.applyNum).add("type", this.type)
117 .add("releaseCollection", this.releaseCollection).toString();
118 }
119}