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.domain; |
20 | |
21 | /** |
22 | * |
23 | * Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com> |
24 | * |
25 | * ==================================================================== |
26 | * Licensed under the Apache License, Version 2.0 (the "License"); |
27 | * you may not use this file except in compliance with the License. |
28 | * You may obtain a copy of the License at |
29 | * |
30 | * http://www.apache.org/licenses/LICENSE-2.0 |
31 | * |
32 | * Unless required by applicable law or agreed to in writing, software |
33 | * distributed under the License is distributed on an "AS IS" BASIS, |
34 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
35 | * See the License for the specific language governing permissions and |
36 | * limitations under the License. |
37 | * ==================================================================== |
38 | */ |
39 | |
40 | import static com.google.common.base.Preconditions.checkNotNull; |
41 | |
42 | import java.net.URI; |
43 | import java.util.Map; |
44 | |
45 | import com.google.common.collect.Maps; |
46 | |
47 | /** |
48 | * |
49 | * @author Adrian Cole |
50 | */ |
51 | public abstract class ResourceMetadataBuilder<T extends Enum<T>> { |
52 | protected String providerId; |
53 | protected String name; |
54 | protected Location location; |
55 | protected URI uri; |
56 | protected Map<String, String> userMetadata = Maps.newLinkedHashMap(); |
57 | |
58 | public ResourceMetadataBuilder<T> providerId(String providerId) { |
59 | this.providerId = providerId; |
60 | return this; |
61 | } |
62 | |
63 | public ResourceMetadataBuilder<T> name(String name) { |
64 | this.name = name; |
65 | return this; |
66 | } |
67 | |
68 | public ResourceMetadataBuilder<T> location(Location location) { |
69 | this.location = location; |
70 | return this; |
71 | } |
72 | |
73 | public ResourceMetadataBuilder<T> uri(URI uri) { |
74 | this.uri = uri; |
75 | return this; |
76 | } |
77 | |
78 | public ResourceMetadataBuilder<T> userMetadata(Map<String, String> userMetadata) { |
79 | this.userMetadata = checkNotNull(userMetadata, "userMetadata"); |
80 | return this; |
81 | } |
82 | } |