Top Description Fields Constructors Methods
com.dlsc.preferencesfx.util

public Class StorageHandlerImpl

extends PreferencesBasedStorageHandler
Class Inheritance
Imports
com.google.gson.Gson, .JsonElement, com.google.gson.reflect.TypeToken, java.util.Collections, .List, java.util.stream.Collectors

Handles everything related to serializing and de-serializing values.
Authors
François Martin, Marco Sanfratello

Field Summary

Modifier and TypeField and Description
private final Gson

Constructor Summary

AccessConstructor and Description
public
StorageHandlerImpl(Class<?> saveClass)

Method Summary

Modifier and TypeMethod and Description
protected <T> T
deserialize(String
the string to deserialze
serialized
,
Class<T>
the class into which to deserialize the string
type
)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserialize.

Deserializes an object from a string for storage.

protected <T> List<T>
deserializeList(String
the string to deserialze
serialized
,
Class<T>
the class into which to deserialize the string
type
)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserializeList.

Deserializes a list of objects from a string for storage.

protected String
serialize(Object
the object to serialize
object
)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.serialize.

Serializes an object to a string for storage.

Inherited from com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler:
clearPreferencesgetPreferenceshashloadDividerPositionloadObjectloadObjectloadObservableListloadObservableListloadSelectedCategoryloadWindowHeightloadWindowPosXloadWindowPosYloadWindowWidthsaveDividerPositionsaveObjectsaveSelectedCategorysaveWindowHeightsaveWindowPosXsaveWindowPosYsaveWindowWidth

Field Detail

gsonback to summary
private final Gson gson

Constructor Detail

StorageHandlerImplback to summary
public StorageHandlerImpl(Class<?> saveClass)

Method Detail

deserializeback to summary
protected <T> T deserialize(String serialized, Class<T> type)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserialize.

Doc from com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserialize.

Deserializes an object from a string for storage.

Subclasses may use any way to deserialize the object. This should be the inverse operation of serialize(Object).

Therefore the following must hold true for any x of type X:

  Objects.equals(x, deserialize(serialize(x), X.class)
Parameters
<T>
the type of object into which to deserialze the string
serialized:String

the string to deserialze

type:Class<T>

the class into which to deserialize the string

Returns:T

the deserialized object

Annotations
@Override
deserializeListback to summary
protected <T> List<T> deserializeList(String serialized, Class<T> type)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserializeList.

Doc from com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.deserializeList.

Deserializes a list of objects from a string for storage.

Subclasses may use any way to deserialize the list. This should be the inverse operation of serialize(Object).

Therefore the following must hold true for any x of type List<X>:

  Objects.equals(x, deserializeList(serialize(x), X.class)
Parameters
<T>
the type of objects in the list
serialized:String

the string to deserialze

type:Class<T>

the class into which to deserialize the string

Returns:List<T>

deserialized list

Annotations
@Override
serializeback to summary
protected String serialize(Object object)

Implements abstract com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.serialize.

Doc from com.dlsc.preferencesfx.util.PreferencesBasedStorageHandler.serialize.

Serializes an object to a string for storage.

Subclasses may use any way to serialize the object. This should be the inverse operation of deserialize(String, Class).

Therefore the following must hold true for any x of type X:

  Objects.equals(x, deserialize(serialize(x), X.class)
Parameters
object:Object

the object to serialize

Returns:String

string representation of the object for storage

Annotations
@Override