javax.management.Impact Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsr255 Show documentation
Show all versions of jsr255 Show documentation
JSR 255 - Java™ Management Extensions (JMX™) API Specification 2.0 EARLY DRAFT REVIEW (December 2007)
The newest version!
/*-
* $Id: c12687779ae1c75f51053d8b6072ab1808df3037 $
*/
package javax.management;
/**
*Defines the impact of an MBean operation, in particular whether it
* has an effect on the MBean or simply returns information. This enum
* is used in the {@link ManagedOperation @ManagedOperation} annotation.
* Its {@link #getCode()} method can be used to get an int
suitable
* for use as the impact
parameter in an {@link MBeanOperationInfo}
* constructor.
*/
public enum Impact {
/**
* The operation is read-like: it returns information but does not change any state.
*
* @see MBeanOperationInfo#INFO
*/
INFO(MBeanOperationInfo.INFO),
/**
* The operation is write-like: it has an effect but does not return any information from the MBean.
*
* @see MBeanOperationInfo#ACTION
*/
ACTION(MBeanOperationInfo.ACTION),
/**
* The operation is both read-like and write-like: it has an effect, and it also returns information from the MBean.
*
* @see MBeanOperationInfo#ACTION_INFO
*/
ACTION_INFO(MBeanOperationInfo.ACTION_INFO),
/**
* The impact of the operation is unknown or cannot be expressed using one of the other values.
*
* @see MBeanOperationInfo#UNKNOWN
*/
UNKNOWN(MBeanOperationInfo.UNKNOWN),
;
private final int code;
Impact(final int code) {
assert code == this.ordinal();
this.code = code;
}
/**
* The equivalent int
code used by the {@link MBeanOperationInfo} constructors.
*
* @return the int
code.
*/
public int getCode() {
return this.code;
}
/**
* Return the Impact
value corresponding to the given int
* code. The code
is the value that would be used in an
* MBeanOperationInfo
constructor.
*
* @param code the int
code.
* @return an Impact
value x
such that
* code == x.
{@link #getCode()}, or Impact.UNKNOWN
* if there is no such value.
*/
public static Impact forCode(final int code) {
switch (code) {
case MBeanOperationInfo.INFO:
return INFO;
case MBeanOperationInfo.ACTION:
return ACTION;
case MBeanOperationInfo.ACTION_INFO:
return ACTION_INFO;
case MBeanOperationInfo.UNKNOWN:
default:
return UNKNOWN;
}
}
}