Class ArgTools
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ILocatorcreateLocator(Object optionValue, ILocator defaultValue, ILocatorFactory factory) static IArgsThe argument value atnameas anIArgsinstance.static booleanThe argument value atnameas a boolean.static byteThe argument value atnameas a byte.static charThe argument value atnameas a char.static char[]getCharArray(IArgs args, String name, char[] defaultValue) The argument value atnameas a char[].static ClassThe argument value atnameas aClass.static DateThe argument value atnameas aDate.static <T extends EnumItem>
TgetEnumItem(IArgs args, EnumMeta<T> meta, String name) The argument value atnameas aEnumItem.static <T extends EnumItem>
TgetEnumItem(IArgs args, EnumMeta<T> meta, String name, String defaultValue) The argument value atnameas aEnumItem.static FileThe argument value atnameas aFile.static floatThe argument value atnameas a float.static intThe argument value atnameas a int.static ILocatorgetLocator(IArgs args, String name, ILocator defaultValue, ILocatorFactory factory) The argument value atnameas aILocator.getLocators(IArgs args, String name, ILocatorFactory factory) The argument value atnameas a List. static MapThe argument value atnameas aMap.static ObjectThe argument value atnameas aObject.static Point2DThe argument value atnameas aPoint2D.static StringThe argument value atnameas aString.static StringCreate a new argument name fromnameby prefixing withprefix.static IArgsCast or convertvalueto anIArgs.static ListConvert theargsto aList.static MapConvert theargsto aMap.static StringCreate a printableStringforargs.protected static voidtoStringArgs(String prefix, StringBuilder sb, String name, IArgs value) protected static voidtoStringPlain(String prefix, StringBuilder sb, String name, Object value)
-
Field Details
-
toString
-
-
Constructor Details
-
ArgTools
public ArgTools()
-
-
Method Details
-
createLocator
protected static ILocator createLocator(Object optionValue, ILocator defaultValue, ILocatorFactory factory) -
getArgs
The argument value atnameas anIArgsinstance. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,IArgs,String,MapandList.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas anIArgsinstance.
-
getBool
The argument value atnameas a boolean. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Boolean,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aboolean
-
getByte
The argument value atnameas a byte. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Number,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas a byte.
-
getChar
The argument value atnameas a char. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Character,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas a char.
-
getCharArray
public static char[] getCharArray(IArgs args, String name, char[] defaultValue) throws IllegalArgumentException The argument value atnameas a char[]. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,String, char[]. Unlike the other conversion methods, this one throws an IllegalArgumentException, if the value is not of typeStringorchar[].- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aString. - Throws:
IllegalArgumentException- if value is not of typeStringorchar[]
-
getClass
The argument value atnameas aClass. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Boolean,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aClass.
-
getDate
The argument value atnameas aDate. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Date,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aDate.
-
getEnumItem
The argument value atnameas aEnumItem. If the argument value is not provided or not convertible, the enumeration default value is returned.This method performs the necessary casts and conversions. Supported input types are
null,EnumItem,String.- Parameters:
args-meta-name-- Returns:
- The argument value at
nameas aEnumItem.
-
getEnumItem
public static <T extends EnumItem> T getEnumItem(IArgs args, EnumMeta<T> meta, String name, String defaultValue) The argument value atnameas aEnumItem. If the argument value is not provided or not convertible, the enumeration item with the iddefaultValueeis returned.This method performs the necessary casts and conversions. Supported input types are
null,EnumItem,String.- Parameters:
args-meta-name-- Returns:
- The argument value at
nameas aEnumItem.
-
getFile
The argument value atnameas aFile. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,File,String,ILocator.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aDate.
-
getFloat
The argument value atnameas a float. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Number,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas a float.
-
getInt
The argument value atnameas a int. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Number,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas a int.
-
getLocator
public static ILocator getLocator(IArgs args, String name, ILocator defaultValue, ILocatorFactory factory) The argument value atnameas aILocator. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,ILocator,String,File- Parameters:
args-name-defaultValue-factory-- Returns:
- The argument value at
nameas aILocator.
-
getLocators
The argument value atnameas a List. If the argument value is not provided, nullis returned.This method performs the necessary casts and conversions. Supported input types are
CollectionofILocator,StringandFile.- Parameters:
args-name-factory-- Returns:
- The argument value at
nameas aList.
-
getMap
The argument value atnameas aMap. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Map,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aMap.
-
getObject
The argument value atnameas aObject. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Object.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aObject.
-
getPoint
The argument value atnameas aPoint2D. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,Point2D,String.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aPoint2D.
-
getString
The argument value atnameas aString. If the argument value is not provided or not convertible,defaultValueis returned.This method performs the necessary casts and conversions. Supported input types are
null,String,Object.- Parameters:
args-name-defaultValue-- Returns:
- The argument value at
nameas aString.
-
prefix
Create a new argument name fromnameby prefixing withprefix.- Parameters:
prefix-name-- Returns:
- The new argument name.
-
toArgs
Cast or convertvalueto anIArgs.- Parameters:
value-- Returns:
- The
IArgscreated fromvalue.
-
toList
Convert theargsto aList.- Parameters:
args-- Returns:
- The
Listrepresentation of theargs
-
toMap
Convert theargsto aMap.- Parameters:
args-- Returns:
- The
Maprepresentation of theargs
-
toString
Create a printableStringforargs.- Parameters:
args-prefix-- Returns:
-
toStringArgs
-
toStringPlain
-