Project

General

Profile

Revision 1ebbb842

ID1ebbb842d5cce478b1385de7c8f5be4b5c040c83
Parent 0df7271b
Child 1a4fdfe5

Added by Patrick Plitzner over 2 years ago

ref #8190 Allow sub term types for FeatureNode relations and trees

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/FeatureNode.java
220 220
	}
221 221

  
222 222
	protected void setFeatureTree(FeatureTree<T> featureTree) {
223
		checkTermType(featureTree);
223
	    IHasTermType.checkTermTypeNull(featureTree);
224
        if (this.getTermType() != featureTree.getTermType()
225
                && !this.getTermType().isKindOf(featureTree.getTermType())){
226
            throw new IllegalArgumentException("Term types must match");
227
        }
224 228
	    this.featureTree = featureTree;
225 229
	}
226 230

  
......
236 240
     * @see #getFeature()
237 241
     */
238 242
    public void setTerm(T term) {
239
        checkTermType(term);
243
        checkEqualTermType(term);
240 244
        this.feature = term;
241 245
    }
242 246

  
......
260 264
	 * @see				#getParent()
261 265
	 */
262 266
	protected void setParent(FeatureNode<T> parent) {
263
		checkTermType(parent);
267
	    checkTermType(parent);
264 268
	    this.parent = parent;
265 269
	}
266 270

  
......
570 574
     * term has not the same term type as this term or if term type is null.
571 575
     * @param term
572 576
     */
573
    private void checkTermType(IHasTermType term) {
577
    private void checkEqualTermType(IHasTermType term) {
574 578
        IHasTermType.checkTermTypes(term, this);
575 579
    }
576 580

  
581
    /**
582
     * Throws {@link IllegalArgumentException} if the given
583
     * term has not the same term type as this term or if it is no sub or super type
584
     * or if term type is null.
585
     * @param term
586
     */
587
    private void checkTermType(IHasTermType term) {
588
        IHasTermType.checkTermTypeNull(term);
589
        if (this.getTermType() != term.getTermType()
590
                && !this.getTermType().isKindOf(term.getTermType())
591
                && !term.getTermType().isKindOf(this.getTermType())){
592
            throw new IllegalArgumentException("Term types must match");
593
        }
594
    }
595

  
577 596
	/**
578 597
	 * Returns all terms that are contained in this node or a child node
579 598
	 *

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)