PreferencesKeys

Added in 1.0.0

public final class PreferencesKeys


Summary

Public methods

static final @NonNull Preferences.Key<@NonNull Boolean>

Get a key for a Boolean preference.

static final @NonNull Preferences.Key<@NonNull byte[]>

Get a key for an ByteArray preference.

static final @NonNull Preferences.Key<@NonNull Double>

Get a key for a Double preference.

static final @NonNull Preferences.Key<@NonNull Float>

Get a key for a Float preference.

static final @NonNull Preferences.Key<@NonNull Integer>

Get a key for an Int preference.

static final @NonNull Preferences.Key<@NonNull Long>

Get a key for an Long preference.

static final @NonNull Preferences.Key<@NonNull String>

Get a key for a String preference.

static final @NonNull Preferences.Key<@NonNull Set<@NonNull String>>

Get a key for a String Set preference.

Public methods

public static final @NonNull Preferences.Key<@NonNull BooleanbooleanKey(@NonNull String name)

Get a key for a Boolean preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Boolean>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull byte[]> byteArrayKey(@NonNull String name)

Get a key for an ByteArray preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Note: ByteArrays returned by DataStore are copies. Mutating their state will do nothing to the underlying data store. They must be set explicitly.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull byte[]>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull DoubledoubleKey(@NonNull String name)

Get a key for a Double preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Double>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull FloatfloatKey(@NonNull String name)

Get a key for a Float preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Float>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull IntegerintKey(@NonNull String name)

Get a key for an Int preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Integer>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull LonglongKey(@NonNull String name)

Get a key for an Long preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Long>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull StringstringKey(@NonNull String name)

Get a key for a String preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull String>

the Preferences.Key for name

public static final @NonNull Preferences.Key<@NonNull Set<@NonNull String>> stringSetKey(@NonNull String name)

Get a key for a String Set preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Note: sets returned by DataStore are unmodifiable and will throw exceptions if mutated.

Parameters
@NonNull String name

the name of the preference

Returns
@NonNull Preferences.Key<@NonNull Set<@NonNull String>>

the Preferences.Key> for name