Debian Codegraph @

net/sf/saxon/z/IntExceptPredicate.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.z;
9
10 /**
11 * An IntPredicate formed as the difference of two other predicates: it matches
12 * an integer if the first operand matches the integer and the second does not
13 */
14
15 public class IntExceptPredicate implements java.util.function.IntPredicate {
16
17 private java.util.function.IntPredicate p1;
18 private java.util.function.IntPredicate p2;
19
20 public IntExceptPredicate(java.util.function.IntPredicate p1, java.util.function.IntPredicate p2) {
21 this.p1 = p1;
22 this.p2 = p2;
23 }
24
25 /**
26 * Ask whether a given value matches this predicate
27 *
28 * @param value the value to be tested
29 * @return true if the value matches; false if it does not
30 */
31 public boolean test(int value) {
32 return p1.test(value) && !p2.test(value);
33 }
34
35 /**
36 * Get the operands
37 *
38 * @return an array containing the two operands
39 */
40
41 public java.util.function.IntPredicate[] getOperands() {
42 return new java.util.function.IntPredicate[]{p1, p2};
43 }
44 }
45