alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (TBlock.java)

This example Java source code file (TBlock.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

tblock

The TBlock.java Java example source code

/**
 * Performs operations upon an input object which may modify that object and/or
 * external state (other objects).
 *
 * <p>All block implementations are expected to:
 * <ul>
 * <li>When used for aggregate operations upon many elements blocks
 * should not assume that the {@code apply} operation will be called upon
 * elements in any specific order.</li>
 * </ul>
 *
 * @param <T> The type of input objects to {@code apply}.
 */
public interface TBlock<T> {

    /**
     * Performs operations upon the provided object which may modify that object
     * and/or external state.
     *
     * @param t an input object
     */
    void apply(T t);

    /**
     * Returns a Block which performs in sequence the {@code apply} methods of
     * multiple Blocks. This Block's {@code apply} method is performed followed
     * by the {@code apply} method of the specified Block operation.
     *
     * @param other an additional Block which will be chained after this Block
     * @return a Block which performs in sequence the {@code apply} method of
     * this Block and the {@code apply} method of the specified Block operation
     */
    public default TBlock<T> chain(TBlock other) {
        return (T t) -> { apply(t); other.apply(t); };
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java TBlock.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.