equal
deleted
inserted
replaced
31 package javax.management.modelmbean; |
31 package javax.management.modelmbean; |
32 |
32 |
33 import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER; |
33 import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER; |
34 import static com.sun.jmx.mbeanserver.Util.cast; |
34 import static com.sun.jmx.mbeanserver.Util.cast; |
35 import com.sun.jmx.mbeanserver.GetPropertyAction; |
35 import com.sun.jmx.mbeanserver.GetPropertyAction; |
|
36 import com.sun.jmx.mbeanserver.Util; |
36 |
37 |
37 import java.io.IOException; |
38 import java.io.IOException; |
38 import java.io.ObjectInputStream; |
39 import java.io.ObjectInputStream; |
39 import java.io.ObjectOutputStream; |
40 import java.io.ObjectOutputStream; |
40 import java.io.ObjectStreamField; |
41 import java.io.ObjectStreamField; |
772 * @exception RuntimeOperationsException for illegal value for |
773 * @exception RuntimeOperationsException for illegal value for |
773 * field Names or field Values. If the descriptor construction |
774 * field Names or field Values. If the descriptor construction |
774 * fails for any reason, this exception will be thrown. |
775 * fails for any reason, this exception will be thrown. |
775 */ |
776 */ |
776 |
777 |
|
778 @Override |
777 public synchronized Object clone() throws RuntimeOperationsException { |
779 public synchronized Object clone() throws RuntimeOperationsException { |
778 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
780 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
779 MODELMBEAN_LOGGER.logp(Level.FINEST, |
781 MODELMBEAN_LOGGER.logp(Level.FINEST, |
780 DescriptorSupport.class.getName(), |
782 DescriptorSupport.class.getName(), |
781 "clone()", "Entry"); |
783 "clone()", "Entry"); |
812 * |
814 * |
813 * @return {@code true} if the objects are the same; {@code false} |
815 * @return {@code true} if the objects are the same; {@code false} |
814 * otherwise. |
816 * otherwise. |
815 * |
817 * |
816 */ |
818 */ |
817 // XXXX TODO: This is not very efficient! |
|
818 // Note: this Javadoc is copied from javax.management.Descriptor |
819 // Note: this Javadoc is copied from javax.management.Descriptor |
819 // due to 6369229. |
820 // due to 6369229. |
|
821 @Override |
820 public synchronized boolean equals(Object o) { |
822 public synchronized boolean equals(Object o) { |
821 if (o == this) |
823 if (o == this) |
822 return true; |
824 return true; |
823 |
825 if (! (o instanceof Descriptor)) |
|
826 return false; |
|
827 if (o instanceof ImmutableDescriptor) |
|
828 return o.equals(this); |
824 return new ImmutableDescriptor(descriptorMap).equals(o); |
829 return new ImmutableDescriptor(descriptorMap).equals(o); |
825 } |
830 } |
826 |
831 |
827 /** |
832 /** |
828 * <p>Returns the hash code value for this descriptor. The hash |
833 * <p>Returns the hash code value for this descriptor. The hash |
842 * </ul> |
847 * </ul> |
843 * |
848 * |
844 * @return A hash code value for this object. |
849 * @return A hash code value for this object. |
845 * |
850 * |
846 */ |
851 */ |
847 // XXXX TODO: This is not very efficient! |
|
848 // Note: this Javadoc is copied from javax.management.Descriptor |
852 // Note: this Javadoc is copied from javax.management.Descriptor |
849 // due to 6369229. |
853 // due to 6369229. |
|
854 @Override |
850 public synchronized int hashCode() { |
855 public synchronized int hashCode() { |
851 return new ImmutableDescriptor(descriptorMap).hashCode(); |
856 final int size = descriptorMap.size(); |
|
857 // descriptorMap is sorted with a comparator that ignores cases. |
|
858 // |
|
859 return Util.hashCode( |
|
860 descriptorMap.keySet().toArray(new String[size]), |
|
861 descriptorMap.values().toArray(new Object[size])); |
852 } |
862 } |
853 |
863 |
854 /** |
864 /** |
855 * Returns true if all of the fields have legal values given their |
865 * Returns true if all of the fields have legal values given their |
856 * names. |
866 * names. |
1276 * |
1286 * |
1277 * @exception RuntimeOperationsException for illegal value for |
1287 * @exception RuntimeOperationsException for illegal value for |
1278 * field Names or field Values. If the descriptor string fails |
1288 * field Names or field Values. If the descriptor string fails |
1279 * for any reason, this exception will be thrown. |
1289 * for any reason, this exception will be thrown. |
1280 */ |
1290 */ |
|
1291 @Override |
1281 public synchronized String toString() { |
1292 public synchronized String toString() { |
1282 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1293 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1283 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1294 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1284 DescriptorSupport.class.getName(), |
1295 DescriptorSupport.class.getName(), |
1285 "toString()", "Entry"); |
1296 "toString()", "Entry"); |