View Javadoc

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.trmk.vcloud_0_8.domain;
20  
21  
22  /**
23   * 
24   * @author Adrian Cole
25   */
26  public class DataCenter {
27     public static Builder builder() {
28        return new Builder();
29     }
30  
31     public static class Builder {
32        private String id;
33        private String name;
34        private String code;
35  
36        public Builder id(String id) {
37           this.id = id;
38           return this;
39        }
40  
41        public Builder name(String name) {
42           this.name = name;
43           return this;
44        }
45  
46        public Builder code(String code) {
47           this.code = code;
48           return this;
49        }
50  
51        public DataCenter build() {
52           return new DataCenter(id, name, code);
53        }
54     }
55  
56     private final String id;
57     private final String name;
58     private final String code;
59  
60     public DataCenter(String id, String name, String code) {
61        this.id = id;
62        this.name = name;
63        this.code = code;
64     }
65  
66     /**
67      * 
68      * @return id of the data center
69      */
70     public String getId() {
71        return id;
72     }
73  
74     /**
75      * 
76      * @return name of the data center
77      */
78     public String getName() {
79        return name;
80     }
81  
82     /**
83      * 
84      * @return airport code of the data center
85      */
86     public String getCode() {
87        return code;
88     }
89  
90     @Override
91     public int hashCode() {
92        final int prime = 31;
93        int result = 1;
94        result = prime * result + ((code == null) ? 0 : code.hashCode());
95        result = prime * result + ((id == null) ? 0 : id.hashCode());
96        result = prime * result + ((name == null) ? 0 : name.hashCode());
97        return result;
98     }
99  
100    @Override
101    public boolean equals(Object obj) {
102       if (this == obj)
103          return true;
104       if (obj == null)
105          return false;
106       if (getClass() != obj.getClass())
107          return false;
108       DataCenter other = (DataCenter) obj;
109       if (code == null) {
110          if (other.code != null)
111             return false;
112       } else if (!code.equals(other.code))
113          return false;
114       if (id == null) {
115          if (other.id != null)
116             return false;
117       } else if (!id.equals(other.id))
118          return false;
119       if (name == null) {
120          if (other.name != null)
121             return false;
122       } else if (!name.equals(other.name))
123          return false;
124       return true;
125    }
126 
127    @Override
128    public String toString() {
129       return "[id=" + id + ", name=" + name + ", code=" + code + "]";
130    }
131 }