Class ArgTools
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ILocator
createLocator
(Object optionValue, ILocator defaultValue, ILocatorFactory factory) static IArgs
The argument value atname
as anIArgs
instance.static boolean
The argument value atname
as a boolean.static byte
The argument value atname
as a byte.static char
The argument value atname
as a char.static char[]
getCharArray
(IArgs args, String name, char[] defaultValue) The argument value atname
as a char[].static Class
The argument value atname
as aClass
.static Date
The argument value atname
as aDate
.static <T extends EnumItem>
TgetEnumItem
(IArgs args, EnumMeta<T> meta, String name) The argument value atname
as aEnumItem
.static <T extends EnumItem>
TgetEnumItem
(IArgs args, EnumMeta<T> meta, String name, String defaultValue) The argument value atname
as aEnumItem
.static File
The argument value atname
as aFile
.static float
The argument value atname
as a float.static int
The argument value atname
as a int.static ILocator
getLocator
(IArgs args, String name, ILocator defaultValue, ILocatorFactory factory) The argument value atname
as aILocator
.getLocators
(IArgs args, String name, ILocatorFactory factory) The argument value atname
as a List. static Map
The argument value atname
as aMap
.static Object
The argument value atname
as aObject
.static Point2D
The argument value atname
as aPoint2D
.static String
The argument value atname
as aString
.static String
Create a new argument name fromname
by prefixing withprefix
.static IArgs
Cast or convertvalue
to anIArgs
.static List
Convert theargs
to aList
.static Map
Convert theargs
to aMap
.static String
Create a printableString
forargs
.protected static void
toStringArgs
(String prefix, StringBuilder sb, String name, IArgs value) protected static void
toStringPlain
(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 atname
as anIArgs
instance. If the argument value is not provided or not convertible,defaultValue
is returned.This method performs the necessary casts and conversions. Supported input types are
null
,IArgs
,String
,Map
andList
.- Parameters:
args
-name
-defaultValue
-- Returns:
- The argument value at
name
as anIArgs
instance.
-
getBool
The argument value atname
as a boolean. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aboolean
-
getByte
The argument value atname
as a byte. If the argument value is not provided or not convertible,defaultValue
is 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
name
as a byte.
-
getChar
The argument value atname
as a char. If the argument value is not provided or not convertible,defaultValue
is 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
name
as a char.
-
getCharArray
public static char[] getCharArray(IArgs args, String name, char[] defaultValue) throws IllegalArgumentException The argument value atname
as a char[]. If the argument value is not provided or not convertible,defaultValue
is 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 typeString
orchar[]
.- Parameters:
args
-name
-defaultValue
-- Returns:
- The argument value at
name
as aString
. - Throws:
IllegalArgumentException
- if value is not of typeString
orchar[]
-
getClass
The argument value atname
as aClass
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aClass
.
-
getDate
The argument value atname
as aDate
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aDate
.
-
getEnumItem
The argument value atname
as 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
name
as aEnumItem
.
-
getEnumItem
public static <T extends EnumItem> T getEnumItem(IArgs args, EnumMeta<T> meta, String name, String defaultValue) The argument value atname
as aEnumItem
. If the argument value is not provided or not convertible, the enumeration item with the iddefaultValuee
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
name
as aEnumItem
.
-
getFile
The argument value atname
as aFile
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aDate
.
-
getFloat
The argument value atname
as a float. If the argument value is not provided or not convertible,defaultValue
is 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
name
as a float.
-
getInt
The argument value atname
as a int. If the argument value is not provided or not convertible,defaultValue
is 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
name
as a int.
-
getLocator
public static ILocator getLocator(IArgs args, String name, ILocator defaultValue, ILocatorFactory factory) The argument value atname
as aILocator
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aILocator
.
-
getLocators
The argument value atname
as a List. If the argument value is not provided, null
is returned.This method performs the necessary casts and conversions. Supported input types are
Collection
ofILocator
,String
andFile
.- Parameters:
args
-name
-factory
-- Returns:
- The argument value at
name
as aList
.
-
getMap
The argument value atname
as aMap
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aMap
.
-
getObject
The argument value atname
as aObject
. If the argument value is not provided or not convertible,defaultValue
is returned.This method performs the necessary casts and conversions. Supported input types are
null
,Object
.- Parameters:
args
-name
-defaultValue
-- Returns:
- The argument value at
name
as aObject
.
-
getPoint
The argument value atname
as aPoint2D
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aPoint2D
.
-
getString
The argument value atname
as aString
. If the argument value is not provided or not convertible,defaultValue
is 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
name
as aString
.
-
prefix
Create a new argument name fromname
by prefixing withprefix
.- Parameters:
prefix
-name
-- Returns:
- The new argument name.
-
toArgs
Cast or convertvalue
to anIArgs
.- Parameters:
value
-- Returns:
- The
IArgs
created fromvalue
.
-
toList
Convert theargs
to aList
.- Parameters:
args
-- Returns:
- The
List
representation of theargs
-
toMap
Convert theargs
to aMap
.- Parameters:
args
-- Returns:
- The
Map
representation of theargs
-
toString
Create a printableString
forargs
.- Parameters:
args
-prefix
-- Returns:
-
toStringArgs
-
toStringPlain
-