public final class ParameterType extends HandleObject implements Comparable
Provides information about the type of a command parameter. Clients can use a
parameter type to check if an object matches the type of the parameter with
isCompatible(Object)
and can get an
AbstractParameterValueConverter
to convert between objects matching
the parameter type and strings that encode the object's identity.
A command parameter is not required to declare a type. To determine if a
given parameter has a type, check if an IParameter
implements
ITypedParameter
and if so, use
ITypedParameter.getParameterType()
like this:
IParameter parameter = // ... get IParameter from Command if (parameter instanceof ITypedParameter) { ParameterType type = ((ITypedParameter)parameter).getParameterType(); if (type != null) { // this parameter has a ParameterType } }
IParameter
,
ITypedParameter.getParameterType()
defined, id, string
Modifier and Type | Method and Description |
---|---|
void |
addListener(IParameterTypeListener listener)
Adds a listener to this parameter type that will be notified when its
state changes.
|
int |
compareTo(Object object)
Compares this parameter type with another object by comparing each of the
non-transient attributes.
|
void |
define(String type,
AbstractParameterValueConverter parameterTypeConverter)
Defines this parameter type, setting the defined property to
true . |
AbstractParameterValueConverter |
getValueConverter()
Returns the value converter associated with this parameter, if any.
|
boolean |
isCompatible(Object value)
Returns whether the provided value is compatible with this parameter
type.
|
void |
removeListener(IParameterTypeListener listener)
Unregisters listener for changes to properties of this parameter type.
|
String |
toString()
The string representation of this parameter type.
|
void |
undefine()
Makes this parameter type become undefined.
|
equals, getId, hashCode, isDefined
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public final void addListener(IParameterTypeListener listener)
listener
- The listener to be added; must not be null
.public final int compareTo(Object object)
compareTo
in interface Comparable
object
- The object with which to compare; must be an instance of
ParameterType
.public final void define(String type, AbstractParameterValueConverter parameterTypeConverter)
Defines this parameter type, setting the defined property to
true
.
Notification is sent to all listeners that something has changed.
type
- a string identifying the Java object type for this parameter
type; null
is interpreted as
"java.lang.Object"
parameterTypeConverter
- an AbstractParameterValueConverter
to perform
string/object conversions for parameter values; may be
null
public final AbstractParameterValueConverter getValueConverter() throws NotDefinedException
null
if there is
no value converter for this parameter.NotDefinedException
- if the parameter type is not currently definedpublic boolean isCompatible(Object value) throws NotDefinedException
value
- an object to check for compatibility with this parameter type;
may be null
.true
if the value is compatible with this type,
false
otherwiseNotDefinedException
- if the parameter type is not currently definedpublic final void removeListener(IParameterTypeListener listener)
listener
- the instance to unregister. Must not be null
.
If an attempt is made to unregister an instance which is not
already registered with this instance, no operation is
performed.public final String toString()
toString
in class HandleObject
null
.public final void undefine()
undefine
in class HandleObject
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.