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 * 1737141 2007-06-18 ebak Sync up with JSR48 evolution
17 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
18 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
19 * 2750520 2009-04-10 blaschke-oss Code cleanup from empty statement et al
20 * 2763216 2009-04-14 blaschke-oss Code cleanup: visible spelling/grammar errors
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 * 3400209 2011-08-31 blaschke-oss Highlighted Static Analysis (PMD) issues
24 * 3565581 2012-09-07 blaschke-oss TCK: remove unnecessary overriding methods
25 */
26
27 package org.metricshub.wbem.javax.cim;
28
29 /*-
30 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
31 * WBEM Java Client
32 * ჻჻჻჻჻჻
33 * Copyright 2023 - 2025 MetricsHub
34 * ჻჻჻჻჻჻
35 * Licensed under the Apache License, Version 2.0 (the "License");
36 * you may not use this file except in compliance with the License.
37 * You may obtain a copy of the License at
38 *
39 * http://www.apache.org/licenses/LICENSE-2.0
40 *
41 * Unless required by applicable law or agreed to in writing, software
42 * distributed under the License is distributed on an "AS IS" BASIS,
43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44 * See the License for the specific language governing permissions and
45 * limitations under the License.
46 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
47 */
48
49 import org.metricshub.wbem.sblim.cimclient.internal.util.MOF;
50
51 //Sync'd against JSR48 1.0.0 javadoc (build 1.5.0_10) on Wed Jan 20 02:20:59 EST 2010
52 /**
53 * This class represents a CIM qualifier as defined by the Distributed
54 * Management Task Force (<a href=http://www.dmtf.org>DMTF</a>) CIM
55 * Infrastructure Specification (<a
56 * href=http://www.dmtf.org/standards/published_documents/DSP0004V2.3_final.pdf
57 * >DSP004</a>). A qualifier provides additional information about classes,
58 * associations, methods, parameters, properties, and/or references. A
59 * <code>CIMQualifier</code> must have a CIM Qualifier Type. A qualifier and its
60 * qualifier type must have the same name and data type. CIM Qualifiers can only
61 * be applied to elements that are allowed by the scope defined by the CIM
62 * Qualifier Type.
63 *
64 * @param <E>
65 * Type parameter.
66 * @see CIMQualifierType
67 */
68 public class CIMQualifier<E> extends CIMValuedElement<E> {
69 private static final long serialVersionUID = 3568987946093931214L;
70
71 private int iFlavor;
72
73 private boolean iPropagated;
74
75 /**
76 * Constructs a CIM qualifier with the specified name, type, value, and
77 * flavors.
78 *
79 * @param pName
80 * The name of the qualifier.
81 * @param pType
82 * The data type of the qualifier.
83 * @param pValue
84 * The value of the qualifier.
85 * @param pFlavor
86 * A list of override permissions. Flavors can be overridden from
87 * the Qualifier Type definition to either restrict the
88 * subclassing of a qualifier or to allow it. For the list of CIM
89 * Flavors see the <code>CIMFlavor</code> class.
90 * @see CIMFlavor
91 */
92 public CIMQualifier(String pName, CIMDataType pType, E pValue, int pFlavor) {
93 this(pName, pType, pValue, pFlavor, false);
94 }
95
96 /**
97 * Constructs a CIM qualifier with the specified name, type, value, and
98 * flavors.
99 *
100 * @param pName
101 * The name of the qualifier.
102 * @param pType
103 * The data type of the qualifier.
104 * @param pValue
105 * The value of the qualifier.
106 * @param pFlavor
107 * A list of override permissions. Flavors can be overridden from
108 * the Qualifier Type definition to either restrict the
109 * subclassing of a qualifier or to allow it. For the list of CIM
110 * Flavors see the <code>CIMFlavor</code> class.
111 * @param pIsPropagated
112 * <code>true</code> if the qualifier was propagated;
113 * <code>false</code> otherwise.
114 * @see CIMFlavor
115 */
116 public CIMQualifier(String pName, CIMDataType pType, E pValue, int pFlavor, boolean pIsPropagated) {
117 super(pName, pType, pValue);
118 this.iFlavor = pFlavor;
119 this.iPropagated = pIsPropagated;
120 }
121
122 /**
123 * Compares this <code>CIMQualifier</code> against the specified
124 * <code>CIMQualifier</code>. The result is <code>true</code> if and only if
125 * the argument is not <code>null</code> and is a <code>CIMQualifier</code>
126 * that represents the same name, type and value as this
127 * <code>CIMQualifier</code>.
128 *
129 * @param pObj
130 * The object to compare.
131 * @return <code>true</code> if the input qualifier is equal, otherwise
132 * <code>false</code>.
133 */
134 @Override
135 public boolean equals(Object pObj) {
136 if (!(pObj instanceof CIMQualifier)) return false;
137 if (!super.equals(pObj)) return false;
138 CIMQualifier<?> that = (CIMQualifier<?>) pObj;
139 return this.iFlavor == that.iFlavor && this.iPropagated == that.iPropagated;
140 }
141
142 /**
143 * Returns the CIM flavors for this CIM qualifier.
144 *
145 * @return A <code>BitSet</code> of CIM flavors in this CIM qualifier.
146 */
147 public int getFlavor() {
148 return this.iFlavor;
149 }
150
151 /**
152 * Determines if this qualifier is propagated. If the qualifier was
153 * inherited, this value will be <code>true</code>. If the qualifier was
154 * applied to the element directly, this value will be <code>false</code>.
155 *
156 * @return <code>true</code> if this property is propagated;
157 * <code>false</code> otherwise.
158 */
159 public boolean isPropagated() {
160 return this.iPropagated;
161 }
162
163 /**
164 * Returns a <code>String</code> representation of the
165 * <code>CIMQualifier</code>. This method is intended to be used only for
166 * debugging purposes, and the format of the returned string may vary
167 * between implementations. The returned string may be empty but may not be
168 * <code>null</code>.
169 *
170 * @return A string representation of this qualifier.
171 */
172 @Override
173 public String toString() {
174 return MOF.qualifier(this);
175 }
176 }