org.springframework.boot.context.properties

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 java.lang.Object
    A source that is in the process of being mapped.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      <R> PropertyMapper.Source<R> as(java.util.function.Function<T,R> adapter)
      Return an adapted version of the source changed via the given adapter function.
      <R extends java.lang.Number>
      PropertyMapper.Source<java.lang.Integer>
      asInt(java.util.function.Function<T,R> adapter)
      Return an adapted version of the source with Integer type.
      void to(java.util.function.Consumer<T> consumer)
      Complete the mapping by passing any non-filtered value to the specified consumer.
      void toCall(java.lang.Runnable runnable)
      Complete the mapping by calling the specified method when the value has not been filtered.
      <R> R toInstance(java.util.function.Function<T,R> factory)
      Complete the mapping by creating a new instance from the non-filtered value.
      PropertyMapper.Source<T> when(java.util.function.Predicate<T> predicate)
      Return a filtered version of the source that won't map values that don't match the given predicate.
      PropertyMapper.Source<T> whenEqualTo(java.lang.Object object)
      Return a filtered version of the source that will only map values equal to the specified object.
      PropertyMapper.Source<T> whenFalse()
      Return a filtered version of the source that will only map values that are false.
      PropertyMapper.Source<T> whenHasText()
      Return a filtered version of the source that will only map values that have a toString() containing actual text.
      <R extends T>
      PropertyMapper.Source<R>
      whenInstanceOf(java.lang.Class<R> target)
      Return a filtered version of the source that will only map values that are an instance of the given type.
      PropertyMapper.Source<T> whenNonNull()
      Return a filtered version of the source that won't map non-null values or suppliers that throw a NullPointerException.
      PropertyMapper.Source<T> whenNot(java.util.function.Predicate<T> predicate)
      Return a filtered version of the source that won't map values that match the given predicate.
      PropertyMapper.Source<T> whenTrue()
      Return a filtered version of the source that will only map values that are true.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • asInt

        public <R extends java.lang.Number> PropertyMapper.Source<java.lang.Integer> asInt(java.util.function.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(java.util.function.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(java.lang.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 TPropertyMapper.Source<R> whenInstanceOf(java.lang.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(java.util.function.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(java.util.function.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(java.util.function.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(java.util.function.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:
        java.util.NoSuchElementException - if the value has been filtered
      • toCall

        public void toCall(java.lang.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