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

OpenMBeanOperationInfoSupport

public class OpenMBeanOperationInfoSupport extends MBeanOperationInfo implements Serializable, OpenMBeanOperationInfo
Describes an operation of an Open MBean.
version
3.25 03/12/19
author
Sun Microsystems, Inc.
since
1.5
since.unbundled
JMX 1.1

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

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.
param
returnOpenType cannot be null: use SimpleType.VOID for operations that return nothing.
param
impact can be only one of ACTION, ACTION_INFO or INFO.
throws
IllegalArgumentException if name or description are null or empty string, or returnOpenType is null, or impact is not one of ACTION, ACTION_INFO or INFO.
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
	      ( returnOpenType == null ?  null : returnOpenType.getClassName() ),
	      impact);

	// 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.");
	}
	if (returnOpenType == null) {
	    throw new IllegalArgumentException("Argument returnOpenType cannot be null.");
	}

	// check impact's value is only one of the 3 allowed (UNKNOWN not allowed)
	//
	if ( (impact != super.ACTION) && (impact != super.ACTION_INFO) && (impact != super.INFO) ) {
	    throw new IllegalArgumentException("Argument impact can be only one of ACTION, ACTION_INFO or INFO.");
	}

	this.returnOpenType = returnOpenType;
    
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 OpenMBeanOperationInfoSupport instance for equality.

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

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

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

 

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

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

	// Now, really test for equality between this OpenMBeanOperationInfo 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;
	}
       
	// their return open types should be equal
	if ( ! this.getReturnOpenType().equals(other.getReturnOpenType()) ) {
	    return false;
	}

	// their impacts should be equal
	if ( this.getImpact() != other.getImpact() ) {
	    return false;
	}

	// All tests for equality were successfull
	//
	return true;
    
public javax.management.openmbean.OpenTypegetReturnOpenType()
Returns the open type of the values returned by the operation described by this OpenMBeanOperationInfo instance.

 

	return returnOpenType;
    
public inthashCode()
Returns the hash code value for this OpenMBeanOperationInfoSupport instance.

The hash code of an OpenMBeanOperationInfoSupport instance is the sum of the hash codes of all elements of information used in equals comparisons (ie: its name, return open type, impact 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 OpenMBeanOperationInfoSupport 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 OpenMBeanOperationInfo interface may be equal to this OpenMBeanOperationInfoSupport instance as defined by {@link #equals(java.lang.Object)}, but may have a different hash code if it is calculated differently.

As OpenMBeanOperationInfoSupport 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 OpenMBeanOperationInfoSupport 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();
	    value += this.getReturnOpenType().hashCode();
	    value += this.getImpact();
	    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 OpenMBeanOperationInfoSupport instance.

The string representation consists of the name of this class (ie javax.management.openmbean.OpenMBeanOperationInfoSupport), and the name, signature, return open type and impact of the described operation.

As OpenMBeanOperationInfoSupport 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 OpenMBeanOperationInfoSupport 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(",return=")
		.append(this.getReturnOpenType().toString())
		.append(",impact=")
		.append(this.getImpact())
		.append(")")
		.toString();
	}

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