1 /*
2 (C) Copyright IBM Corp. 2006, 2013
3
4 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
5 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
6 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
7
8 You can obtain a current copy of the Eclipse Public License from
9 http://www.opensource.org/licenses/eclipse-1.0.php
10
11 @author : Alexander Wolf-Reber, a.wolf-reber@de.ibm.com
12 *
13 * Flag Date Prog Description
14 * -------------------------------------------------------------------------------
15 * 1565892 2006-09-26 lupusalex Make SBLIM client JSR48 compliant
16 * 1737141 2007-06-18 ebak Sync up with JSR48 evolution
17 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
18 * 2227442 2008-11-05 blaschke-oss Add missing serialVersionUID
19 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
20 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2)
21 * 2763216 2009-04-14 blaschke-oss Code cleanup: visible spelling/grammar errors
22 * 2795671 2009-05-22 raman_arora Add Type to Comparable <T>
23 * 2935258 2010-01-22 blaschke-oss Sync up javax.cim.* javadoc with JSR48 1.0.0
24 * 3410126 2011-09-15 blaschke-oss TCK: CIM element name cannot be null
25 * 2716 2013-12-11 blaschke-oss Sync up javax.* javadoc with JSR48 1.0.0 Final V
26 */
27
28 package org.metricshub.wbem.javax.cim;
29
30 /*-
31 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
32 * WBEM Java Client
33 * ჻჻჻჻჻჻
34 * Copyright 2023 - 2025 MetricsHub
35 * ჻჻჻჻჻჻
36 * Licensed under the Apache License, Version 2.0 (the "License");
37 * you may not use this file except in compliance with the License.
38 * You may obtain a copy of the License at
39 *
40 * http://www.apache.org/licenses/LICENSE-2.0
41 *
42 * Unless required by applicable law or agreed to in writing, software
43 * distributed under the License is distributed on an "AS IS" BASIS,
44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45 * See the License for the specific language governing permissions and
46 * limitations under the License.
47 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
48 */
49
50 import java.io.Serializable;
51
52 //Sync'd against JSR48 1.0.0 javadoc (version 1.7.0_03) on Tue Dec 10 07:02:50 EST 2013
53 /**
54 * <code>CIMElement</code> is an abstract base class that represents a CIM
55 * Element as defined by the Distributed Management Task Force (<a
56 * href=http://www.dmtf.org>DMTF</a>) CIM Infrastructure Specification (<a
57 * href=http://www.dmtf.org/standards/published_documents/DSP0004V2.3_final.pdf
58 * >DSP004</a>).
59 */
60 public abstract class CIMElement implements Serializable, Comparable<CIMElement> {
61 private static final long serialVersionUID = -3310480832682118922L;
62
63 private String iName;
64
65 /**
66 * Creates a new CIM element with the given name.
67 *
68 * @param pName
69 * The string for the name of the element.
70 * @throws IllegalArgumentException
71 * If name is <code>null</code>.
72 */
73 public CIMElement(String pName) {
74 if (pName == null) throw new IllegalArgumentException("CIM element name cannot be null");
75 this.iName = pName;
76 }
77
78 /**
79 * Compares this element name to the CIMElement passed in.
80 *
81 * @param pObj
82 * The CIMElement to be compared.
83 * @return A negative integer, zero, or a positive integer as this object is
84 * less than, equal to, or greater than the specified object.
85 */
86 public int compareTo(CIMElement pObj) {
87 if (pObj == null) return -1;
88 CIMElement that = pObj;
89 return this.iName.compareToIgnoreCase(that.iName);
90 }
91
92 /**
93 * Takes a CIM element and returns <code>true</code> if it is equal to this
94 * CIM element. Otherwise, it returns <code>false</code>. Useful for
95 * comparing two CIM elements, for example, to determine whether a CIM
96 * element exists in a Collection.
97 *
98 * @param pObj
99 * The object to be compared a CIM element.
100 * @return <code>true</code> indicates the specified CIM element equals this
101 * CIM element, <code>false</code> indicates the CIM element does
102 * not equal this CIM element.
103 */
104 @Override
105 public boolean equals(Object pObj) {
106 if (pObj instanceof CIMElement) {
107 return this.iName.equalsIgnoreCase(((CIMElement) pObj).iName);
108 }
109 return false;
110 }
111
112 /**
113 * Returns a string representing the name of a CIM element instance.
114 *
115 * @return The name of this CIM element.
116 */
117 public String getName() {
118 return this.iName;
119 }
120
121 /**
122 * Returns a hash code value for the CIM element. This method is supported
123 * for the benefit of hashtables such as those provided by
124 * <code>java.util.Hashtable</code>.
125 *
126 * @return A hash code value for this CIM element.
127 */
128 @Override
129 public int hashCode() {
130 return this.iName.hashCode();
131 }
132
133 /**
134 * Returns a <code>String</code> representation of the
135 * <code>CIMElement</code>. This method is intended to be used only for
136 * debugging purposes. The format of the returned string may vary between
137 * implementations. The returned string may be empty but may not be
138 * <code>null</code>
139 *
140 * @return <code>String</code> representation of this CIM element.
141 */
142 @Override
143 public String toString() {
144 return this.iName;
145 }
146 }