WithKeys.java

package org.thewonderlemming.c4plantuml.graphml.model;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

/**
 * A basic Java {@link Function} to create fluent builders such as {@link GraphMLModel#builder()}.
 *
 * @author thewonderlemming
 *
 * @param <T> the type of the result of the function.
 */
@FunctionalInterface
public interface WithKeys<T> {

    /**
     * Takes a list of {@link KeyModel}, processes it and returns a results of type T.
     *
     * @param keys the parameter given to the function.
     * @return the results of the function.
     */
    T withKeys(final List<KeyModel> keys);

    /**
     * A semantic call to pass no value to the current function.
     *
     * @return the results of the function.
     */
    default T withoutKeys() {
        return withKeys(Collections.emptyList());
    }
}