public final class UserStyle implements Map


An immutable representation of user style choices that maps each UserStyleSetting to UserStyleSetting.Option.

This is intended for use by the WatchFace and entries are the same as the ones specified in the UserStyleSchema. This means you can't serialize a UserStyle directly, instead you need to use a UserStyleData (see toUserStyleData).

To modify the user style, you should call toMutableUserStyle and construct a new UserStyle instance with MutableUserStyle.toUserStyle.

Summary

Public constructors

Constructs a UserStyle with the given selected options for each setting.

Constructs a copy of the UserStyle.

UserStyle(
    @NonNull UserStyleData userStyle,
    @NonNull UserStyleSchema styleSchema
)

Constructs a UserStyle from a UserStyleData and the UserStyleSchema.

Public methods

boolean
boolean
boolean
equals(Object other)
UserStyleSetting.Option

Returns the UserStyleSetting.Option for key if there is one or null otherwise.

final UserStyleSetting.Option

Returns the UserStyleSetting.Option for settingId if there is one or null otherwise.

@NonNull Set<@NonNull Map.Entry<@NonNull UserStyleSetting, @NonNull UserStyleSetting.Option>>
@NonNull Set<@NonNull UserStyleSetting>
int

The number of entries in the style.

@NonNull Collection<@NonNull UserStyleSetting.Option>
int
boolean
final @NonNull MutableUserStyle

Returns a mutable instance initialized with the same mapping.

@NonNull String
final @NonNull UserStyleData

Returns the style as a UserStyleData.

Public constructors

UserStyle

public UserStyle(
    @NonNull Map<@NonNull UserStyleSetting, @NonNull UserStyleSetting.Option> selectedOptions
)

Constructs a UserStyle with the given selected options for each setting.

A copy of the selectedOptions map will be created, so that changed to the map will not be reflected by this object.

UserStyle

Added in 1.0.0
public UserStyle(@NonNull UserStyle userStyle)

Constructs a copy of the UserStyle. It is backed by the same map.

UserStyle

Added in 1.0.0
public UserStyle(
    @NonNull UserStyleData userStyle,
    @NonNull UserStyleSchema styleSchema
)

Constructs a UserStyle from a UserStyleData and the UserStyleSchema. Unrecognized style settings will be ignored. Unlisted style settings will be initialized with that setting's default option.

Parameters
@NonNull UserStyleData userStyle

The UserStyle represented as a UserStyleData.

@NonNull UserStyleSchema styleSchema

The UserStyleSchema for this UserStyle, describes how we interpret userStyle.

Public methods

containsKey

Added in 1.0.0
public boolean containsKey(@NonNull UserStyleSetting key)

containsValue

Added in 1.0.0
public boolean containsValue(@NonNull UserStyleSetting.Option value)

equals

public boolean equals(Object other)

get

Added in 1.0.0
public UserStyleSetting.Option get(@NonNull UserStyleSetting key)

Returns the UserStyleSetting.Option for key if there is one or null otherwise.

get

Added in 1.0.0
public final UserStyleSetting.Option get(@NonNull UserStyleSetting.Id settingId)

Returns the UserStyleSetting.Option for settingId if there is one or null otherwise. Note this is an O(n) operation.

getKeys

Added in 1.0.0
public @NonNull Set<@NonNull UserStyleSettinggetKeys()

getSize

Added in 1.0.0
public int getSize()

The number of entries in the style.

hashCode

public int hashCode()

isEmpty

Added in 1.0.0
public boolean isEmpty()

toMutableUserStyle

Added in 1.0.0
public final @NonNull MutableUserStyle toMutableUserStyle()

Returns a mutable instance initialized with the same mapping.

toString

public @NonNull String toString()

toUserStyleData

Added in 1.0.0
public final @NonNull UserStyleData toUserStyleData()

Returns the style as a UserStyleData.