jdk/src/share/classes/java/util/function/package-info.java
author darcy
Fri, 19 Jul 2013 09:42:58 -0700
changeset 19033 13013b301bd0
parent 16011 890a7ed97f6c
child 19040 7b25fde2a4ed
permissions -rw-r--r--
8020948: Fix doclint issues in misc package-info.java files Reviewed-by: dholmes, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     1
/*
19033
13013b301bd0 8020948: Fix doclint issues in misc package-info.java files
darcy
parents: 16011
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     4
 *
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    10
 *
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    15
 * accompanied this code).
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    16
 *
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    20
 *
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    23
 * questions.
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    24
 */
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    25
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    26
/**
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    27
 * <em>Functional interfaces</em> provide target types for lambda expressions
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    28
 * and method references.  Each functional interface has a single abstract method
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    29
 * to which the lambda expression's parameter and return types are matched or
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    30
 * adapted.  Functional interfaces can provide a target type in multiple contexts,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    31
 * such as assignment context, method invocation, or cast context:
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    32
 *
19033
13013b301bd0 8020948: Fix doclint issues in misc package-info.java files
darcy
parents: 16011
diff changeset
    33
 * <pre>{@code
13013b301bd0 8020948: Fix doclint issues in misc package-info.java files
darcy
parents: 16011
diff changeset
    34
 *     Predicate<String> p = String::isEmpty;
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    35
 *
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    36
 *     stream.filter(e -> e.getSize() > 10)...
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    37
 *
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    38
 *     stream.map((ToIntFunction) e -> e.getSize())...
19033
13013b301bd0 8020948: Fix doclint issues in misc package-info.java files
darcy
parents: 16011
diff changeset
    39
 * }</pre>
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    40
 *
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    41
 * <p>The interfaces in this package are functional interfaces used by the JDK,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    42
 * and are available to be used by user code as well.  While they do not identify
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    43
 * a complete set of function shapes to which lambda expressions might be adapted,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    44
 * they provide enough to cover common requirements.
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    45
 *
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    46
 * <p>The interfaces in this package are annotated with @{link FunctionalInterface}.
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    47
 * This annotation is not a requirement for the compiler to recognize an interface
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    48
 * as a functional interface, but merely an aid to capture design intent and enlist the
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    49
 * help of the compiler in identifying accidental violations of design intent.
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    50
 *
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    51
 * <p>The functional interfaces in this package follow an extensible naming convention,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    52
 * as follows:
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    53
 *
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    54
 * <ul>
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    55
 *     <li>There are several basic function shapes, including {@link java.util.function.Function} ({@code T -> R}),
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    56
 *     {@link java.util.function.Consumer} ({@code T -> void}),
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    57
 *     {@link java.util.function.Predicate} ({@code T -> boolean}),
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    58
 *     and {@link java.util.function.Supplier} ({@code () -> T}).
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    59
 *     </li>
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    60
 *     <li>Function shapes have a natural arity based on how they are most commonly used.
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    61
 *     The basic shapes can be modified by an arity prefix to indicate a different arity,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    62
 *     such as {@link java.util.function.BiFunction} ({@code (T, U) -> R}).
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    63
 *     </li>
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    64
 *     <li>There are additional derived function shapes which extend the basic function
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    65
 *     shapes, including {@link java.util.function.UnaryOperator} (extends {@code Function}) and
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    66
 *     {@link java.util.function.BinaryOperator} (extends {@code BiFunction}).
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    67
 *     </li>
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    68
 *     <li>Type parameters of functional interfaces can be specialized to primitives with
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    69
 *     additional type prefixes.  To specialize the return type for a type that has both
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    70
 *     generic return type and generic arguments, we prefix {@code ToXxx}, as in
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    71
 *     {@link java.util.function.ToIntFunction}.  Otherwise, type arguments are specialized left-to-right,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    72
 *     as in {@link java.util.function.DoubleConsumer} or {@link java.util.function.ObjIntConsumer}.
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    73
 *     (The type prefix {@code Obj} is used to indicate that we don't want to specialize this parameter,
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    74
 *     but want to move on to the next parameter.)  These schemes can be combined as in {@code IntToDoubleFunction}.
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    75
 *     </li>
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    76
 *     <li>If there are specialization prefixes for all arguments, the arity prefix may be left
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    77
 *     out (as in {@link java.util.function.ObjIntConsumer}).
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    78
 *     </li>
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    79
 * </ul>
16011
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    80
 *
890a7ed97f6c 8004561: Additional functional interfaces, extension methods and name changes
mduigou
parents: 14670
diff changeset
    81
 * @see java.lang.FunctionalInterface
14670
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    82
 */
964ac9f1463c 8001634: Initial set of functional interface types
mduigou
parents:
diff changeset
    83
package java.util.function;