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.cim;
20  
21  
22  /**
23   * 
24   * ManagedElement is an abstract class that provides a common superclass (or top of the inheritance
25   * tree) for the non-association classes in the CIM Schema.
26   * 
27   * @author Adrian Cole
28   * @see <a
29   *      href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
30   *      />
31   * 
32   */
33  public abstract class ManagedElement extends SettingData {
34     public static Builder builder() {
35        return new Builder();
36     }
37  
38     /**
39      * {@inheritDoc}
40      */
41     @Override
42     public Builder toBuilder() {
43        return builder().fromManagedElement(this);
44     }
45  
46     public static class Builder extends SettingData.Builder {
47        protected String caption;
48        protected String description;
49  
50        /**
51         * @see ManagedSettingData#getCaption
52         */
53        public Builder caption(String caption) {
54           this.caption = caption;
55           return this;
56        }
57  
58        /**
59         * @see ManagedSettingData#getDescription
60         */
61        public Builder description(String description) {
62           this.description = description;
63           return this;
64        }
65  
66        public Builder fromManagedElement(ManagedElement in) {
67           return caption(in.getCaption()).description(in.getDescription()).fromSettingData(in);
68        }
69  
70        /**
71         * {@inheritDoc}
72         */
73        @Override
74        public Builder fromSettingData(SettingData in) {
75           return Builder.class.cast(super.fromSettingData(in));
76        }
77  
78        /**
79         * {@inheritDoc}
80         */
81        @Override
82        public Builder elementName(String elementName) {
83           return Builder.class.cast(super.elementName(elementName));
84        }
85  
86        /**
87         * {@inheritDoc}
88         */
89        @Override
90        public Builder instanceID(String instanceID) {
91           return Builder.class.cast(super.instanceID(instanceID));
92        }
93  
94     }
95  
96     protected final String caption;
97     protected final String description;
98  
99     public ManagedElement(String elementName, String instanceID, String caption, String description) {
100       super(elementName, instanceID);
101       this.caption = caption;
102       this.description = description;
103    }
104 
105    /**
106     * The Caption property is a short textual description (one- line string) of the object.
107     */
108    public String getCaption() {
109       return caption;
110    }
111 
112    /**
113     * The Description property provides a textual description of the object.
114     */
115    public String getDescription() {
116       return description;
117    }
118 
119    @Override
120    public String toString() {
121       return String.format("[elementName=%s, instanceID=%s, caption=%s, description=%s]", elementName, instanceID,
122                caption, description);
123    }
124 
125 }