Project

General

Profile

Download (1.02 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
/**
3
 * <p>TaxonNodePropertyTester class.</p>
4
 *
5
 * @author n.hoffmann
6
 * @version $Id: $
7
 */
8
package eu.etaxonomy.taxeditor.navigation.navigator;
9

    
10
import org.eclipse.core.expressions.PropertyTester;
11

    
12
import eu.etaxonomy.cdm.model.taxon.Classification;
13
import eu.etaxonomy.cdm.model.taxon.Taxon;
14
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
15
public class TaxonNodePropertyTester extends PropertyTester {
16
	
17
	private static final Object HAS_SYNONYMS = "hasSynonyms";
18
	private static final Object HAS_TAXA = "hasTaxa";
19
	
20
	/** {@inheritDoc} */
21
	public boolean test(Object receiver, String property, Object[] args,
22
			Object expectedValue) {
23
		if (receiver instanceof TaxonNode && HAS_SYNONYMS.equals(property)) {
24
			Taxon taxon = ((TaxonNode) receiver).getTaxon();
25
			if(taxon != null){
26
				return taxon.hasSynonyms();
27
			}
28
		}
29

    
30
		if (receiver instanceof Classification && HAS_TAXA.equals(property)) {
31
			Classification taxononomicTree = (Classification) receiver;
32
			return taxononomicTree.getChildNodes().size() > 0;
33
		}
34
		
35
		return false;
36
	}
37
}
(14-14/14)