| 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.gogrid.domain; |
| 20 | |
| 21 | import com.google.common.primitives.Longs; |
| 22 | |
| 23 | /** |
| 24 | * @author Oleksiy Yarmula |
| 25 | */ |
| 26 | public class Option implements Comparable<Option> { |
| 27 | |
| 28 | private Long id; |
| 29 | private String name; |
| 30 | private String description; |
| 31 | |
| 32 | |
| 33 | /** |
| 34 | * A no-args constructor is required for deserialization |
| 35 | */ |
| 36 | public Option() { |
| 37 | } |
| 38 | |
| 39 | public Option(Long id) { |
| 40 | this(id, null, null); |
| 41 | } |
| 42 | |
| 43 | public Option(String name) { |
| 44 | this(null, name, null); |
| 45 | } |
| 46 | |
| 47 | public Option(Long id, String name, String description) { |
| 48 | this.id = id; |
| 49 | this.name = name; |
| 50 | this.description = description; |
| 51 | } |
| 52 | |
| 53 | public long getId() { |
| 54 | return id; |
| 55 | } |
| 56 | |
| 57 | public String getName() { |
| 58 | return name; |
| 59 | } |
| 60 | |
| 61 | public String getDescription() { |
| 62 | return description; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public boolean equals(Object o) { |
| 67 | if (this == o) return true; |
| 68 | if (o == null || getClass() != o.getClass()) return false; |
| 69 | |
| 70 | Option option = (Option) o; |
| 71 | |
| 72 | if (description != null ? !description.equals(option.description) : option.description != null) return false; |
| 73 | if (id != null ? !id.equals(option.id) : option.id != null) return false; |
| 74 | if (name != null ? !name.equals(option.name) : option.name != null) return false; |
| 75 | |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public int hashCode() { |
| 81 | int result = id != null ? id.hashCode() : 0; |
| 82 | result = 31 * result + (name != null ? name.hashCode() : 0); |
| 83 | result = 31 * result + (description != null ? description.hashCode() : 0); |
| 84 | return result; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public int compareTo(Option o) { |
| 89 | return Longs.compare(id, o.id); |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public String toString() { |
| 94 | return "[id=" + id + ", name=" + name + ", description=" + description + "]"; |
| 95 | } |
| 96 | } |