| 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.softlayer.domain; |
| 20 | |
| 21 | /** |
| 22 | * The SoftLayer_Product_Item_Category data type contains |
| 23 | * general category information for prices. |
| 24 | * |
| 25 | * @author Jason King |
| 26 | * @see <a href= |
| 27 | * "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Category" |
| 28 | * /> |
| 29 | */ |
| 30 | public class ProductItemCategory implements Comparable<ProductItemCategory> { |
| 31 | |
| 32 | // TODO there are more elements than this. |
| 33 | |
| 34 | public static Builder builder() { |
| 35 | return new Builder(); |
| 36 | } |
| 37 | |
| 38 | public static class Builder { |
| 39 | private int id = -1; |
| 40 | private String name; |
| 41 | private String categoryCode; |
| 42 | |
| 43 | public Builder id(int id) { |
| 44 | this.id = id; |
| 45 | return this; |
| 46 | } |
| 47 | |
| 48 | public Builder name(String name) { |
| 49 | this.name = name; |
| 50 | return this; |
| 51 | } |
| 52 | |
| 53 | public Builder categoryCode(String categoryCode) { |
| 54 | this.categoryCode = categoryCode; |
| 55 | return this; |
| 56 | } |
| 57 | |
| 58 | public ProductItemCategory build() { |
| 59 | return new ProductItemCategory(id, name, categoryCode); |
| 60 | } |
| 61 | |
| 62 | public static Builder fromProductItemCategory(ProductItemCategory in) { |
| 63 | return ProductItemCategory.builder().id(in.getId()) |
| 64 | .name(in.getName()) |
| 65 | .categoryCode(in.getCategoryCode()); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | private int id = -1; |
| 70 | private String name; |
| 71 | private String categoryCode; |
| 72 | |
| 73 | // for deserializer |
| 74 | ProductItemCategory() { |
| 75 | |
| 76 | } |
| 77 | |
| 78 | public ProductItemCategory(int id, String name, String categoryCode) { |
| 79 | this.id = id; |
| 80 | this.name = name; |
| 81 | this.categoryCode = categoryCode; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public int compareTo(ProductItemCategory arg0) { |
| 86 | return new Integer(id).compareTo(arg0.getId()); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @return The unique identifier of a specific location. |
| 91 | */ |
| 92 | public int getId() { |
| 93 | return id; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @return The friendly, descriptive name of the category as seen on the order forms and on invoices. |
| 98 | */ |
| 99 | public String getName() { |
| 100 | return name; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @return The code used to identify this category. |
| 105 | */ |
| 106 | public String getCategoryCode() { |
| 107 | return categoryCode; |
| 108 | } |
| 109 | |
| 110 | public Builder toBuilder() { |
| 111 | return Builder.fromProductItemCategory(this); |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public int hashCode() { |
| 116 | final int prime = 31; |
| 117 | int result = 1; |
| 118 | result = prime * result + (id ^ (id >>> 32)); |
| 119 | return result; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public boolean equals(Object obj) { |
| 124 | if (this == obj) |
| 125 | return true; |
| 126 | if (obj == null) |
| 127 | return false; |
| 128 | if (getClass() != obj.getClass()) |
| 129 | return false; |
| 130 | ProductItemCategory other = (ProductItemCategory) obj; |
| 131 | if (id != other.id) |
| 132 | return false; |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public String toString() { |
| 138 | return "ProductItemCategory [id=" + id + ", name=" + name + ", categoryCode=" + categoryCode + "]"; |
| 139 | } |
| 140 | } |