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 * 3496301 2012-03-02 blaschke-oss Sync up javax.* javadoc with JSR48 1.0.0 Final 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 //Sync'd against JSR48 1.0.0 javadoc (build 1.6.0_18) on Thu Mar 01 12:21:26 EST 2012 51 /** 52 * This class represents a CIM Property as defined by the Distributed Management 53 * Task Force (<a href=http://www.dmtf.org>DMTF</a>) CIM Infrastructure 54 * Specification (<a 55 * href=http://www.dmtf.org/standards/published_documents/DSP0004V2.3_final.pdf 56 * >DSP004</a>). A CIM Property Object consists of a name, data type and value. 57 * The CIM Property object also includes a flag to signify whether the property 58 * is a key property (used as part of the name of the CIM element), a flag to 59 * signify whether it was propagated from a parent class and the class origin 60 * information (where the property was originally defined). 61 * 62 * @param <E> 63 * Type parameter. 64 */ 65 public class CIMProperty<E> extends CIMValuedElement<E> { 66 private static final long serialVersionUID = -4741931597423829396L; 67 68 private boolean iKey, iPropagated; 69 70 private String iOriginClass; 71 72 /** 73 * Constructs a <code>CIMProperty</code> to be used in instances. For a 74 * <code>CIMClass</code>, <code>CIMClassProperty</code> shall be used. This 75 * can only be used for non-Key properties, non-propagated properties and 76 * when the the origin class is not needed. 77 * 78 * @param pName 79 * The name of the property. 80 * @param pType 81 * The <code>CIMDataType</code> of the property. 82 * @param pValue 83 * The value of the property. 84 */ 85 public CIMProperty(String pName, CIMDataType pType, E pValue) { 86 this(pName, pType, pValue, false, false, null); 87 } 88 89 /** 90 * Constructs a <code>CIMProperty</code> to be used in instances. For a 91 * <code>CIMClass</code>, <code>CIMClassProperty</code> shall be used. 92 * 93 * @param pName 94 * The name of the property. 95 * @param pType 96 * The <code>CIMDataType</code> of the property. 97 * @param pValue 98 * The value of the property. 99 * @param pKey 100 * <code>true</code> if the property is a key; otherwise 101 * <code>false</code>. 102 * @param pPropagated 103 * <code>true</code> if the value was propagated from the class. 104 * @param pOriginClass 105 * The class in which this property was defined or overridden. 106 */ 107 public CIMProperty( 108 String pName, 109 CIMDataType pType, 110 E pValue, 111 boolean pKey, 112 boolean pPropagated, 113 String pOriginClass 114 ) { 115 super(pName, pType, pValue); 116 this.iKey = pKey; 117 this.iPropagated = pPropagated; 118 this.iOriginClass = pOriginClass; 119 } 120 121 /** 122 * Compares this object against the specified object. The result is 123 * <code>true</code> if and only if the argument is not <code>null</code> 124 * and is a <code>CIMProperty</code> that represents the same name, type and 125 * value as this object. 126 * 127 * @param pObj 128 * The object to compare with. 129 * @return <code>true</code> if the objects are the same; <code>false</code> 130 * otherwise. 131 */ 132 @Override 133 public boolean equals(Object pObj) { 134 if (!(pObj instanceof CIMProperty)) return false; 135 if (!super.equals(pObj)) return false; 136 CIMProperty<?> that = (CIMProperty<?>) pObj; 137 return ( 138 this.iKey == that.iKey && 139 this.iPropagated == that.iPropagated && 140 (this.iOriginClass == null ? that.iOriginClass == null : this.iOriginClass.equalsIgnoreCase(that.iOriginClass)) 141 ); 142 } 143 144 /** 145 * Returns the class in which this property was defined or overridden. 146 * 147 * @return Name of class where this property was defined. 148 */ 149 public String getOriginClass() { 150 return this.iOriginClass; 151 } 152 153 /** 154 * Convenience method for determining if this property is a Key. 155 * 156 * @return <code>true</code> if this property is a key. 157 */ 158 public boolean isKey() { 159 return this.iKey; 160 } 161 162 /** 163 * Determines if this property is Propagated. When this property is part of 164 * a class, this value designates that the class origin value is the same as 165 * the class name. 166 * 167 * @return <code>true</code> if this property is propagated. 168 */ 169 public boolean isPropagated() { 170 return this.iPropagated; 171 } 172 }