1993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira/*
2993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Copyright (C) 2007 Google Inc.
3993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
4993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Licensed under the Apache License, Version 2.0 (the "License");
5993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * you may not use this file except in compliance with the License.
6993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * You may obtain a copy of the License at
7993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
8993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * http://www.apache.org/licenses/LICENSE-2.0
9993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
10993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Unless required by applicable law or agreed to in writing, software
11993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * distributed under the License is distributed on an "AS IS" BASIS,
12993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * See the License for the specific language governing permissions and
14993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * limitations under the License.
15993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira */
16993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
171bdbfefe4b144c7b031a1d9242a0fa061a0ae6b5Scott Kennedypackage com.google.android.mail.common.base;
18993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
19993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
20993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira/**
21993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * A transformation from one object to another. For example, a
22993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * {@code StringToIntegerFunction} may implement
23993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * <code>Function&lt;String,Integer&gt;</code> and transform integers in
24993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * {@code String} format to {@code Integer} format.
25993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
26993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * <p>The transformation on the source object does not necessarily result in
27993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * an object of a different type.  For example, a
28993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * {@code FarenheitToCelsiusFunction} may implement
29993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * <code>Function&lt;Float,Float&gt;</code>.
30993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
31993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * <p>Implementations which may cause side effects upon evaluation are strongly
32993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * encouraged to state this fact clearly in their API documentation.
33993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
34993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @param <F> the type of the function input
35993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @param <T> the type of the function output
36993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @author Kevin Bourrillion
37993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @author Scott Bonneau
38993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
39993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira */
40993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereirapublic interface Function<F, T> {
41993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
42993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  /**
43993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * Applies the function to an object of type {@code F}, resulting in an object
44993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * of type {@code T}.  Note that types {@code F} and {@code T} may or may not
45993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * be the same.
46993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   *
47993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * @param from the source object
48993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * @return the resulting object
49993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   */
50993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  T apply(F from);
51993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
52993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  /**
53993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * Indicates whether some other object is equal to this {@code Function}.
54993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * This method can return {@code true} <i>only</i> if the specified object is
55993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * also a {@code Function} and, for every input object {@code o}, it returns
56993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * exactly the same value.  Thus, {@code function1.equals(function2)} implies
57993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * that either {@code function1.apply(o)} and {@code function2.apply(o)} are
58993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * both null, or {@code function1.apply(o).equals(function2.apply(o))}.
59993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   *
60993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * <p>Note that it is always safe <em>not</em> to override
61993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * {@link Object#equals}.
62993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   */
63993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  boolean equals(Object obj);
64993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira}
65