Module watamebot

Interface ImmutableProperty<L,M extends PropertyMapping>

All Known Subinterfaces:
ImmutableLCKProperty, ImmutablePluginProperty, LCKProperty, PluginProperty, Property<L,M>

public interface ImmutableProperty<L,M extends PropertyMapping>
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Optional<M>
    get(L lookup)
    Get the current value of this property.
    default <U> U
    get(L lookup, @NotNull Function<? super M,U> mapper)
    Get the current value of this property and map it with the specified mapper.
    default <U> U
    get(L lookup, @Nullable Supplier<U> defaultValue, @NotNull Function<? super M,U> mapper)
    Get the current value of this property and map it with the specified mapper.
    @NotNull PropertyInfo
    Get the definition of this property
    default @NotNull Optional<M>
    getOr(L lookup, @NotNull ImmutableProperty<L,M> fallback)
    Get the current value of this property if present.
    boolean
    isPresent(L lookup)
    Check if this property is populated in the configuration.
  • Method Details

    • get

      @NotNull @NotNull Optional<M> get(@NotNull L lookup)
      Get the current value of this property.
      Parameters:
      lookup - - property lookup
      Returns:
      Returns an Optional PropertyMapping containing the raw data retrieved
    • getOr

      @NotNull default @NotNull Optional<M> getOr(@NotNull L lookup, @NotNull @NotNull ImmutableProperty<L,M> fallback)
      Get the current value of this property if present. Otherwise get the current value of the specified fallback.
      Parameters:
      lookup - - property lookup
      fallback - - fallback property
      Returns:
      Returns a Optional PropertyMapping containing the raw data retrieved
    • get

      @Nullable default <U> U get(@NotNull L lookup, @NotNull @NotNull Function<? super M,U> mapper)
      Get the current value of this property and map it with the specified mapper.

      This method is effectively equivalent to:

       get(lookup, null, mapper)
       
      Type Parameters:
      U - Return type
      Parameters:
      lookup - - property lookup
      mapper - - function to convert the raw data into a usable type
      Returns:
      Returns the mapped data or null if this property is empty
    • get

      @Nullable default <U> U get(@NotNull L lookup, @Nullable @Nullable Supplier<U> defaultValue, @NotNull @NotNull Function<? super M,U> mapper)
      Get the current value of this property and map it with the specified mapper. If the property is empty, the defaultValue will be returned instead.

      This method is effectively equivalent to:

       get(lookup).map(mapper).orElseGet(defaultValue != null ? defaultValue : () -> null);
       
      Type Parameters:
      U - Return type
      Parameters:
      lookup - - property lookup
      defaultValue - - default value supplier
      mapper - - function to convert the raw data into a usable type
      Returns:
      Returns the mapped data or defaultValue if this property is empty
    • isPresent

      boolean isPresent(@NotNull L lookup)
      Check if this property is populated in the configuration.
      Parameters:
      lookup - - property lookup
      Returns:
      Returns true if the lookup with this PropertyInfo was found inside the configuration (empty or not)
    • getInfo

      @NotNull @NotNull PropertyInfo getInfo()
      Get the definition of this property
      Returns:
      Returns the PropertyInfo linked to this property