Class PropertyMapper.Source<T>

java.lang.Object
org.springframework.boot.context.properties.PropertyMapper.Source<T>
Type Parameters:
T - the source type
Enclosing class:
PropertyMapper

public static final class PropertyMapper.Source<T> extends Object
A source that is in the process of being mapped.
  • Method Details

    • asInt

      public <R extends Number> PropertyMapper.Source<Integer> asInt(Function<T,R> adapter)
      Return an adapted version of the source with Integer type.
      Type Parameters:
      R - the resulting type
      Parameters:
      adapter - an adapter to convert the current value to a number.
      Returns:
      a new adapted source instance
    • as

      public <R> PropertyMapper.Source<R> as(Function<T,R> adapter)
      Return an adapted version of the source changed via the given adapter function.
      Type Parameters:
      R - the resulting type
      Parameters:
      adapter - the adapter to apply
      Returns:
      a new adapted source instance
    • whenNonNull

      public PropertyMapper.Source<T> whenNonNull()
      Return a filtered version of the source that won't map non-null values or suppliers that throw a NullPointerException.
      Returns:
      a new filtered source instance
    • whenTrue

      public PropertyMapper.Source<T> whenTrue()
      Return a filtered version of the source that will only map values that are true.
      Returns:
      a new filtered source instance
    • whenFalse

      public PropertyMapper.Source<T> whenFalse()
      Return a filtered version of the source that will only map values that are false.
      Returns:
      a new filtered source instance
    • whenHasText

      public PropertyMapper.Source<T> whenHasText()
      Return a filtered version of the source that will only map values that have a toString() containing actual text.
      Returns:
      a new filtered source instance
    • whenEqualTo

      public PropertyMapper.Source<T> whenEqualTo(Object object)
      Return a filtered version of the source that will only map values equal to the specified object.
      Parameters:
      object - the object to match
      Returns:
      a new filtered source instance
    • whenInstanceOf

      public <R extends T> PropertyMapper.Source<R> whenInstanceOf(Class<R> target)
      Return a filtered version of the source that will only map values that are an instance of the given type.
      Type Parameters:
      R - the target type
      Parameters:
      target - the target type to match
      Returns:
      a new filtered source instance
    • whenNot

      public PropertyMapper.Source<T> whenNot(Predicate<T> predicate)
      Return a filtered version of the source that won't map values that match the given predicate.
      Parameters:
      predicate - the predicate used to filter values
      Returns:
      a new filtered source instance
    • when

      public PropertyMapper.Source<T> when(Predicate<T> predicate)
      Return a filtered version of the source that won't map values that don't match the given predicate.
      Parameters:
      predicate - the predicate used to filter values
      Returns:
      a new filtered source instance
    • to

      public void to(Consumer<T> consumer)
      Complete the mapping by passing any non-filtered value to the specified consumer.
      Parameters:
      consumer - the consumer that should accept the value if it's not been filtered
    • toInstance

      public <R> R toInstance(Function<T,R> factory)
      Complete the mapping by creating a new instance from the non-filtered value.
      Type Parameters:
      R - the resulting type
      Parameters:
      factory - the factory used to create the instance
      Returns:
      the instance
      Throws:
      NoSuchElementException - if the value has been filtered
    • toCall

      public void toCall(Runnable runnable)
      Complete the mapping by calling the specified method when the value has not been filtered.
      Parameters:
      runnable - the method to call if the value has not been filtered