Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.resource.label; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Collection; |
| 19 | import java.util.Objects; |
| 20 | |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 21 | import com.google.common.annotations.Beta; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DeviceId; |
| 23 | |
| 24 | import com.google.common.base.MoreObjects; |
| 25 | import com.google.common.collect.ImmutableSet; |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 26 | |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Represents for a label request. |
| 29 | */ |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 30 | @Beta |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 31 | public 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 | } |