Project

General

Profile

Revision b06d238e

IDb06d238e73643956e6dcb860a220adae90a46904
Parent 4dda23ea
Child 958bbf47

Added by Andreas Müller about 1 year ago

ref #7446 add extension already exists check to IdentifiableEntity

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java
428 428
    /**
429 429
     * @param extensionTypeUuid
430 430
     * @return a Set of extension value strings
431
     * @see #hasExtension(UUID, String)
431 432
     */
432 433
    public Set<String> getExtensions(UUID extensionTypeUuid){
433 434
        Set<String> result = new HashSet<>();
......
449 450
        return result;
450 451
    }
451 452

  
453
    /**
454
     * Has this entity an extension of given type with value 'value'.
455
     * If value is <code>null</code> <code>true</code> is returned if
456
     * an Extension exists with given type and 'value' is <code>null</code>.
457
     * @param extensionTypeUuid
458
     * @param value
459
     * @see #hasExtension(ExtensionType, String)
460
     * @see #getExtensions(UUID)
461
     */
462
    public boolean hasExtension(UUID extensionTypeUuid, String value) {
463
        for (String ext : this.getExtensions(extensionTypeUuid)){
464
            if (CdmUtils.nullSafeEqual(ext, value)){
465
                return true;
466
            }
467
        }
468
        return false;
469
    }
470

  
471
    /**
472
     * @see #hasExtension(UUID, String)
473
     */
474
    public boolean hasExtension(ExtensionType extensionType, String value) {
475
        return hasExtension(extensionType.getUuid(), value);
476
    }
477

  
452 478
    @Override
453 479
    public void addExtension(String value, ExtensionType extensionType){
454 480
        Extension.NewInstance(this, value, extensionType);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)