Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 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 | */ |
| 16 | package org.onosproject.pcep.controller; |
| 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | |
| 22 | /** |
| 23 | * Representation of capabilities supported by client. |
| 24 | */ |
| 25 | public class ClientCapability { |
| 26 | private boolean pceccCapability; |
| 27 | private boolean statefulPceCapability; |
| 28 | private boolean pcInstantiationCapability; |
| 29 | |
| 30 | /** |
| 31 | * Creates new instance of client capability. |
| 32 | * |
| 33 | * @param pceccCapability represents PCECC capability |
| 34 | * @param statefulPceCapability represents stateful PCE capability |
| 35 | * @param pcInstantiationCapability represents PC initiation capability |
| 36 | */ |
| 37 | public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability) { |
| 38 | this.pceccCapability = pceccCapability; |
| 39 | this.statefulPceCapability = statefulPceCapability; |
| 40 | this.pcInstantiationCapability = pcInstantiationCapability; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Obtains PCECC capability. |
| 45 | * |
| 46 | * @return true if client supports PCECC capability otherwise false |
| 47 | */ |
| 48 | public boolean pceccCapability() { |
| 49 | return pceccCapability; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Obtains stateful PCE capability. |
| 54 | * |
| 55 | * @return true if client supports stateful PCE capability otherwise false |
| 56 | */ |
| 57 | public boolean statefulPceCapability() { |
| 58 | return statefulPceCapability; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Obtains PC initiation capability. |
| 63 | * |
| 64 | * @return true if client supports PC initiation capability otherwise false |
| 65 | */ |
| 66 | public boolean pcInstantiationCapability() { |
| 67 | return pcInstantiationCapability; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public int hashCode() { |
| 72 | return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public boolean equals(Object obj) { |
| 77 | if (this == obj) { |
| 78 | return true; |
| 79 | } |
| 80 | if (obj instanceof ClientCapability) { |
| 81 | ClientCapability other = (ClientCapability) obj; |
| 82 | return Objects.equals(pceccCapability, other.pceccCapability) |
| 83 | && Objects.equals(statefulPceCapability, other.statefulPceCapability) |
| 84 | && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability); |
| 85 | } |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public String toString() { |
| 91 | return MoreObjects.toStringHelper(getClass()) |
| 92 | .add("pceccCapability", pceccCapability) |
| 93 | .add("statefulPceCapability", statefulPceCapability) |
| 94 | .add("pcInstantiationCapability", pcInstantiationCapability) |
| 95 | .toString(); |
| 96 | } |
| 97 | } |