Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Not |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.policy.predicate; | |
11 | ||
12 | import java.util.Map; | |
13 | ||
14 | import org.openpermis.policy.Predicate; | |
15 | import org.openpermis.policy.TimeStamp; | |
16 | ||
17 | /** | |
18 | * Not operation on a predicate. | |
19 | * @since 0.1.0 | |
20 | */ | |
21 | public class Not extends AbstractPredicate<Predicate> { | |
22 | ||
23 | //---- Static | |
24 | ||
25 | /** | |
26 | * @since 0.1.0 | |
27 | */ | |
28 | private static final long serialVersionUID = 4230209545826050488L; | |
29 | ||
30 | //---- Constructors | |
31 | ||
32 | /** | |
33 | * Creates an not node. | |
34 | * @param predicate {@link Predicate}. | |
35 | * @since 0.1.0 | |
36 | */ | |
37 | public Not (Predicate predicate) { | |
38 | 12 | super(predicate); |
39 | 12 | } |
40 | ||
41 | //---- AbstractPredicate | |
42 | ||
43 | /** | |
44 | * @since 0.1.0 | |
45 | */ | |
46 | public boolean isValid () { | |
47 | 2 | return getOperand(0).isValid(); |
48 | } | |
49 | ||
50 | /** | |
51 | * @since 0.1.0 | |
52 | */ | |
53 | public boolean matches (TimeStamp timeStamp, Map<String, ?> arguments) { | |
54 | 5 | return !getOperand(0).matches(timeStamp, arguments); |
55 | } | |
56 | ||
57 | /** | |
58 | * @since 0.3.0 | |
59 | */ | |
60 | public boolean isMatchable (Map<String, Class<?>> arguments) { | |
61 | 2 | return getOperand(0).isMatchable(arguments); |
62 | } | |
63 | ||
64 | /** | |
65 | * @since 0.1.0 | |
66 | */ | |
67 | @Override | |
68 | public boolean comparablePredicate (Predicate predicate) { | |
69 | 2 | return predicate instanceof Not; |
70 | } | |
71 | ||
72 | /** | |
73 | * @since 0.1.0 | |
74 | */ | |
75 | protected int partHashCode () { | |
76 | 2 | return Not.class.hashCode(); |
77 | } | |
78 | ||
79 | } |