1 /** 2 * Copyright (C) 2006 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.inject.util; 18 19 /** 20 * A Function provides a transformation on an object and returns the resulting 21 * object. For example, a {@code StringToIntegerFunction} may implement 22 * <code>Function<String,Integer></code> and transform integers in String 23 * format to Integer format. 24 * 25 * <p>The transformation on the from object does not necessarily result in 26 * an object of a different type. For example, a 27 * {@code FarenheitToCelciusFunction} may implement 28 * <code>Function<Float,Float></code>. 29 * 30 * <p>Implementors of Function which may cause side effects upon evaluation are 31 * strongly encouraged to state this fact clearly in their API documentation. 32 */ 33 public interface Function<F,T> { 34 35 /** 36 * Applies the function to an object of type {@code F}, resulting in an object 37 * of type {@code T}. Note that types {@code F} and {@code T} may or may not 38 * be the same. 39 * 40 * @param from The from object. 41 * @return The resulting object. 42 */ 43 T apply(F from); 44 } 45