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