Class UnitPFBuilder<I>

java.lang.Object
org.apache.pekko.japi.pf.UnitPFBuilder<I>
Type Parameters:
I - the input type, that this PartialFunction to be applied to

public final class UnitPFBuilder<I> extends Object
A builder for PartialFunction. This is a specialized version of PFBuilder to map java void methods to BoxedUnit.
  • Field Details

    • statements

      protected scala.PartialFunction<I,scala.runtime.BoxedUnit> statements
  • Constructor Details

    • UnitPFBuilder

      public UnitPFBuilder()
      Create a UnitPFBuilder.
  • Method Details

    • match

      public <P> UnitPFBuilder<I> match(Class<P> type, Procedure<P> apply)
      Add a new case statement to this builder.
      Parameters:
      type - a type to match the argument against
      apply - an action to apply to the argument if the type matches
      Returns:
      a builder with the case statement added
    • matchUnchecked

      public UnitPFBuilder<I> matchUnchecked(Class<?> type, Procedure<?> apply)
      Add a new case statement to this builder without compile time type check. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g. List.class and (List<String> list) -> {}.
      Parameters:
      type - a type to match the argument against
      apply - an action to apply to the argument if the type matches
      Returns:
      a builder with the case statement added
    • match

      public <P> UnitPFBuilder<I> match(Class<P> type, Predicate<P> predicate, Procedure<P> apply)
      Add a new case statement to this builder.
      Parameters:
      type - a type to match the argument against
      predicate - a predicate that will be evaluated on the argument if the type matches
      apply - an action to apply to the argument if the type matches and the predicate returns true
      Returns:
      a builder with the case statement added
    • matchUnchecked

      public UnitPFBuilder<I> matchUnchecked(Class<?> type, Predicate<?> predicate, Procedure<?> apply)
      Add a new case statement to this builder without compile time type check. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g. List.class and (List<String> list) -> {}.
      Parameters:
      type - a type to match the argument against
      predicate - a predicate that will be evaluated on the argument if the type matches
      apply - an action to apply to the argument if the type matches and the predicate returns true
      Returns:
      a builder with the case statement added
    • matchEquals

      public <P> UnitPFBuilder<I> matchEquals(P object, Procedure<P> apply)
      Add a new case statement to this builder.
      Parameters:
      object - the object to compare equals with
      apply - an action to apply to the argument if the object compares equal
      Returns:
      a builder with the case statement added
    • matchEquals

      public <P> UnitPFBuilder<I> matchEquals(P object, Predicate<P> predicate, Procedure<P> apply)
      Add a new case statement to this builder.
      Parameters:
      object - the object to compare equals with
      predicate - a predicate that will be evaluated on the argument if the object compares equal
      apply - an action to apply to the argument if the object compares equal
      Returns:
      a builder with the case statement added
    • matchAny

      public UnitPFBuilder<I> matchAny(Procedure<Object> apply)
      Add a new case statement to this builder, that matches any argument.
      Parameters:
      apply - an action to apply to the argument
      Returns:
      a builder with the case statement added
    • addStatement

      protected void addStatement(scala.PartialFunction<I,scala.runtime.BoxedUnit> statement)
    • build

      public scala.PartialFunction<I,scala.runtime.BoxedUnit> build()
      Build a PartialFunction from this builder. After this call the builder will be reset.
      Returns:
      a PartialFunction for this builder.