FileDocCategorySizeDatePackage
OpenMBeanConstructorInfoSupport.javaAPI DocJava SE 5 API7851Fri Aug 26 14:57:36 BST 2005javax.management.openmbean

OpenMBeanConstructorInfoSupport

public class OpenMBeanConstructorInfoSupport extends MBeanConstructorInfo implements OpenMBeanConstructorInfo, Serializable
Describes a constructor of an Open MBean.
version
3.22 03/12/19
author
Sun Microsystems, Inc.
since
1.5
since.unbundled
JMX 1.1

Fields Summary
static final long
serialVersionUID
private transient Integer
myHashCode
private transient String
myToString
Constructors Summary
public OpenMBeanConstructorInfoSupport(String name, String description, OpenMBeanParameterInfo[] signature)
Constructs an OpenMBeanConstructorInfoSupport instance, which describes the constructor of a class of open MBeans with the specified name, description and signature.

The signature array parameter is internally copied, so that subsequent changes to the array referenced by signature have no effect on this instance.

param
name cannot be a null or empty string.
param
description cannot be a null or empty string.
param
signature can be null or empty if there are no parameters to describe.
throws
IllegalArgumentException if name or description are null or empty string.
throws
ArrayStoreException If signature is not an array of instances of a subclass of MBeanParameterInfo.

	// need only be calculated once.

                                                                                                                       
       
					     
					     

	super(name, 
	      description, 
	      ( signature == null ?  null : arrayCopyCast(signature) )); // may throw an ArrayStoreException

	// check parameters that should not be null or empty (unfortunately it is not done in superclass :-( ! )
	//
	if ( (name == null) || (name.trim().equals("")) ) {
	    throw new IllegalArgumentException("Argument name cannot be null or empty.");
	}
	if ( (description == null) || (description.trim().equals("")) ) {
	    throw new IllegalArgumentException("Argument description cannot be null or empty.");
	}

    
Methods Summary
private static javax.management.MBeanParameterInfo[]arrayCopyCast(javax.management.openmbean.OpenMBeanParameterInfo[] src)


	MBeanParameterInfo[] dst = new MBeanParameterInfo[src.length];
	System.arraycopy(src, 0, dst, 0, src.length); // may throw an ArrayStoreException
	return dst;
    
public booleanequals(java.lang.Object obj)
Compares the specified obj parameter with this OpenMBeanConstructorInfoSupport instance for equality.

Returns true if and only if all of the following statements are true:

  • obj is non null,
  • obj also implements the OpenMBeanConstructorInfo interface,
  • their names are equal
  • their signatures are equal.
This ensures that this equals method works properly for obj parameters which are different implementations of the OpenMBeanConstructorInfo interface.
 

param
obj the object to be compared for equality with this OpenMBeanConstructorInfoSupport instance;
return
true if the specified object is equal to this OpenMBeanConstructorInfoSupport instance.

 

	// if obj is null, return false
	//
	if (obj == null) {
	    return false;
	}

	// if obj is not a OpenMBeanConstructorInfo, return false
	//
	OpenMBeanConstructorInfo other;
	try {
	    other = (OpenMBeanConstructorInfo) obj;
	} catch (ClassCastException e) {
	    return false;
	}

	// Now, really test for equality between this OpenMBeanConstructorInfo implementation and the other:
	//
	
	// their Name should be equal
	if ( ! this.getName().equals(other.getName()) ) {
	    return false;
	}

	// their Signatures should be equal
	if ( ! Arrays.equals(this.getSignature(), other.getSignature()) ) {
	    return false;
	}
       
	// All tests for equality were successfull
	//
	return true;
    
public inthashCode()
Returns the hash code value for this OpenMBeanConstructorInfoSupport instance.

The hash code of an OpenMBeanConstructorInfoSupport instance is the sum of the hash codes of all elements of information used in equals comparisons (ie: its name and signature, where the signature hashCode is calculated by a call to java.util.Arrays.asList(this.getSignature).hashCode()).

This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two OpenMBeanConstructorInfoSupport instances t1 and t2, as required by the general contract of the method {@link Object#hashCode() Object.hashCode()}.

However, note that another instance of a class implementing the OpenMBeanConstructorInfo interface may be equal to this OpenMBeanConstructorInfoSupport instance as defined by {@link #equals(java.lang.Object)}, but may have a different hash code if it is calculated differently.

As OpenMBeanConstructorInfoSupport instances are immutable, the hash code for this instance is calculated once, on the first call to hashCode, and then the same value is returned for subsequent calls.

return
the hash code value for this OpenMBeanConstructorInfoSupport instance


	// Calculate the hash code value if it has not yet been done (ie 1st call to hashCode())
	//
	if (myHashCode == null) {
	    int value = 0;
	    value += this.getName().hashCode();
	    value += Arrays.asList(this.getSignature()).hashCode();
	    myHashCode = new Integer(value);
	}
	
	// return always the same hash code for this instance (immutable)
	//
	return myHashCode.intValue();
    
public java.lang.StringtoString()
Returns a string representation of this OpenMBeanConstructorInfoSupport instance.

The string representation consists of the name of this class (ie javax.management.openmbean.OpenMBeanConstructorInfoSupport), and of the name and signature of the described constructor.

As OpenMBeanConstructorInfoSupport instances are immutable, the string representation for this instance is calculated once, on the first call to toString, and then the same value is returned for subsequent calls.

return
a string representation of this OpenMBeanConstructorInfoSupport instance

 

	// Calculate the hash code value if it has not yet been done (ie 1st call to toString())
	//
	if (myToString == null) {
	    myToString = new StringBuffer()
		.append(this.getClass().getName())
		.append("(name=")
		.append(this.getName())
		.append(",signature=")
		.append(Arrays.asList(this.getSignature()).toString())
		.append(")")
		.toString();
	}

	// return always the same string representation for this instance (immutable)
	//
	return myToString;