Package akka.japi.pf

Class PFBuilder<I,​R>

  • Type Parameters:
    I - the input type, that this PartialFunction will be applied to
    R - the return type, that the results of the application will have

    public final class PFBuilder<I,​R>
    extends java.lang.Object
    A builder for PartialFunction.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected scala.PartialFunction<F,​T> statements  
    • Constructor Summary

      Constructors 
      Constructor Description
      PFBuilder()
      Create a PFBuilder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addStatement​(scala.PartialFunction<F,​T> statement)  
      scala.PartialFunction<F,​T> build()
      Build a PartialFunction from this builder.
      <P> PFBuilder<I,​R> match​(java.lang.Class<P> type, FI.Apply<P,​R> apply)
      Add a new case statement to this builder.
      <P> PFBuilder<I,​R> match​(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.Apply<P,​R> apply)
      Add a new case statement to this builder.
      PFBuilder<I,​R> matchAny​(FI.Apply<I,​R> apply)
      Add a new case statement to this builder, that matches any argument.
      <P> PFBuilder<I,​R> matchEquals​(P object, FI.Apply<P,​R> apply)
      Add a new case statement to this builder.
      PFBuilder<I,​R> matchUnchecked​(java.lang.Class<?> type, FI.Apply<?,​R> apply)
      Add a new case statement to this builder without compile time type check of the parameters.
      PFBuilder<I,​R> matchUnchecked​(java.lang.Class<?> type, FI.TypedPredicate<?> predicate, FI.Apply<?,​R> apply)
      Add a new case statement to this builder without compile time type check of the parameters.
      • Methods inherited from class java.lang.Object

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

      • statements

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

      • PFBuilder

        public PFBuilder()
        Create a PFBuilder.
    • Method Detail

      • match

        public <P> PFBuilder<I,​R> match​(java.lang.Class<P> type,
                                              FI.Apply<P,​R> 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 PFBuilder<I,​R> matchUnchecked​(java.lang.Class<?> type,
                                                   FI.Apply<?,​R> apply)
        Add a new case statement to this builder without compile time type check of the parameters. 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> PFBuilder<I,​R> match​(java.lang.Class<P> type,
                                              FI.TypedPredicate<P> predicate,
                                              FI.Apply<P,​R> 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 PFBuilder<I,​R> matchUnchecked​(java.lang.Class<?> type,
                                                   FI.TypedPredicate<?> predicate,
                                                   FI.Apply<?,​R> apply)
        Add a new case statement to this builder without compile time type check of the parameters. 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> PFBuilder<I,​R> matchEquals​(P object,
                                                    FI.Apply<P,​R> 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
      • matchAny

        public PFBuilder<I,​R> matchAny​(FI.Apply<I,​R> 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.