Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IsNotSame |
|
| 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 java.io.Serializable; | |
20 | ||
21 | import org.apache.commons.functor.BinaryPredicate; | |
22 | import org.apache.commons.functor.UnaryPredicate; | |
23 | import org.apache.commons.functor.adapter.RightBoundPredicate; | |
24 | ||
25 | /** | |
26 | * {@link #test Tests} the reference (!=) inequality of its arguments. | |
27 | * | |
28 | * @param <L> the left argument type. | |
29 | * @param <R> the right argument type. | |
30 | * @version $Revision: 1160404 $ $Date: 2011-08-22 21:49:40 +0200 (Mon, 22 Aug 2011) $ | |
31 | * @author Matt Benson | |
32 | */ | |
33 | public final class IsNotSame<L, R> implements BinaryPredicate<L, R>, Serializable { | |
34 | // static attributes | |
35 | // ------------------------------------------------------------------------ | |
36 | /** | |
37 | * Basic IsNotSame<Object, Object> instance. | |
38 | */ | |
39 | 2 | public static final IsNotSame<Object, Object> INSTANCE = IsNotSame.<Object, Object>instance(); |
40 | /** | |
41 | * serialVersionUID declaration. | |
42 | */ | |
43 | private static final long serialVersionUID = 5566555980860979281L; | |
44 | ||
45 | // constructor | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
48 | * Create a new IsNotSame. | |
49 | */ | |
50 | 26 | public IsNotSame() { |
51 | 26 | } |
52 | ||
53 | // predicate interface | |
54 | // ------------------------------------------------------------------------ | |
55 | /** | |
56 | * {@inheritDoc} | |
57 | */ | |
58 | public boolean test(L left, R right) { | |
59 | 26 | return left != right; |
60 | } | |
61 | ||
62 | /** | |
63 | * {@inheritDoc} | |
64 | */ | |
65 | public boolean equals(Object that) { | |
66 | 28 | return that instanceof IsNotSame<?, ?>; |
67 | } | |
68 | ||
69 | /** | |
70 | * {@inheritDoc} | |
71 | */ | |
72 | public int hashCode() { | |
73 | 28 | return "IsNotSame".hashCode(); |
74 | } | |
75 | ||
76 | /** | |
77 | * {@inheritDoc} | |
78 | */ | |
79 | public String toString() { | |
80 | 20 | return "IsNotSame"; |
81 | } | |
82 | ||
83 | // static methods | |
84 | // ------------------------------------------------------------------------ | |
85 | /** | |
86 | * Get an IsNotSame instance. | |
87 | * @param <L> the left argument type. | |
88 | * @param <R> the right argument type. | |
89 | * @return IsNotSame | |
90 | */ | |
91 | public static <L, R> IsNotSame<L, R> instance() { | |
92 | 12 | return new IsNotSame<L, R>(); |
93 | } | |
94 | ||
95 | /** | |
96 | * Get an IsNotSame UnaryPredicate. | |
97 | * @param <L> the left argument type. | |
98 | * @param <R> the right argument type. | |
99 | * @param object bound comparison object | |
100 | * @return UnaryPredicate<L> | |
101 | */ | |
102 | public static <L, R> UnaryPredicate<L> as(R object) { | |
103 | 0 | return new RightBoundPredicate<L>(new IsNotSame<L, R>(), object); |
104 | } | |
105 | } |