@Override public void elementUpdated(ContextEvent event) { AbstractEntity.this.notifyElementUpdated(ContextEvent.ATTINSTANCE_UPDATED, event); } }
@Override public void elementUpdated(ContextEvent event) { AbstractEntity.this.notifyElementUpdated(ContextEvent.RELINSTANCE_UPDATED, event); } }
/** * {@inheritDoc} */ @Override public <A extends Attribute> A removeAttributeInstance(Class<A> attribute) { synchronized (attributesInstancesLock) { A ai = (A) attributesInstances.remove(attribute); if (ai != null) { ai.removeObserver(attsInstancesObserver); this.notifyElementUpdated(ContextEvent.ATTINSTANCE_REMOVED, ai); } return ai; } }
/** * {@inheritDoc} */ @Override public <R extends Relationship> R removeRelationshipInstance(Class<R> relationship) { synchronized (relationshipsInstancesLock) { R ri = (R) relationshipsInstances.remove(relationship); if (ri != null) { ri.removeObserver(relsInstancesObserver); this.notifyElementUpdated(ContextEvent.RELINSTANCE_REMOVED, ri); } return ri; } }
/** * {@inheritDoc} */ @Override public void removeAllRelationshipsInstances() { synchronized (relationshipsInstancesLock) { if (!relationshipsInstances.isEmpty()) { Map<Class<? extends Relationship>, Relationship> oldRelInstances = getAllRelationshipsInstances(); for (Relationship ri : oldRelInstances.values()) ri.removeObserver(relsInstancesObserver); relationshipsInstances.clear(); this.notifyElementUpdated(ContextEvent.ALL_RELINSTANCES_REMOVED, oldRelInstances); } } }
/** * {@inheritDoc} */ @Override public void removeAllAttributesInstances() { synchronized (attributesInstancesLock) { if (!attributesInstances.isEmpty()) { Map<Class<? extends Attribute>, Attribute> oldAttInstances = getAllAttributesInstances(); for (Attribute ai : oldAttInstances.values()) ai.removeObserver(attsInstancesObserver); attributesInstances.clear(); this.notifyElementUpdated(ContextEvent.ALL_ATTINSTANCES_REMOVED, oldAttInstances); } } }
/** * {@inheritDoc} */ @Override public <A extends Attribute> A putAttributeInstance(A attributeInstance) { synchronized (attributesInstancesLock) { if (attributeInstance.getEntity() != this) throw new IllegalArgumentException("attributeInstance " + attributeInstance + " not compatible with " + this); A oldAttInstance = (A) attributesInstances.put(attributeInstance.getClass(), attributeInstance); if (attributeInstance != oldAttInstance) { attributeInstance.addObserver(attsInstancesObserver); this.notifyElementUpdated(ContextEvent.ATTINSTANCE_PUT, attributeInstance); } return oldAttInstance; } }
/** * {@inheritDoc} */ @Override public <R extends Relationship> R putRelationshipInstance(R relationshipInstance) { synchronized (relationshipsInstancesLock) { if (relationshipInstance.getSourceEntity() != this) throw new IllegalArgumentException("relationshipInstance " + relationshipInstance + " not compatible with " + this); R oldRelInstance = (R) relationshipsInstances.put(relationshipInstance.getClass(), relationshipInstance); if (relationshipInstance != oldRelInstance) { relationshipInstance.addObserver(relsInstancesObserver); this.notifyElementUpdated(ContextEvent.RELINSTANCE_PUT, relationshipInstance); } return oldRelInstance; } }