Revision 41138
Added by Claudio Atzori almost 9 years ago
modules/dnet-pace-core/trunk/src/main/java/eu/dnetlib/pace/model/CondDef.java | ||
---|---|---|
24 | 24 |
return new SizeMatch(fields); |
25 | 25 |
case exactMatch: |
26 | 26 |
return new ExactMatch(fields); |
27 |
case mustBeDifferent: |
|
28 |
return new MustBeDifferent(fields); |
|
27 | 29 |
case exactMatchIgnoreCase: |
28 | 30 |
return new ExactMatchIgnoreCase(fields); |
29 | 31 |
case doiExactMatch: |
modules/dnet-pace-core/trunk/src/main/java/eu/dnetlib/pace/config/Cond.java | ||
---|---|---|
11 | 11 |
titleVersionMatch, |
12 | 12 |
/** The size match. */ |
13 | 13 |
sizeMatch, |
14 |
/** |
|
15 |
* Returns true if the field values are different |
|
16 |
*/ |
|
17 |
mustBeDifferent, |
|
14 | 18 |
/** The Exact match. */ |
15 | 19 |
exactMatch, |
16 | 20 |
/** |
modules/dnet-pace-core/trunk/src/main/java/eu/dnetlib/pace/condition/MustBeDifferent.java | ||
---|---|---|
1 |
package eu.dnetlib.pace.condition; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.common.collect.Iterables; |
|
6 |
import eu.dnetlib.pace.model.Field; |
|
7 |
import eu.dnetlib.pace.model.FieldDef; |
|
8 |
|
|
9 |
/** |
|
10 |
* Returns true if the field values are different. |
|
11 |
* |
|
12 |
* @author claudio |
|
13 |
*/ |
|
14 |
public class MustBeDifferent extends AbstractCondition { |
|
15 |
|
|
16 |
/** |
|
17 |
* Instantiates a new size match. |
|
18 |
* |
|
19 |
* @param fields the fields |
|
20 |
*/ |
|
21 |
public MustBeDifferent(final List<FieldDef> fields) { |
|
22 |
super(fields); |
|
23 |
} |
|
24 |
|
|
25 |
/* |
|
26 |
* (non-Javadoc) |
|
27 |
* |
|
28 |
* @see eu.dnetlib.pace.condition.AbstractCondition#verify(eu.dnetlib.pace.model.FieldDef, java.util.List, java.util.List) |
|
29 |
*/ |
|
30 |
@Override |
|
31 |
protected int verify(final FieldDef fd, final Field a, final Field b) { |
|
32 |
|
|
33 |
final String fa = getValue(a); |
|
34 |
final String fb = getValue(b); |
|
35 |
|
|
36 |
return fa.equals(fb) ? -1 : 1; |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
protected String getValue(final Field f) { |
|
41 |
return getFirstValue(f); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Checks if is empty. |
|
46 |
* |
|
47 |
* @param a the a |
|
48 |
* @return true, if is empty |
|
49 |
*/ |
|
50 |
protected boolean isEmpty(final Iterable<?> a) { |
|
51 |
return (a == null) || Iterables.isEmpty(a); |
|
52 |
} |
|
53 |
|
|
54 |
} |
Also available in: Unified diff
introduced condition: mustBeDifferent