-
- All Implemented Interfaces:
public final class PreferencesBuilderBuilder of the Preferences instance provided by
Preferences(sharedPreferences) { ... }factory function.
-
-
Field Summary
Fields Modifier and Type Field Description private SharedPreferencessharedPreferencesprivate DoubleRepresentationdoubleRepresentationprivate BooleanencodeObjectStartsprivate BooleanencodeStringSetNativelyprivate BooleansynchronizeEncodingprivate final List<String>stringSetDescriptorNamesprivate SerializersModuleserializersModule
-
Method Summary
Modifier and Type Method Description final SharedPreferencesgetSharedPreferences()Specifies the SharedPreferences where everything will be encoded to and decoded from. final UnitsetSharedPreferences(SharedPreferences sharedPreferences)Specifies the SharedPreferences where everything will be encoded to and decoded from. final DoubleRepresentationgetDoubleRepresentation()Specifies how Double fields will be encoded. final UnitsetDoubleRepresentation(DoubleRepresentation doubleRepresentation)Specifies how Double fields will be encoded. final BooleangetEncodeObjectStarts()Specifies whether objects, empty classes and empty collections will be serialized by encoding a marker at the position. final UnitsetEncodeObjectStarts(Boolean encodeObjectStarts)Specifies whether objects, empty classes and empty collections will be serialized by encoding a marker at the position. final BooleangetEncodeStringSetNatively()Specifies whether Sets of String, Char and Enum will be encoded with putStringSet or not. final UnitsetEncodeStringSetNatively(Boolean encodeStringSetNatively)Specifies whether Sets of String, Char and Enum will be encoded with putStringSet or not. final BooleangetSynchronizeEncoding()Specifies the usage of synchronize blocks over PreferencesBuilder.sharedPreferences while serialization. final UnitsetSynchronizeEncoding(Boolean synchronizeEncoding)Specifies the usage of synchronize blocks over PreferencesBuilder.sharedPreferences while serialization. final List<String>getStringSetDescriptorNames()Specifies the names of the SerialDescriptor which are used to detect Set<String> to encode these natively. final SerializersModulegetSerializersModule()Module with contextual and polymorphic serializers to be used in the resulting Preferences instance. final UnitsetSerializersModule(SerializersModule serializersModule)Module with contextual and polymorphic serializers to be used in the resulting Preferences instance. -
-
Method Detail
-
getSharedPreferences
final SharedPreferences getSharedPreferences()
Specifies the SharedPreferences where everything will be encoded to and decoded from.
-
setSharedPreferences
final Unit setSharedPreferences(SharedPreferences sharedPreferences)
Specifies the SharedPreferences where everything will be encoded to and decoded from.
-
getDoubleRepresentation
final DoubleRepresentation getDoubleRepresentation()
Specifies how Double fields will be encoded. DoubleRepresentation.LONG_BITS by default
-
setDoubleRepresentation
final Unit setDoubleRepresentation(DoubleRepresentation doubleRepresentation)
Specifies how Double fields will be encoded. DoubleRepresentation.LONG_BITS by default
-
getEncodeObjectStarts
final Boolean getEncodeObjectStarts()
Specifies whether objects, empty classes and empty collections will be serialized by encoding a marker at the position.
@Serializable data class PrefTest(val u: Unit) val pref = Preferences(sharedPreferences) { encodeObjectStarts = true } pref.encode(PrefTest.serializer(), "test", PrefTest(Unit)) assertTrue(sharedPreferences.getBoolean("test.u", false))trueby default
-
setEncodeObjectStarts
final Unit setEncodeObjectStarts(Boolean encodeObjectStarts)
Specifies whether objects, empty classes and empty collections will be serialized by encoding a marker at the position.
@Serializable data class PrefTest(val u: Unit) val pref = Preferences(sharedPreferences) { encodeObjectStarts = true } pref.encode(PrefTest.serializer(), "test", PrefTest(Unit)) assertTrue(sharedPreferences.getBoolean("test.u", false))trueby default
-
getEncodeStringSetNatively
final Boolean getEncodeStringSetNatively()
Specifies whether Sets of String, Char and Enum will be encoded with putStringSet or not.
trueby default
-
setEncodeStringSetNatively
final Unit setEncodeStringSetNatively(Boolean encodeStringSetNatively)
Specifies whether Sets of String, Char and Enum will be encoded with putStringSet or not.
trueby default
-
getSynchronizeEncoding
final Boolean getSynchronizeEncoding()
Specifies the usage of synchronize blocks over PreferencesBuilder.sharedPreferences while serialization.
falseby default
-
setSynchronizeEncoding
final Unit setSynchronizeEncoding(Boolean synchronizeEncoding)
Specifies the usage of synchronize blocks over PreferencesBuilder.sharedPreferences while serialization.
falseby default
-
getStringSetDescriptorNames
final List<String> getStringSetDescriptorNames()
Specifies the names of the SerialDescriptor which are used to detect Set<String> to encode these natively.
trueby default
-
getSerializersModule
final SerializersModule getSerializersModule()
Module with contextual and polymorphic serializers to be used in the resulting Preferences instance.
-
setSerializersModule
final Unit setSerializersModule(SerializersModule serializersModule)
Module with contextual and polymorphic serializers to be used in the resulting Preferences instance.
-
-
-
-