Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RightIdentity |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | package org.apache.commons.functor.core; | |
18 | ||
19 | import org.apache.commons.functor.BinaryFunction; | |
20 | import org.apache.commons.functor.BinaryPredicate; | |
21 | import org.apache.commons.functor.adapter.BinaryFunctionBinaryPredicate; | |
22 | import org.apache.commons.functor.adapter.IgnoreLeftFunction; | |
23 | ||
24 | /** | |
25 | * Holder class for a right-identity <code>BinaryFunction</code> (evaluates to the right argument) and a right-identity | |
26 | * <code>BinaryPredicate</code> (tests whether right <code>Boolean</code> argument equals <code>Boolean.TRUE</code>). | |
27 | * | |
28 | * @version $Revision: 1160415 $ $Date: 2011-08-22 22:14:38 +0200 (Mon, 22 Aug 2011) $ | |
29 | * @author Rodney Waldhoff | |
30 | * @author Matt Benson | |
31 | */ | |
32 | public final class RightIdentity { | |
33 | ||
34 | // static attributes | |
35 | // ------------------------------------------------------------------------ | |
36 | /** | |
37 | * Right-identity function. | |
38 | */ | |
39 | 2 | public static final BinaryFunction<Object, Object, Object> FUNCTION = RightIdentity.<Object, Object>function(); |
40 | ||
41 | /** | |
42 | * Right-identity predicate. | |
43 | */ | |
44 | 2 | public static final BinaryPredicate<Object, Boolean> PREDICATE = |
45 | BinaryFunctionBinaryPredicate.adapt(IgnoreLeftFunction.adapt(new Identity<Boolean>())); | |
46 | ||
47 | // constructor | |
48 | // ------------------------------------------------------------------------ | |
49 | /** | |
50 | * Create a new RightIdentity. | |
51 | */ | |
52 | 0 | public RightIdentity() { |
53 | 0 | } |
54 | ||
55 | // static methods | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
58 | /** | |
59 | * Get a typed right-identity BinaryFunction. | |
60 | * @param <L> the left argument type. | |
61 | * @param <R> the right argument type. | |
62 | * @return BinaryFunction<L, R, R> | |
63 | */ | |
64 | public static <L, R> BinaryFunction<L, R, R> function() { | |
65 | 24 | return IgnoreLeftFunction.adapt(new Identity<R>()); |
66 | } | |
67 | ||
68 | /** | |
69 | * Get a typed right-identity BinaryPredicate. | |
70 | * @param <L> the left argument type. | |
71 | * @return BinaryPredicate<L, Boolean> | |
72 | */ | |
73 | public static <L> BinaryPredicate<L, Boolean> predicate() { | |
74 | 0 | return BinaryFunctionBinaryPredicate.adapt( |
75 | IgnoreLeftFunction.<L, Boolean, Boolean>adapt(new Identity<Boolean>())); | |
76 | } | |
77 | } |