01: /**
02: * Copyright (C) 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */package com.google.inject.util;
16:
17: /**
18: * A Function provides a transformation on an object and returns the resulting
19: * object. For example, a {@code StringToIntegerFunction} may implement
20: * <code>Function<String,Integer></code> and transform integers in String
21: * format to Integer format.
22: *
23: * <p>The transformation on the from object does not necessarily result in
24: * an object of a different type. For example, a
25: * {@code FarenheitToCelciusFunction} may implement
26: * <code>Function<Float,Float></code>.
27: *
28: * <p>Implementors of Function which may cause side effects upon evaluation are
29: * strongly encouraged to state this fact clearly in their API documentation.
30: */
31: public interface Function<F, T> {
32:
33: /**
34: * Applies the function to an object of type {@code F}, resulting in an object
35: * of type {@code T}. Note that types {@code F} and {@code T} may or may not
36: * be the same.
37: *
38: * @param from The from object.
39: * @return The resulting object.
40: */
41: T apply(F from);
42: }
|