• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-17, OpenCensus Authors
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 io.opencensus.common;
18 
19 /**
20  * Used to specify matching functions for use encoding tagged unions (i.e. sum types) in Java. See
21  * {@link io.opencensus.trace.AttributeValue#match} for an example of its use.
22  *
23  * <p>Note: This class is based on the java.util.Function class added in Java 1.8. We cannot use the
24  * Function from Java 1.8 because this library is Java 1.6 compatible.
25  *
26  * @since 0.5
27  */
28 public interface Function<A, B> {
29 
30   /**
31    * Applies the function to the given argument.
32    *
33    * @param arg the argument to the function.
34    * @return the result of the function.
35    * @since 0.5
36    */
apply(A arg)37   B apply(A arg);
38 }
39