Class UnitMatch<I>

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

public class UnitMatch<I> extends Object
Version of PartialFunction that can be built during runtime from Java. This is a specialized version of UnitMatch to map java void methods to BoxedUnit.
  • Field Details

    • statements

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

    • match

      public static <F, P> UnitPFBuilder<F> match(Class<P> type, Procedure<P> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added.
      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
      See Also:
    • matchUnchecked

      public static UnitPFBuilder<Object> matchUnchecked(Class<?> type, Procedure<?> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added. Should normally not be used.
      See Also:
    • match

      public static <F, P> UnitPFBuilder<F> match(Class<P> type, Predicate<P> predicate, Procedure<P> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added.
      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 and predicate matches
      Returns:
      a builder with the case statement added
      See Also:
    • matchUnchecked

      public static <F, P> UnitPFBuilder<F> matchUnchecked(Class<?> type, Predicate<?> predicate, Procedure<?> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added. Should normally not be used.
      See Also:
    • matchEquals

      public static <F, P> UnitPFBuilder<F> matchEquals(P object, Procedure<P> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added.
      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
      See Also:
    • matchEquals

      public static <F, P> UnitPFBuilder<F> matchEquals(P object, Predicate<P> predicate, Procedure<P> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added.
      Parameters:
      object - the object to compare equals with
      predicate - a predicate that will be evaluated on the argument 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
      See Also:
    • matchAny

      public static <F> UnitPFBuilder<F> matchAny(Procedure<Object> apply)
      Convenience function to create a UnitPFBuilder with the first case statement added.
      Parameters:
      apply - an action to apply to the argument
      Returns:
      a builder with the case statement added
      See Also:
    • create

      public static <F> UnitMatch<F> create(UnitPFBuilder<F> builder)
      Create a UnitMatch from the builder.
      Parameters:
      builder - a builder representing the partial function
      Returns:
      a UnitMatch that can be reused
    • match

      public void match(I i) throws scala.MatchError
      Convenience function to make the Java code more readable.

      
         UnitMatcher<X> matcher = UnitMatcher.create(...);
      
         matcher.match(obj);
       
      Parameters:
      i - the argument to apply the match to
      Throws:
      scala.MatchError - if there is no match
    • asPF

      public scala.PartialFunction<I,scala.runtime.BoxedUnit> asPF()
      Turn this Match into a PartialFunction.
      Returns:
      a partial function representation ot his Match