Class ConfigurationSerialization
java.lang.Object
me.confuser.banmanager.common.configuration.serialization.ConfigurationSerialization
Utility class for storing and retrieving classes for
Configuration.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(Map<String, ?> args) static ConfigurationSerializabledeserializeObject(Map<String, ?> args) Attempts to deserialize the given arguments into a new instance of the given class.static ConfigurationSerializabledeserializeObject(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) Attempts to deserialize the given arguments into a new instance of the given class.protected ConfigurationSerializabledeserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) protected ConfigurationSerializabledeserializeViaMethod(Method method, Map<String, ?> args) static StringgetAlias(Class<? extends ConfigurationSerializable> clazz) Gets the correct alias for the givenConfigurationSerializableclass.static Class<? extends ConfigurationSerializable> getClassByAlias(String alias) Attempts to get a registeredConfigurationSerializableclass by its alias.protected Constructor<? extends ConfigurationSerializable> protected Methodstatic voidregisterClass(Class<? extends ConfigurationSerializable> clazz) Registers the givenConfigurationSerializableclass by its alias.static voidregisterClass(Class<? extends ConfigurationSerializable> clazz, String alias) Registers the given alias to the specifiedConfigurationSerializableclass.static voidunregisterClass(Class<? extends ConfigurationSerializable> clazz) Unregisters any aliases for the specifiedConfigurationSerializableclass.static voidunregisterClass(String alias) Unregisters the specified alias to aConfigurationSerializable
-
Field Details
-
SERIALIZED_TYPE_KEY
- See Also:
-
-
Constructor Details
-
ConfigurationSerialization
-
-
Method Details
-
deserializeObject
public static ConfigurationSerializable deserializeObject(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) Attempts to deserialize the given arguments into a new instance of the given class.The class must implement
ConfigurationSerializable, including the extra methods as specified in the javadoc of ConfigurationSerializable.If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.
- Parameters:
args- Arguments for deserializationclazz- Class to deserialize into- Returns:
- New instance of the specified class
-
deserializeObject
Attempts to deserialize the given arguments into a new instance of the given class.The class must implement
ConfigurationSerializable, including the extra methods as specified in the javadoc of ConfigurationSerializable.If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.
- Parameters:
args- Arguments for deserialization- Returns:
- New instance of the specified class
-
registerClass
Registers the givenConfigurationSerializableclass by its alias.- Parameters:
clazz- Class to register
-
registerClass
Registers the given alias to the specifiedConfigurationSerializableclass.- Parameters:
clazz- Class to registeralias- Alias to register as- See Also:
-
unregisterClass
Unregisters the specified alias to aConfigurationSerializable- Parameters:
alias- Alias to unregister
-
unregisterClass
Unregisters any aliases for the specifiedConfigurationSerializableclass.- Parameters:
clazz- Class to unregister
-
getClassByAlias
Attempts to get a registeredConfigurationSerializableclass by its alias.- Parameters:
alias- Alias of the serializable- Returns:
- Registered class, or null if not found
-
getAlias
Gets the correct alias for the givenConfigurationSerializableclass.- Parameters:
clazz- Class to get alias for- Returns:
- Alias to use for the class
-
getMethod
-
getConstructor
-
deserializeViaMethod
-
deserializeViaCtor
protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) -
deserialize
-