blob: 7e429e20af80a8399f70a2b5503233fca0469325 [file] [log] [blame]
Brian O'Connor6de2e202015-05-21 14:30:41 -07001package org.onosproject.incubator.net.resource.label;
jccfff0de92015-03-28 01:40:08 -07002
3import java.util.Collection;
4import java.util.Objects;
5
6import org.onosproject.net.DeviceId;
7
8import com.google.common.base.MoreObjects;
9import com.google.common.collect.ImmutableSet;
10/**
11 * Represents for a label request.
12 */
13public class LabelResourceRequest {
14
15 private final DeviceId deviceId;
16 private final Type type;
17 private final long applyNum;
18 private ImmutableSet<LabelResource> releaseCollection;
19
20 /**
21 * Creates LabelResourceRequest object.
22 * @param deviceId device identifier
23 * @param type request type
24 * @param applyNum apply the number of labels
25 * @param releaseCollection Set of released label
26 */
27 public LabelResourceRequest(DeviceId deviceId,
28 Type type,
29 long applyNum,
30 ImmutableSet<LabelResource> releaseCollection) {
31 this.deviceId = deviceId;
32 this.type = type;
33 this.applyNum = applyNum;
34 this.releaseCollection = releaseCollection;
35 }
36 /**
37 * Returns a device id.
38 * @return DeviceId
39 */
40 public DeviceId deviceId() {
41 return deviceId;
42 }
43
44 /**
45 * Returns request type.
46 * @return Type
47 */
48 public Type type() {
49 return type;
50 }
51
52 /**
53 * Returns apply label number.
54 * @return label number
55 */
56 public long applyNum() {
57 return applyNum;
58 }
59
60 /**
61 * Returns the collection of release labels.
62 * @return Collection of DefaultLabelResource
63 */
64 public Collection<LabelResource> releaseCollection() {
65 return releaseCollection;
66 }
67
68 /**
69 * Request type.
70 */
71 public enum Type {
72 APPLY, //apple label request
73 RELEASE //release label request
74 }
75
76 @Override
77 public int hashCode() {
78 return Objects.hash(this.deviceId, this.applyNum, this.type,
79 this.releaseCollection);
80 }
81
82 @Override
83 public boolean equals(Object obj) {
84 if (obj instanceof LabelResourceRequest) {
85 LabelResourceRequest that = (LabelResourceRequest) obj;
86 return Objects.equals(this.deviceId, that.deviceId)
87 && Objects.equals(this.applyNum, that.applyNum)
88 && Objects.equals(this.type, that.type)
89 && Objects.equals(this.releaseCollection,
90 that.releaseCollection);
91 }
92 return false;
93 }
94
95 @Override
96 public String toString() {
97 return MoreObjects.toStringHelper(this).add("deviceId", this.deviceId)
98 .add("applyNum", this.applyNum).add("type", this.type)
99 .add("releaseCollection", this.releaseCollection).toString();
100 }
101}