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