blob: 4579a6afca31e595a3b453c07a76933682d21bbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*******************************************************************************
* Copyright (c) 2005, 2015 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.common.utility.internal.predicate.int_;
import org.eclipse.jpt.common.utility.predicate.IntPredicate;
/**
* This compound predicate will evaluate to <code>true</code> if <em>all</em>
* its wrapped predicates evaluate to <code>true</code>.
* If there are <em>no</em> wrapped
* predicates, this predicate will always evaluate to <code>true</code>.
* If there are wrapped predicates, this predicate will
* exhibit "short-circuit" behavior; i.e. if any wrapped predicate evaluates
* to <code>false</code>, no following wrapped predicates will be evaluated.
*
* @see OR
* @see XOR
* @see NOT
*/
public class AND
extends AbstractCompoundIntPredicate
{
/**
* Construct a predicate that will evaluate to <code>true</code> if <em>all</em>
* the specified predicates evaluate to <code>true</code>.
*/
@SafeVarargs
public AND(IntPredicate... predicates) {
super(predicates);
}
public boolean evaluate(int variable) {
for (IntPredicate predicate : this.predicates) {
if ( ! predicate.evaluate(variable)) {
return false;
}
}
return true;
}
@Override
protected String operatorString() {
return "AND"; //$NON-NLS-1$
}
}
|