|
Akka/Scala example source code file (AbstractPFBuilder.java)
The AbstractPFBuilder.java Akka example source code
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.japi.pf;
import scala.PartialFunction;
/**
* A builder for {@link scala.PartialFunction}.
*
* @param <F> the input type, that this PartialFunction will be applied to
* @param <T> the return type, that the results of the application will have
*
* This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.
*/
abstract class AbstractPFBuilder<F, T> {
protected PartialFunction<F, T> statements = null;
protected void addStatement(PartialFunction<F, T> statement) {
if (statements == null)
statements = statement;
else
statements = statements.orElse(statement);
}
/**
* Build a {@link scala.PartialFunction} from this builder.
* After this call the builder will be reset.
*
* @return a PartialFunction for this builder.
*/
public PartialFunction<F, T> build() {
PartialFunction<F, T> empty = CaseStatement.empty();
PartialFunction<F, T> statements = this.statements;
this.statements = null;
if (statements == null)
return empty;
else
return statements.orElse(empty);
}
}
Other Akka source code examplesHere is a short list of links related to this Akka AbstractPFBuilder.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.