Top Description Fields Constructors Methods
org.kohsuke.args4j.spi

public final Class FieldSetter

extends Object
implements Getter, Setter
Class Inheritance
All Implemented Interfaces
org.kohsuke.args4j.spi.Setter, org.kohsuke.args4j.spi.Getter
Imports
java.lang.reflect.AnnotatedElement, .Field, java.util.Collections, .List

Setter that sets to a Field.
Author
Kohsuke Kawaguchi

Field Summary

Modifier and TypeField and Description
private final Object
private final Field
f

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addValue(Object value)

Implements org.kohsuke.args4j.spi.Setter.addValue.

Adds/sets a value to the property of the option bean.

public AnnotatedElement
asAnnotatedElement()

Implements org.kohsuke.args4j.spi.Setter.asAnnotatedElement.

Returns the AnnotatedElement by which you can access annotations written on this setter.

public FieldSetter
asFieldSetter()

Implements org.kohsuke.args4j.spi.Setter.asFieldSetter.

If this setter encapsulates a field, return the direct access to that field as FieldSetter.

private List<Object>
public Class<T>
getType()

Implements org.kohsuke.args4j.spi.Setter.getType.

Gets the type of the underlying method/field.

public Object
public List<Object>
getValueList()

Implements org.kohsuke.args4j.spi.Getter.getValueList.

Gets the current value of the property.

public boolean
isMultiValued()

Implements org.kohsuke.args4j.spi.Setter.isMultiValued.

Whether this setter is intrinsically multi-valued.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanback to summary
private final Object bean
fback to summary
private final Field f

Constructor Detail

FieldSetterback to summary
public FieldSetter(Object bean, Field f)

Method Detail

addValueback to summary
public void addValue(Object value)

Implements org.kohsuke.args4j.spi.Setter.addValue.

Doc from org.kohsuke.args4j.spi.Setter.addValue.

Adds/sets a value to the property of the option bean.

A Setter object has an implicit knowledge about the property it's setting, and the instance of the option bean.

asAnnotatedElementback to summary
public AnnotatedElement asAnnotatedElement()

Implements org.kohsuke.args4j.spi.Setter.asAnnotatedElement.

Doc from org.kohsuke.args4j.spi.Setter.asAnnotatedElement.

Returns the AnnotatedElement by which you can access annotations written on this setter. This is the same AnnotatedElement that had Option/Argument.

This enables OptionHandler to further tweak its behavior based on additional annotations.

asFieldSetterback to summary
public FieldSetter asFieldSetter()

Implements org.kohsuke.args4j.spi.Setter.asFieldSetter.

Doc from org.kohsuke.args4j.spi.Setter.asFieldSetter.

If this setter encapsulates a field, return the direct access to that field as FieldSetter. This method serves two purposes:

  1. This lets OptionHandlers bypass the collection/array handling of fields. This is useful if you're defining an option handler that produces array or collection from a single argument.
  2. The other is to retrieve the current value of the field (via FieldSetter#getValueList()).
Returns:FieldSetter

null if this setter wraps a method.

asListback to summary
private List<Object> asList(Object o)
getTypeback to summary
public Class<T> getType()

Implements org.kohsuke.args4j.spi.Setter.getType.

Doc from org.kohsuke.args4j.spi.Setter.getType.

Gets the type of the underlying method/field.

getValueback to summary
public Object getValue()
getValueListback to summary
public List<Object> getValueList()

Implements org.kohsuke.args4j.spi.Getter.getValueList.

Doc from org.kohsuke.args4j.spi.Getter.getValueList.

Gets the current value of the property.

A Getter object has an implicit knowledge about the property it's getting, and the instance of the option bean.

Returns:List<Object>

empty list or null if there's no current value.

isMultiValuedback to summary
public boolean isMultiValued()

Implements org.kohsuke.args4j.spi.Setter.isMultiValued.

Doc from org.kohsuke.args4j.spi.Setter.isMultiValued.

Whether this setter is intrinsically multi-valued.

When parsing arguments (instead of options), intrinsically multi-valued setters consume all the remaining arguments. So, if the setter can store multiple values, this method should return true.

This characteristics of a setter doesn't affect option parsing at all; any options can be specified multiple times. In many cases, this is a no-op--but when your shell script expands multiple environment variables (each of which may contain options), tolerating such redundant options can be useful.