Interface ModuleItem<T>
-
- All Superinterfaces:
BasicDetails,Named
- All Known Subinterfaces:
MutableModuleItem<T>
- All Known Implementing Classes:
AbstractModuleItem,CommandModuleItem,DefaultMutableModuleItem
public interface ModuleItem<T> extends BasicDetails
A ModuleItem represents metadata about one input or output of a module.- Author:
- Aivar Grislis, Curtis Rueden
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidcallback(Module module)Invokes this item's callback function, if any, on the given module.StringgetCallback()Gets the function that is called whenever this item changes.List<T>getChoices()Gets the list of possible values.intgetColumnCount()Gets the preferred width of the input field in characters (if applicable).TgetDefaultValue()Gets the default value.TypegetGenericType()Gets the type of the item, including Java generic parameters.ModuleInfogetInfo()Gets theModuleInfoto which this item belongs.StringgetInitializer()Gets the function that is called to initialize the item's value.ItemIOgetIOType()Gets the input/output type of the item.TgetMaximumValue()Gets the maximum allowed value (if applicable).TgetMinimumValue()Gets the minimum allowed value (if applicable).StringgetPersistKey()Gets the key to use for saving the value persistently.TgetSoftMaximum()Gets the "soft" maximum value (if applicable).TgetSoftMinimum()Gets the "soft" minimum value (if applicable).NumbergetStepSize()Gets the preferred step size to use when rendering the item in a user interface (if applicable).Class<T>getType()Gets the type of the item.StringgetValidater()Gets the function that is called to validate the item's value.TgetValue(Module module)Gets the item's current value with respect to the given module.ItemVisibilitygetVisibility()Gets the visibility of the item.StringgetWidgetStyle()Gets the preferred widget style to use when rendering the item in a user interface.voidinitialize(Module module)Invokes this item's initializer function, if any, on the given module.booleanisAutoFill()Gets whether the item value is allowed to be auto-filled.booleanisInput()Gets whether the item is a module input.booleanisOutput()Gets whether the item is a module output.booleanisPersisted()Gets whether to remember the most recent value of the parameter.booleanisRequired()Gets whether the item value must be specified (i.e., no default).TloadValue()Deprecated.voidsaveValue(T value)Deprecated.voidsetValue(Module module, T value)Sets the item's current value with respect to the given module.voidvalidate(Module module)Invokes this item's validation function, if any, on the given module.default StringvalidateMessage(Module module)Validates this item's value in the given module, returning any error message rather than throwing.-
Methods inherited from interface org.scijava.BasicDetails
get, getDescription, getLabel, is, set, setDescription, setLabel
-
-
-
-
Method Detail
-
getInfo
ModuleInfo getInfo()
Gets theModuleInfoto which this item belongs.
-
getGenericType
Type getGenericType()
Gets the type of the item, including Java generic parameters.For many modules, this may be the same
Classobject returned bygetType(), but some module inputs or outputs may be backed by a generic type such asList<String>orIterable<Integer>.- See Also:
Field.getGenericType()
-
getIOType
ItemIO getIOType()
Gets the input/output type of the item.
-
isInput
boolean isInput()
Gets whether the item is a module input.
-
isOutput
boolean isOutput()
Gets whether the item is a module output.
-
getVisibility
ItemVisibility getVisibility()
Gets the visibility of the item.
-
isAutoFill
boolean isAutoFill()
Gets whether the item value is allowed to be auto-filled.
-
isRequired
boolean isRequired()
Gets whether the item value must be specified (i.e., no default).
-
isPersisted
boolean isPersisted()
Gets whether to remember the most recent value of the parameter.
-
getPersistKey
String getPersistKey()
Gets the key to use for saving the value persistently.
-
loadValue
@Deprecated T loadValue()
Deprecated.Loads the item's persisted value. This recalls the value last stored usingsaveValue(Object).Note that this is different than obtaining a module instance's current value for the input; see
getValue(Module)for that.- See Also:
ModuleService.load(ModuleItem)
-
saveValue
@Deprecated void saveValue(T value)
Deprecated.Saves the given value to persistent storage. This allows later restoration of the value vialoadValue(), even from a different JVM.- See Also:
ModuleService.save(ModuleItem, Object)
-
getInitializer
String getInitializer()
Gets the function that is called to initialize the item's value.
-
initialize
void initialize(Module module) throws MethodCallException
Invokes this item's initializer function, if any, on the given module.- Throws:
MethodCallException- See Also:
getInitializer()
-
getValidater
String getValidater()
Gets the function that is called to validate the item's value.
-
validate
void validate(Module module) throws MethodCallException
Invokes this item's validation function, if any, on the given module.The validation function may signal failure either by throwing an exception or by returning a non-empty
Stringerror message.- Throws:
MethodCallException- if validation fails or the method cannot be invoked. When the validater returns a non-empty String, aMethodCallExceptionis thrown with that string as its message.- See Also:
getValidater(),validateMessage(Module)
-
validateMessage
default String validateMessage(Module module)
Validates this item's value in the given module, returning any error message rather than throwing.The validation function may signal failure either by throwing an exception or by returning a non-empty
Stringerror message. This method catches both cases and returns the error message as a string, ornullif the value is valid.- Returns:
- an error message if the value is invalid, or
nullif valid. - See Also:
getValidater(),validate(Module)
-
getCallback
String getCallback()
Gets the function that is called whenever this item changes.This mechanism enables interdependent items of various types. For example, two int parameters "width" and "height" could update each other when another boolean "Preserve aspect ratio" flag is set.
-
callback
void callback(Module module) throws MethodCallException
Invokes this item's callback function, if any, on the given module.- Throws:
MethodCallException- See Also:
getCallback()
-
getWidgetStyle
String getWidgetStyle()
Gets the preferred widget style to use when rendering the item in a user interface.
-
getDefaultValue
T getDefaultValue()
Gets the default value.
-
getMinimumValue
T getMinimumValue()
Gets the minimum allowed value (if applicable).
-
getMaximumValue
T getMaximumValue()
Gets the maximum allowed value (if applicable).
-
getSoftMinimum
T getSoftMinimum()
Gets the "soft" minimum value (if applicable).The soft minimum is a hint for use in bounded scenarios, such as rendering in a user interface with a slider or scroll bar widget; the parameter value will not actually be clamped to the soft bounds, but they may be used in certain circumstances where appropriate.
-
getSoftMaximum
T getSoftMaximum()
Gets the "soft" maximum value (if applicable).The soft maximum is a hint for use in bounded scenarios, such as rendering in a user interface with a slider or scroll bar widget; the parameter value will not actually be clamped to the soft bounds, but they may be used in certain circumstances where appropriate.
-
getStepSize
Number getStepSize()
Gets the preferred step size to use when rendering the item in a user interface (if applicable).
-
getColumnCount
int getColumnCount()
Gets the preferred width of the input field in characters (if applicable).
-
-