Package com.jbstrap.core
Class Parameters
java.lang.Object
com.jbstrap.core.Parameters
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
GaugeChartSection
Class for storing parameters and transporting them
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the specified parameterclear()Delete all previously specified values from the parameter object.copy()Creates a perfect copy of the objectstatic Parametersdeserialize(String source) booleanDetermines if the specified object is equal with the Parameters object.<T> TGets the value of the specified parametergetAsBoolean(String name) Gets the specified parameter's value as a Boolean valuefinal DateGets the specified parameter's value as a Date.final DateGets the specified parameter's value as a Date, in the specified formatfinal DoublegetAsDouble(String name) Gets the specified parameter's value as a Doublefinal IntegergetAsInteger(String name) Gets the specified parameter's value as an Integerfinal LongGets the specified parameter's value as a Longfinal NumbergetAsNumber(String name) Gets the specified parameter's value as a Numberfinal StringgetAsString(String name) Gets the specified parameter's value as a stringgetNames()Gets a list of every parameter name, that are stored in the object.booleanisEmpty()Determines if the object is empty.merge(Parameters... sources) Merges the object with the specified parametersRemoves the specified parametertoString()Returns a string representation of the object.
-
Constructor Details
-
Parameters
public Parameters()
-
-
Method Details
-
add
Adds the specified parameter- Parameters:
name- The name of the parameter to be added. If the specified name already exists, it will be overwrittenvalue- The parameter value- Returns:
- The object containing the parameter
- Throws:
NullPointerException- If the parameter name was specified asnull
-
remove
Removes the specified parameter- Parameters:
name- The name of the parameter to be removed- Returns:
- The object containing the parameters
- Throws:
NullPointerException- If the name was specified asnull
-
get
Gets the value of the specified parameter- Type Parameters:
T- The parameter value's type- Parameters:
name- The parameter name- Returns:
- The parameter value or
null, if the parameter was not found - Throws:
NullPointerException- If the parameter name was specified asnull
-
getAsString
Gets the specified parameter's value as a string- Parameters:
name- The parameter name- Returns:
- The parameter value as a String or
nullif the parameter was not found - Throws:
NullPointerException- If the parameter name was specified asnull
-
getAsDate
Gets the specified parameter's value as a Date. If the parameter isn't a Date, it will be interpreted in the "yyyy-MM-dd HH:mm:ss" date format if possible- Parameters:
name- The parameter name- Returns:
- The parameter value as a Date or
nullif the parameter was not found or couldn't be interpreted as a date - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsDate
Gets the specified parameter's value as a Date, in the specified format- Parameters:
name- The parameter nameformat- The date format to be used. If specified asnull, the format will be "yyyy-MM-dd HH:mm:ss"- Returns:
- The parameter value as a date or
null, if the specified parameter was not found, or couldn't be interpreted as a date - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsNumber
Gets the specified parameter's value as a Number- Parameters:
name- The parameter name- Returns:
- The parameter value as a Number or
null, if the specified parameter was not found, or couldn't be interpreted as a Number - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsLong
Gets the specified parameter's value as a Long- Parameters:
name- The parameter name- Returns:
- The parameter value as a Long or
null, if the specified parameter was not found, or couldn't be interpreted as a Long - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsDouble
Gets the specified parameter's value as a Double- Parameters:
name- The parameter name- Returns:
- The parameter value as a Double or
null, if the specified parameter was not found, or couldn't be interpreted as a Double - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsInteger
Gets the specified parameter's value as an Integer- Parameters:
name- The parameter name- Returns:
- The parameter value as an Integer or
null, if the specified parameter was not found, or couldn't be interpreted as a Double - Throws:
NullPointerException- If the parameter name was specified asnullParseException- If the beginning of the specified string cannot be parsed.
-
getAsBoolean
Gets the specified parameter's value as a Boolean value- Parameters:
name- The parameter name- Returns:
- The parameter value as a Boolean value or
null, if the specified parameter was not found, or couldn't be interpreted as a Boolean value - Throws:
NullPointerException- If the parameter name was specified asnull
-
getNames
Gets a list of every parameter name, that are stored in the object.- Returns:
- A list of every parameter name, that are stored in the object. If the object is empty (ie, doesn't contain any parameters), it will return with an empty list
-
copy
Creates a perfect copy of the object- Returns:
- The new object, that is a perfect copy the original
-
merge
Merges the object with the specified parameters- Parameters:
sources- The objects containing the parameters that will be merged. The merging will be done in the order the parameters were specified. If one of the specified objects contains a parameter, that has a name that is already present in the Parameters class, the older one will be overwritten by the new, specified one.- Returns:
- The object containing the parameters
-
isEmpty
public boolean isEmpty()Determines if the object is empty. It's considered empty, if it was created, but has no parameters- Returns:
true,if the object has no parameters. Otherwisefalse
-
clear
Delete all previously specified values from the parameter object.- Returns:
- The object containing the parameter
-
equals
Determines if the specified object is equal with the Parameters object.
The two objects are considered equal if:
- The specified object is not
null - The specified object is a Parameters class, or a descendant of one
- The cardinality of the two are the same
- Every specified parameter is the same as the ones in the Parameters class
- The specified object is not
-
toString
Returns a string representation of the object. -
serialize
- Throws:
IOException
-
deserialize
- Throws:
IOExceptionClassNotFoundException
-