Class CustomOptions
java.lang.Object
com.mrivanplays.annotationconfig.core.resolver.options.CustomOptions
Represents a class, containing options for reading or writing a file. This can contain literally
any information you want or need.
- Since:
- 2.0.0
- Author:
- MrIvanPlays
-
Method Summary
Modifier and TypeMethodDescriptionstatic CustomOptions
empty()
Creates a new emptyCustomOptions
instance.<T> Optional<T>
Returns the heldOption
, assigned to the specified key, as the specified type.<T> T
boolean
Returns whether this custom options instance has anOption
, assigned to the specified key.isReplaceable
(String key) Returns whether theOption
, contained or not, in this custom options instance, assigned to the specified key, can be replaced.static CustomOptions
Creates a newCustomOptions
instance with the specified data.<T> void
Assigns the specifiedOption
to the specified key.
-
Method Details
-
of
Creates a newCustomOptions
instance with the specified data.- Parameters:
customData
- the data you want these options constructed with- Returns:
- populated mutable custom options instance
-
empty
Creates a new emptyCustomOptions
instance.- Returns:
- empty mutable custom options instance
-
has
Returns whether this custom options instance has anOption
, assigned to the specified key.- Parameters:
key
- the key of the option you want to check if exists- Returns:
- boolean value
-
isReplaceable
Returns whether theOption
, contained or not, in this custom options instance, assigned to the specified key, can be replaced. If there is an option assigned to the specified key, this will return a populatedOptional
, otherwise empty optional.- Parameters:
key
- the key of the option you want to check if it can be replaced- Returns:
- optional with a value, or empty optional
-
getAs
Returns the heldOption
, assigned to the specified key, as the specified type. If there is no option assigned to this key, this will return an emptyOptional
, otherwise a value if the option's value can be assigned to the specified type. If the option's value cannot be assigned to the specified type, this method will throw anIllegalArgumentException
- Type Parameters:
T
- type- Parameters:
key
- the key of the option you want to gettype
- the type you want it converted to- Returns:
- filled optional or empty optional (check header)
- Throws:
IllegalArgumentException
- if the value is not assignable to the specified type
-
getAsOr
- Type Parameters:
T
- type- Parameters:
key
- the key of the option you want to gettype
- the type you want it converted todef
- a default value- Returns:
- always a usable value
- See Also:
-
put
Assigns the specifiedOption
to the specified key.- Type Parameters:
T
- type- Parameters:
key
- the key you want the specified option to be assigned tovalue
- the option you want assigned to the specified key
-