/* * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Functional interfaces provide target types for lambda expressions * and method references. Each functional interface has a single abstract * method, called the functional method for that functional interface, * to which the lambda expression's parameter and return types are matched or * adapted. Functional interfaces can provide a target type in multiple * contexts, such as assignment context, method invocation, or cast context: * *
{@code
 *     // Assignment context
 *     Predicate p = String::isEmpty;
 *
 *     // Method invocation context
 *     stream.filter(e -> e.getSize() > 10)...
 *
 *     // Cast context
 *     stream.map((ToIntFunction) e -> e.getSize())...
 * }
* *

The interfaces in this package are general purpose functional interfaces * used by the JDK, and are available to be used by user code as well. While * they do not identify a complete set of function shapes to which lambda * expressions might be adapted, they provide enough to cover common * requirements. Other functional interfaces provided for specific purposes, * such as {@link java.io.FileFilter}, are defined in the packages where they * are used. * *

The interfaces in this package are annotated with * {@link java.lang.FunctionalInterface}. This annotation is not a requirement * for the compiler to recognize an interface as a functional interface, but * merely an aid to capture design intent and enlist the help of the compiler in * identifying accidental violations of design intent. * *

Functional interfaces often represent abstract concepts like functions, * actions, or predicates. In documenting functional interfaces, or referring * to variables typed as functional interfaces, it is common to refer directly * to those abstract concepts, for example using "this function" instead of * "the function represented by this object". * *

The functional interfaces in this package follow an extensible naming * convention, as follows: * *

* * @see java.lang.FunctionalInterface */ package java.util.function;