org.wildfly.swarm.spi.api

## Class Defaultable<T>

- java.lang.Object
- - org.wildfly.swarm.spi.api.Defaultable<T>

- All Implemented Interfaces:
    Supplier<T>

      public class Defaultable<T>
      extends Object
      implements Supplier<T>

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Defaultable<Boolean>` | `bool(boolean defaultValue)`
    `static Defaultable<Boolean>` | `bool(Supplier<Boolean> defaultValueSupplier)`
    `T` | `defaultValue()` Retrieve the default value, if any.
    `Optional<T>` | `explicit()` Retrieve a standard `Optional` containing the explicit value, if any.
    `T` | `explicitOrElseGet(Supplier<? extends T> other)` Retrieve the explicit value if present, otherwise return the value supplied by the `Supplier` parameter.
    `T` | `explicitValue()` Retrieve the explicitly set value, if any.
    `static Defaultable<Float>` | `floating(float defaultValue)`
    `static Defaultable<Float>` | `floating(Supplier<Float> defaultValueSupplier)`
    `T` | `get()` Retrieve the value, regardless of it's origin.
    `T` | `get(Supplier<? extends T> preferred)` Retrieve the explicit value if present, followed in precedence by whatever value, if not-null supplied by the `preferred` parameter, followed by the default if all previous options were null.
    `static Defaultable<Boolean>` | `ifAllExplicitlySet(Defaultable<?>... items)` Create a `Boolean` configuration that has a default value of `true` if all arguments have been explicitly set to non-default values.
    `static Defaultable<Boolean>` | `ifAnyExplicitlySet(Defaultable<?>... items)` Create a `Boolean` configuration that has a default value of `true` if any arguments have been explicitly set to non-default values.
    `void` | `ifDefault(Consumer<? super T> consumer)` If (and only if) only a default value is present (without an explicit value), invoke the supplied consumer with it.
    `void` | `ifExplicit(Consumer<? super T> consumer)` If (and only if) an explicit value is present, invoke the supplied consumer with it
    `void` | `ifPresent(Consumer<? super T> consumer)` If a default or explicit value is present, invoke the supplied consumer with it.
    `static Defaultable<Integer>` | `integer(int defaultValue)`
    `static Defaultable<Integer>` | `integer(Supplier<Integer> defaultValueSupplier)`
    `boolean` | `isDefault()` Determine if the value that would be provided (even if null) is the default value or not.
    `boolean` | `isExplicit()` Determine if the value that would be provided is explicitly set or not.
    `boolean` | `isExplicitPresent(Supplier<T> other)` Determine if either an explicit value is set of the supplied `other` `Supplier` parameter returns non-null.
    `boolean` | `isPresent()` Determine if any value (default or explicit) is present.
    `static Defaultable<Long>` | `longInteger(long defaultValue)`
    `static Defaultable<Long>` | `longInteger(Supplier<Long> defaultValueSupplier)`
    `T` | `orElse(T defaultValue)` Retrieve the value (default or explicit) if present, otherwise the provided value parameter.
    `T` | `orElseGet(Supplier<? extends T> other)` Retrieve the value (default or explicit) if present, otherwise return the value supplied by the `Supplier` parameter.
    `void` | `set(T explicitValue)` Explicitly set a value.
    `static Defaultable<String>` | `string(String defaultValue)`
    `static Defaultable<String>` | `string(Supplier<String> defaultValueSupplier)`
    `Class<T>` | `type()`
    `static Defaultable<URL>` | `url(Supplier<URL> defaultValueSupplier)`
    `static Defaultable<URL>` | `url(URL defaultValue)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### string

          public static Defaultable<String> string(String defaultValue)

    - #### string

          public static Defaultable<String> string(Supplier<String> defaultValueSupplier)

    - #### integer

          public static Defaultable<Integer> integer(int defaultValue)

    - #### floating

          public static Defaultable<Float> floating(float defaultValue)

    - #### integer

          public static Defaultable<Integer> integer(Supplier<Integer> defaultValueSupplier)

    - #### floating

          public static Defaultable<Float> floating(Supplier<Float> defaultValueSupplier)

    - #### longInteger

          public static Defaultable<Long> longInteger(long defaultValue)

    - #### longInteger

          public static Defaultable<Long> longInteger(Supplier<Long> defaultValueSupplier)

    - #### bool

          public static Defaultable<Boolean> bool(boolean defaultValue)

    - #### bool

          public static Defaultable<Boolean> bool(Supplier<Boolean> defaultValueSupplier)

    - #### url

          public static Defaultable<URL> url(URL defaultValue)

    - #### url

          public static Defaultable<URL> url(Supplier<URL> defaultValueSupplier)

    - #### ifAllExplicitlySet

          public static Defaultable<Boolean> ifAllExplicitlySet(Defaultable<?>... items)

      Create a `Boolean` configuration that has a default value of `true` if all arguments have been explicitly set to non-default values.
      Parameters:
        `items` - The items to test.
      Returns:
        The new item.

    - #### ifAnyExplicitlySet

          public static Defaultable<Boolean> ifAnyExplicitlySet(Defaultable<?>... items)

      Create a `Boolean` configuration that has a default value of `true` if any arguments have been explicitly set to non-default values.
      Parameters:
        `items` - The items to test.
      Returns:
        The new item.

    - #### type

          public Class<T> type()

    - #### set

          public void set(T explicitValue)

      Explicitly set a value.
      Parameters:
        `explicitValue` - The value to set.

    - #### defaultValue

          public T defaultValue()
                         throws NoSuchElementException

      Retrieve the default value, if any.
      Returns:
        The default value.
      Throws:
        `NoSuchElementException` - if no default value is available.

    - #### explicitValue

          public T explicitValue()
                          throws NoSuchElementException

      Retrieve the explicitly set value, if any.
      Returns:
        The explicitly set value.
      Throws:
        `NoSuchElementException` - if no explicit value is available.

    - #### get

          public T get()
                throws NoSuchElementException

      Retrieve the value, regardless of it's origin.
      Specified by:
        `get` in interface `Supplier<T>`
      Returns:
        The value, if non-null.
      Throws:
        `NoSuchElementException` - If no value (default nor explicit) is present.

    - #### explicit

          public Optional<T> explicit()

      Retrieve a standard `Optional` containing the explicit value, if any.

      If no explicit value is set, an empty `Optional` will be returned.

      Returns:
        The `Optional` wrapper around the explicitly set value, if any.

    - #### ifPresent

          public void ifPresent(Consumer<? super T> consumer)

      If a default or explicit value is present, invoke the supplied consumer with it.
      Parameters:
        `consumer` - The consumer.

    - #### ifExplicit

          public void ifExplicit(Consumer<? super T> consumer)

      If (and only if) an explicit value is present, invoke the supplied consumer with it
      Parameters:
        `consumer` - The consumer.

    - #### ifDefault

          public void ifDefault(Consumer<? super T> consumer)

      If (and only if) only a default value is present (without an explicit value), invoke the supplied consumer with it.
      Parameters:
        `consumer` - The consumer.

    - #### orElse

          public T orElse(T defaultValue)

      Retrieve the value (default or explicit) if present, otherwise the provided value parameter.
      Parameters:
        `defaultValue` - The value to return only if no value is present.
      Returns:
        Either the value (default or explicit) or the `defaultValue` parameter.

    - #### orElseGet

          public T orElseGet(Supplier<? extends T> other)

      Retrieve the value (default or explicit) if present, otherwise return the value supplied by the `Supplier` parameter.
      Parameters:
        `other` - The value supplier to use to supply a value only if no value is present.
      Returns:
        Either the value (default or explicit) or the value supplied by the `other` `Supplier` parameter.

    - #### explicitOrElseGet

          public T explicitOrElseGet(Supplier<? extends T> other)

      Retrieve the explicit value if present, otherwise return the value supplied by the `Supplier` parameter.
      Parameters:
        `other` - The value supplier to use to supply a value only if no explicit value is present.
      Returns:
        Either the explicitly set value (if set) or the value supplied by the `other` `Supplier` parameter.

    - #### get

          public T get(Supplier<? extends T> preferred)

      Retrieve the explicit value if present, followed in precedence by whatever value, if not-null supplied by the `preferred` parameter, followed by the default if all previous options were null.
      Parameters:
        `preferred` - The intermediate value supplier.
      Returns:
        The explicitly set, preferred or default value in that order, or possibly null.

    - #### isPresent

          public boolean isPresent()

      Determine if any value (default or explicit) is present.
      Returns:
        `true` is a value is present, otherwise `false`.

    - #### isExplicitPresent

          public boolean isExplicitPresent(Supplier<T> other)

      Determine if either an explicit value is set of the supplied `other` `Supplier` parameter returns non-null.
      Parameters:
        `other` - The alternative value supplier.
      Returns:
        `true` if either an explicit value is set or the supplier provides a non-null value.

    - #### isDefault

          public boolean isDefault()

      Determine if the value that would be provided (even if null) is the default value or not.
      Returns:
        `true` only if no explicit value is set.

    - #### isExplicit

          public boolean isExplicit()

      Determine if the value that would be provided is explicitly set or not.
      Returns:
        `true` only if an explicit value is set.

Copyright © 2018 JBoss by Red Hat. All rights reserved.