1 /*
2 (C) Copyright IBM Corp. 2006, 2012
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 : Endre Bak, ebak@de.ibm.com
12 *
13 * Flag Date Prog Description
14 * -------------------------------------------------------------------------------
15 * 1565892 2006-10-06 ebak Make SBLIM client JSR48 compliant
16 * 1660756 2007-02-22 ebak Embedded object support
17 * 1737141 2007-06-19 ebak Sync up with JSR48 evolution
18 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
19 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
20 * 2750520 2009-04-10 blaschke-oss Code cleanup from empty statement et al
21 * 2797550 2009-06-01 raman_arora JSR48 compliance - add Java Generics
22 * 2935258 2010-01-22 blaschke-oss Sync up javax.cim.* javadoc with JSR48 1.0.0
23 * 2944842 2010-02-08 blaschke-oss Missing thrown ArrayIndexOutOfBoundsException
24 * 3400209 2011-08-31 blaschke-oss Highlighted Static Analysis (PMD) issues
25 * 3565581 2012-09-07 blaschke-oss TCK: remove unnecessary overriding methods
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 org.metricshub.wbem.sblim.cimclient.internal.cim.CIMQualifiedElementInterfaceImpl;
51 import org.metricshub.wbem.sblim.cimclient.internal.util.MOF;
52
53 //Sync'd against JSR48 1.0.0 javadoc (build 1.5.0_10) on Wed Jan 20 02:20:59 EST 2010
54 /**
55 * This class represents a CIM Parameter. A CIM Parameter is a schema item, thus
56 * it can only be part of a <code>CIMMethod</code> definition for a
57 * <code>CIMClass</code>. A parameter can be used to define an input, output or
58 * input/output parameter. A <code>CIMParameter</code> consists of a name, data
59 * type and qualifiers. <code>CIMParameters</code> do not have values - so you
60 * can not set a default value. CIM Parameters are defined by the Distributed
61 * Management Task Force (<a href=http://www.dmtf.org>DMTF</a>) CIM
62 * Infrastructure Specification (<a
63 * href=http://www.dmtf.org/standards/published_documents/DSP0004V2.3_final.pdf
64 * >DSP004</a>). To invoke a method, you would use <code>CIMArgument</code>.
65 *
66 * @param <E>
67 * Type parameter.
68 *
69 * @see CIMMethod
70 */
71 public class CIMParameter<E> extends CIMTypedElement implements CIMQualifiedElementInterface {
72 private static final long serialVersionUID = -4741931597423829396L;
73
74 private CIMQualifiedElementInterfaceImpl iQualiImpl;
75
76 /**
77 * Constructs a <code>CIMParameter</code> object using the specified name,
78 * data type and qualifiers. Takes a string for the name of an existing CIM
79 * parameter and creates a new instance of a CIM parameter, using the name
80 * and identifier of the existing CIM parameter.
81 *
82 * @param pName
83 * Name of this parameter.
84 * @param pType
85 * Data type of this parameter.
86 * @param pQualifiers
87 * Qualifiers for this parameter.
88 */
89 public CIMParameter(String pName, CIMDataType pType, CIMQualifier<?>[] pQualifiers) {
90 super(pName, pType);
91 this.iQualiImpl = new CIMQualifiedElementInterfaceImpl(pQualifiers, false, true);
92 }
93
94 /**
95 * Compares this object against the specified object. The result is
96 * <code>true</code> if and only if the argument is not <code>null</code>
97 * and is a <code>CIMParameter</code> object that represents the same value
98 * as this object.
99 *
100 * @param pObj
101 * The object to compare.
102 * @return <code>true</code> if the objects are the same; <code>false</code>
103 * otherwise.
104 */
105 @Override
106 public boolean equals(Object pObj) {
107 if (!(pObj instanceof CIMParameter)) return false;
108 if (!super.equals(pObj)) return false;
109 CIMParameter<?> that = (CIMParameter<?>) pObj;
110 return this.iQualiImpl.equals(that.iQualiImpl);
111 }
112
113 /**
114 * Returns a <code>CIMParameter</code> filtered as specified.
115 *
116 * @param pIncludeQualifiers
117 * If <code>true</code> all qualifiers are returned; otherwise no
118 * qualifiers.
119 * @param pLocalOnly
120 * If <code>true</code> only the qualifiers that were not
121 * propagated will be included.
122 * @return A filtered <code>CIMParameter</code>.
123 */
124 public CIMParameter<E> filter(boolean pIncludeQualifiers, boolean pLocalOnly) {
125 return new CIMParameter<E>(
126 getName(),
127 getDataType(),
128 pIncludeQualifiers ? this.iQualiImpl.getQualifiers(pLocalOnly) : null
129 );
130 }
131
132 /**
133 * Get a qualifier by index.
134 *
135 * @param pIndex
136 * The index of the qualifier.
137 * @return The Qualifier at index pIndex.
138 * @throws ArrayIndexOutOfBoundsException
139 */
140 public CIMQualifier<?> getQualifier(int pIndex) throws ArrayIndexOutOfBoundsException {
141 return this.iQualiImpl.getQualifier(pIndex);
142 }
143
144 /**
145 * Gets a qualifier by name.
146 *
147 * @param pName
148 * The name of the qualifier to get.
149 * @return <code>null</code> if the qualifier does not exist, otherwise
150 * returns the reference to the qualifier.
151 */
152 public CIMQualifier<?> getQualifier(String pName) {
153 return this.iQualiImpl.getQualifier(pName);
154 }
155
156 /**
157 * Get the number of qualifiers defined for this CIM Parameter.
158 *
159 * @return The number of qualifiers.
160 */
161 public int getQualifierCount() {
162 return this.iQualiImpl.getQualifierCount();
163 }
164
165 /**
166 * Returns the list of qualifiers for this class.
167 *
168 * @return Qualifiers for this class.
169 */
170 public CIMQualifier<?>[] getQualifiers() {
171 return this.iQualiImpl.getQualifiers();
172 }
173
174 /**
175 * Gets a qualifier value by name.
176 *
177 * @param pName
178 * The name of the qualifier to get.
179 * @return <code>null</code> if the qualifier does not exist or value is
180 * <code>null</code>, otherwise returns the reference to the
181 * qualifier.
182 */
183 public Object getQualifierValue(String pName) {
184 return this.iQualiImpl.getQualifierValue(pName);
185 }
186
187 /**
188 * Checks whether the specified qualifier is one of the qualifiers in this
189 * CIM element.
190 *
191 * @param pName
192 * The name of the qualifier.
193 * @return <code>true</code> if the qualifier exists in this CIM parameter,
194 * otherwise <code>false</code>.
195 */
196 public boolean hasQualifier(String pName) {
197 return this.iQualiImpl.hasQualifier(pName);
198 }
199
200 /**
201 * Checks whether the specified qualifier is one of the qualifiers defined
202 * for this parameter with the specified value. This method will return
203 * <code>false</code> if the qualifier is not applied or if the value does
204 * not match.
205 *
206 * @param pName
207 * The name of the qualifier.
208 * @param pValue
209 * The value to be tested.
210 * @return <code>true</code> if the qualifier exists in this property,
211 * otherwise <code>false</code>.
212 */
213 public boolean hasQualifierValue(String pName, Object pValue) {
214 return this.iQualiImpl.hasQualifierValue(pName, pValue);
215 }
216
217 /**
218 * Returns a <code>String</code> representation of the
219 * <code>CIMParameter</code>. This method is intended to be used only for
220 * debugging purposes, and the format of the returned string may vary
221 * between implementations. The returned string may be empty but may not be
222 * <code>null</code>.
223 *
224 * @return String representation of this parameter.
225 */
226 @Override
227 public String toString() {
228 return MOF.parameter(this, MOF.EMPTY);
229 }
230 }