Module watamebot

Interface IPropertyField<K,F,M extends IPropertyMapping>

Type Parameters:
K - Key type that points to a property
F - Lookup data type that coincides property lookup
M - Property mapping type that turns the raw property data into a usable type
All Known Implementing Classes:
GuildProperty

public interface IPropertyField<K,F,M extends IPropertyMapping>
An interface that provides generic methods used to retrieve and set properties from various data structures.
Author:
Ashley
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    get(F from)
    Get this property's data wrapped in an IPropertyMapping.
    default <U> U
    get(F from, Function<? super M,U> resolver)
    Get this property's value by applying the mapping into the resolver function.
    default <U> U
    get(F from, Supplier<U> fallback, Function<? super M,? extends U> resolver)
    Get this property's value by applying the mapping into the resolver function or returning the fallback suppliers value if the resolver's result is null.
    default <U> U
    get(F from, U fallback, Function<? super M,? extends U> resolver)
    Get this property's value by applying the mapping into the resolver function or returning the fallback value if the resolver's result is null.
    Get the key pointing to the property.
    boolean
    Check if this property is end user editable.
    boolean
    isPresent(F from)
    Check if this property is present.
    boolean
    set(F from, Object value)
    Update/Set this property's value.
    default boolean
    set(F from, Object value, boolean userEdited)
    Update/Set this property's value.
  • Method Details

    • get

      @CheckForNull M get(@Nonnull F from)
      Get this property's data wrapped in an IPropertyMapping.
      Parameters:
      from - - property lookup data
      Returns:
      The property's data inside an IPropertyMapping
    • get

      default <U> U get(@Nonnull F from, @Nonnull Supplier<U> fallback, @Nonnull Function<? super M,? extends U> resolver)
      Get this property's value by applying the mapping into the resolver function or returning the fallback suppliers value if the resolver's result is null.
      Type Parameters:
      U - - returned data type of the resolver
      Parameters:
      from - - property lookup data
      fallback - - supplier providing a fallback value
      resolver - - function to resolve the mapping into a usable data type
      Returns:
      Returns the property's value by applying it using the resolver function. If the result of the resolver function is null, the fallback supplier's value will be returned instead
    • get

      default <U> U get(@Nonnull F from, @Nullable U fallback, @Nonnull Function<? super M,? extends U> resolver)
      Get this property's value by applying the mapping into the resolver function or returning the fallback value if the resolver's result is null.
      Type Parameters:
      U - - returned data type of the resolver
      Parameters:
      from - - property lookup data
      fallback - - fallback value
      resolver - - function to resolve the mapping into a usable data type
      Returns:
      Returns the property's value by applying it using the resolver function. If the result of the resolver function is null, the fallback value will be returned instead
    • get

      default <U> U get(@Nonnull F from, @Nonnull Function<? super M,U> resolver)
      Get this property's value by applying the mapping into the resolver function.
      Type Parameters:
      U - - returned data type of the resolver
      Parameters:
      from - - property lookup data
      resolver - - function to resolve the mapping into a usable data type
      Returns:
      Returns the property's value by applying the mapping into the resolver function.
    • set

      boolean set(@Nonnull F from, @Nullable Object value)
      Update/Set this property's value.
      Parameters:
      from - - property lookup data
      value - - the new value
      Returns:
      Returns true if the property was updated successfully
      See Also:
    • set

      default boolean set(@Nonnull F from, @Nullable Object value, boolean userEdited)
      Update/Set this property's value.
      Parameters:
      from - - property lookup data
      value - - the new value
      userEdited - - was this change initiated by the end user
      Returns:
      Returns true if the property was updated successfully
      Throws:
      UnmodifiablePropertyException - Thrown if this property is not editable and userEdited is true
      See Also:
    • getKey

      @Nonnull K getKey()
      Get the key pointing to the property.
      Returns:
      The property's key
    • isPresent

      boolean isPresent(@Nonnull F from)
      Check if this property is present.
      Parameters:
      from - - lookup data
      Returns:
      Returns true if the property was found using the provided lookup data
    • isEditable

      boolean isEditable()
      Check if this property is end user editable.
      Returns:
      Returns true if this property is allowed to be modified by the end user