1 | /** |
2 | * |
3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
4 | * |
5 | * ==================================================================== |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * 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, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * ==================================================================== |
18 | */ |
19 | package org.jclouds.compute.domain; |
20 | |
21 | import static com.google.common.base.Preconditions.checkNotNull; |
22 | |
23 | import javax.annotation.Nullable; |
24 | |
25 | /** |
26 | * |
27 | * @author Adrian Cole |
28 | */ |
29 | public class OperatingSystemBuilder { |
30 | @Nullable |
31 | private OsFamily family; |
32 | @Nullable |
33 | private String name; |
34 | @Nullable |
35 | private String arch; |
36 | @Nullable |
37 | private String version; |
38 | private String description; |
39 | private boolean is64Bit; |
40 | |
41 | public OperatingSystemBuilder family(@Nullable OsFamily family) { |
42 | this.family = family; |
43 | return this; |
44 | } |
45 | |
46 | public OperatingSystemBuilder name(@Nullable String name) { |
47 | this.name = name; |
48 | return this; |
49 | } |
50 | |
51 | public OperatingSystemBuilder arch(@Nullable String arch) { |
52 | this.arch = arch; |
53 | return this; |
54 | } |
55 | |
56 | public OperatingSystemBuilder version(@Nullable String version) { |
57 | this.version = version; |
58 | return this; |
59 | } |
60 | |
61 | public OperatingSystemBuilder description(String description) { |
62 | this.description = checkNotNull(description, "description"); |
63 | return this; |
64 | } |
65 | |
66 | public OperatingSystemBuilder is64Bit(boolean is64Bit) { |
67 | this.is64Bit = is64Bit; |
68 | return this; |
69 | } |
70 | |
71 | public OperatingSystem build() { |
72 | return new OperatingSystem(family, name, version, arch, description, is64Bit); |
73 | } |
74 | |
75 | public static OperatingSystem fromOperatingSystem(OperatingSystem in) { |
76 | return new OperatingSystem(in.getFamily(), in.getName(), in.getVersion(), in.getArch(), in.getDescription(), |
77 | in.is64Bit()); |
78 | } |
79 | } |