Hyunsun Moon | 7ad9220 | 2016-04-20 10:36:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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.xosclient.api; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
| 25 | * Objects holding XOS API access information. |
| 26 | */ |
| 27 | public class XosAccess { |
| 28 | |
| 29 | private final String endpoint; |
| 30 | private final String username; |
| 31 | private final String password; |
| 32 | |
| 33 | /** |
| 34 | * Default constructor. |
| 35 | * |
| 36 | * @param endpoint XOS service endpoint |
| 37 | * @param adminUser admin user name |
| 38 | * @param adminPassword admin password |
| 39 | */ |
| 40 | public XosAccess(String endpoint, String adminUser, String adminPassword) { |
| 41 | this.endpoint = checkNotNull(endpoint); |
| 42 | this.username = checkNotNull(adminUser); |
| 43 | this.password = checkNotNull(adminPassword); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns XOS service endpoint. |
| 48 | * |
| 49 | * @return endpoint |
| 50 | */ |
| 51 | public String endpoint() { |
| 52 | return this.endpoint; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns admin user name. |
| 57 | * |
| 58 | * @return user name |
| 59 | */ |
| 60 | public String username() { |
| 61 | return this.username; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Returns admin password. |
| 66 | * |
| 67 | * @return password |
| 68 | */ |
| 69 | public String password() { |
| 70 | return this.password; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public int hashCode() { |
| 75 | return Objects.hash(endpoint, username, password); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public boolean equals(Object obj) { |
| 80 | if (this == obj) { |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | if ((obj instanceof XosAccess)) { |
| 85 | XosAccess that = (XosAccess) obj; |
| 86 | if (Objects.equals(endpoint, that.endpoint) && |
| 87 | Objects.equals(username, that.username) && |
| 88 | Objects.equals(password, that.password)) { |
| 89 | return true; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public String toString() { |
| 98 | return MoreObjects.toStringHelper(getClass()) |
| 99 | .add("endpoint", endpoint) |
| 100 | .add("username", username) |
| 101 | .add("password", password) |
| 102 | .toString(); |
| 103 | } |
| 104 | } |