Failure Sharing

Bootup your energy with sharing failure.

Mainly used Functional Interface on Java 8

Function, The Transformer

무조건 입력값과 출력값이 있어야 한다.

github.com

Consumer, The Spartan, Give Them Nothing but Take from Them Everything

말 그대로 무언가를 소비한다. ex. print out

without any return.

@FunctionalInterface
public interface Consumer<T> {

    /**
     * Performs this operation on the given argument.
     *
     * @param t the input argument
     */
    void accept(T t);

github.com

Predicate, The Judge

어떤 결과값이 주어진 조건에 만족 하는지 확인할 때 자주 사용

    /**
     * Evaluates this predicate on the given argument.
     *
     * @param t the input argument
     * @return {@code true} if the input argument matches the predicate,
     * otherwise {@code false}
     */
    boolean test(T t);

github.com

Supplier, The Master of Lazy Evaluation

Lazy evaluation을 통해 불필요한 자원 낭비를 최소화한다. 필요한 순간까지 평가를 지연시킨다.

    /**
     * Gets a result.
     *
     * @return a result
     */
    T get();

github.com

참고 블로그

medium.com