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