Package akka.japi.pf

Class UnitPFBuilder<I>

  • Type Parameters:
    I - the input type, that this PartialFunction to be applied to

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

      • statements

        protected scala.PartialFunction<F,​T> statements
    • Constructor Detail

      • UnitPFBuilder

        public UnitPFBuilder()
        Create a UnitPFBuilder.
    • Method Detail

      • match

        public <P> UnitPFBuilder<I> match​(java.lang.Class<P> type,
                                          FI.UnitApply<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​(java.lang.Class<?> type,
                                               FI.UnitApply<?> 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​(java.lang.Class<P> type,
                                          FI.TypedPredicate<P> predicate,
                                          FI.UnitApply<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​(java.lang.Class<?> type,
                                               FI.TypedPredicate<?> predicate,
                                               FI.UnitApply<?> 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,
                                                FI.UnitApply<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,
                                                FI.TypedPredicate<P> predicate,
                                                FI.UnitApply<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​(FI.UnitApply<java.lang.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<F,​T> statement)
      • build

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