CNlucius | 5b2fff1 | 2015-08-20 14:13:46 +0800 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright 2015 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.vtnrsc;
|
| 17 |
|
| 18 | import java.util.Objects;
|
| 19 |
|
| 20 | import static com.google.common.base.MoreObjects.toStringHelper;
|
| 21 | import static com.google.common.base.Preconditions.checkNotNull;
|
| 22 |
|
| 23 | /**
|
| 24 | * Immutable representation of a security group.
|
| 25 | */
|
| 26 | public final class SecurityGroup {
|
| 27 | private final String securityGroup;
|
| 28 |
|
| 29 | /**
|
| 30 | * Returns the securityGroup.
|
| 31 | *
|
| 32 | * @return securityGroup
|
| 33 | */
|
| 34 | public String securityGroup() {
|
| 35 | return securityGroup;
|
| 36 | }
|
| 37 | // Public construction is prohibited
|
| 38 | private SecurityGroup(String securityGroup) {
|
| 39 | checkNotNull(securityGroup, "SecurityGroup cannot be null");
|
| 40 | this.securityGroup = securityGroup;
|
| 41 | }
|
| 42 |
|
| 43 | /**
|
| 44 | * Creates a securityGroup using the supplied securityGroup.
|
| 45 | *
|
| 46 | * @param securityGroup security group
|
| 47 | * @return securityGroup
|
| 48 | */
|
| 49 | public static SecurityGroup securityGroup(String securityGroup) {
|
| 50 | return new SecurityGroup(securityGroup);
|
| 51 | }
|
| 52 |
|
| 53 | @Override
|
| 54 | public int hashCode() {
|
| 55 | return Objects.hash(securityGroup);
|
| 56 | }
|
| 57 |
|
| 58 | @Override
|
| 59 | public boolean equals(Object obj) {
|
| 60 | if (this == obj) {
|
| 61 | return true;
|
| 62 | }
|
| 63 | if (obj instanceof SecurityGroup) {
|
| 64 | final SecurityGroup that = (SecurityGroup) obj;
|
| 65 | return this.getClass() == that.getClass()
|
| 66 | && Objects.equals(this.securityGroup, that.securityGroup);
|
| 67 | }
|
| 68 | return false;
|
| 69 | }
|
| 70 |
|
| 71 | @Override
|
| 72 | public String toString() {
|
| 73 | return toStringHelper(this).add("securityGroup", securityGroup)
|
| 74 | .toString();
|
| 75 | }
|
| 76 |
|
| 77 | }
|