1 /*
2 * Copyright 2006-2010 the original author or 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 package net.sourceforge.domian.specification;
17
18
19 import org.apache.commons.lang.Validate;
20
21 import static java.lang.Boolean.FALSE;
22 import static java.lang.Boolean.TRUE;
23
24
25 /**
26 * Leaf specification, always giving a negative response.
27 * <p/>
28 * Also known as a <i>contradiction</i>.
29 * <p/>
30 * This specification is raw/not type parameterized by design.
31 *
32 * @author Eirik Torske
33 * @since 0.4
34 */
35 final class AlwaysFalseSpecification extends AbstractSpecification implements LeafSpecification {
36
37 @Override
38 public Boolean isSatisfiedBy(final Object candidate) {
39 return FALSE;
40 }
41
42 @Override
43 public Boolean isDisjointWith(final Specification specification) {
44 Validate.notNull(specification, "Specification parameter cannot be null");
45 if (specification instanceof AlwaysTrueSpecification) {
46 return TRUE;
47 }
48 if (specification instanceof JointDenialSpecification) {
49 return specification.isDisjointWith(this);
50 }
51 return FALSE;
52 }
53
54 @Override
55 public final boolean equals(final Object otherObject) {
56 return this == otherObject || otherObject != null && otherObject instanceof AlwaysFalseSpecification;
57 }
58 }