| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.cloudsigma.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | * @author Adrian Cole |
| 26 | */ |
| 27 | public class ProfileInfo { |
| 28 | |
| 29 | public static class Builder { |
| 30 | protected String uuid; |
| 31 | protected String email; |
| 32 | protected String firstName; |
| 33 | protected String lastName; |
| 34 | protected String nickName; |
| 35 | protected ProfileType type = ProfileType.REGULAR; |
| 36 | |
| 37 | public Builder uuid(String uuid) { |
| 38 | this.uuid = uuid; |
| 39 | return this; |
| 40 | } |
| 41 | |
| 42 | public Builder email(String email) { |
| 43 | this.email = email; |
| 44 | return this; |
| 45 | } |
| 46 | |
| 47 | public Builder firstName(String firstName) { |
| 48 | this.firstName = firstName; |
| 49 | return this; |
| 50 | } |
| 51 | |
| 52 | public Builder lastName(String lastName) { |
| 53 | this.lastName = lastName; |
| 54 | return this; |
| 55 | } |
| 56 | |
| 57 | public Builder nickName(String nickName) { |
| 58 | this.nickName = nickName; |
| 59 | return this; |
| 60 | } |
| 61 | |
| 62 | public Builder type(ProfileType type) { |
| 63 | this.type = type; |
| 64 | return this; |
| 65 | } |
| 66 | |
| 67 | public ProfileInfo build() { |
| 68 | return new ProfileInfo(uuid, email, firstName, lastName, nickName, type); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 | protected final String uuid; |
| 74 | protected final String email; |
| 75 | protected final String firstName; |
| 76 | protected final String lastName; |
| 77 | protected final String nickName; |
| 78 | protected final ProfileType type; |
| 79 | |
| 80 | public ProfileInfo(String uuid, String email, String firstName, String lastName, String nickName, ProfileType type) { |
| 81 | this.uuid = checkNotNull(uuid, "uuid"); |
| 82 | this.email = checkNotNull(email, "email"); |
| 83 | this.firstName = checkNotNull(firstName, "firstName"); |
| 84 | this.lastName = checkNotNull(lastName, "lastName"); |
| 85 | this.nickName = checkNotNull(nickName, "nickName"); |
| 86 | this.type = checkNotNull(type, "type"); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * |
| 91 | * @return uuid of the profile. |
| 92 | */ |
| 93 | public String getUuid() { |
| 94 | return uuid; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Checks for valid email address |
| 99 | * |
| 100 | * @return email of the profile. |
| 101 | */ |
| 102 | public String getEmail() { |
| 103 | return email; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * |
| 108 | * @return firstName of the profile. |
| 109 | */ |
| 110 | protected String getFirstName() { |
| 111 | return firstName; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * |
| 116 | * @return lastName of the profile. |
| 117 | */ |
| 118 | protected String getLastName() { |
| 119 | return lastName; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Used in phpBB nick name |
| 124 | * |
| 125 | * @return nickName of the profile. |
| 126 | */ |
| 127 | protected String getNickName() { |
| 128 | return nickName; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * |
| 133 | * @return type of the profile. |
| 134 | */ |
| 135 | protected ProfileType getType() { |
| 136 | return type; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public int hashCode() { |
| 141 | final int prime = 31; |
| 142 | int result = 1; |
| 143 | result = prime * result + ((email == null) ? 0 : email.hashCode()); |
| 144 | result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); |
| 145 | result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); |
| 146 | result = prime * result + ((nickName == null) ? 0 : nickName.hashCode()); |
| 147 | result = prime * result + ((type == null) ? 0 : type.hashCode()); |
| 148 | result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); |
| 149 | return result; |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public boolean equals(Object obj) { |
| 154 | if (this == obj) |
| 155 | return true; |
| 156 | if (obj == null) |
| 157 | return false; |
| 158 | if (getClass() != obj.getClass()) |
| 159 | return false; |
| 160 | ProfileInfo other = (ProfileInfo) obj; |
| 161 | if (email == null) { |
| 162 | if (other.email != null) |
| 163 | return false; |
| 164 | } else if (!email.equals(other.email)) |
| 165 | return false; |
| 166 | if (firstName == null) { |
| 167 | if (other.firstName != null) |
| 168 | return false; |
| 169 | } else if (!firstName.equals(other.firstName)) |
| 170 | return false; |
| 171 | if (lastName == null) { |
| 172 | if (other.lastName != null) |
| 173 | return false; |
| 174 | } else if (!lastName.equals(other.lastName)) |
| 175 | return false; |
| 176 | if (nickName == null) { |
| 177 | if (other.nickName != null) |
| 178 | return false; |
| 179 | } else if (!nickName.equals(other.nickName)) |
| 180 | return false; |
| 181 | if (type != other.type) |
| 182 | return false; |
| 183 | if (uuid == null) { |
| 184 | if (other.uuid != null) |
| 185 | return false; |
| 186 | } else if (!uuid.equals(other.uuid)) |
| 187 | return false; |
| 188 | return true; |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public String toString() { |
| 193 | return "[uuid=" + uuid + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName |
| 194 | + ", nickName=" + nickName + ", type=" + type + "]"; |
| 195 | } |
| 196 | |
| 197 | } |