blob: 6c7dbc40ef3a0163363fd93633a7e0a4ef08ed72 [file] [log] [blame]
Jian Li89eeccd2016-05-06 02:10:33 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jian Li89eeccd2016-05-06 02:10: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 */
16package org.onosproject.cpman;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24/**
25 * A container class that is used to request available resource of remote node.
26 */
27public class ControlResourceRequest {
28 private final ControlResource.Type type;
29
30 /**
31 * Instantiates a new control resource request of the control resource type.
32 *
33 * @param type control resource type
34 */
35 public ControlResourceRequest(ControlResource.Type type) {
36 this.type = type;
37 }
38
39 /**
40 * Obtains control resource type.
41 *
42 * @return control resource type
43 */
44 public ControlResource.Type getType() {
45 return type;
46 }
47
48 @Override
49 public int hashCode() {
50 return Objects.hash(type);
51 }
52
53 @Override
54 public boolean equals(Object obj) {
55 if (this == obj) {
56 return true;
57 }
58 if (obj instanceof ControlResourceRequest) {
59 final ControlResourceRequest other = (ControlResourceRequest) obj;
60 return Objects.equals(this.type, other.type);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 MoreObjects.ToStringHelper helper;
68 helper = toStringHelper(this)
69 .add("type", type);
70 return helper.toString();
71 }
72}