public boolean add(int i, EntityReference entityReference) {
    if (references.contains(entityReference)) {
      return false;
    }

    references.add(i, entityReference);
    unitOfWork.addManyAssociation(identity, stateName, i, entityReference);
    return true;
  }
 public boolean remove(EntityReference entity) {
   boolean removed = references.remove(entity);
   unitOfWork.removeManyAssociation(identity, stateName, entity);
   return removed;
 }
 public void setProperty(StateName stateName, String newValue) {
   properties.put(stateName, newValue);
   unitOfWork.setProperty(identity, stateName, newValue);
 }
 public void removeEntityTypeReference(EntityTypeReference entityTypeReference) {
   entityTypes.remove(entityTypeReference);
   unitOfWork.removeEntityType(identity, entityTypeReference);
 }
 public void addEntityTypeReference(EntityTypeReference entityType) {
   entityTypes.add(entityType);
   unitOfWork.addEntityType(identity, entityType);
 }
 public void remove() {
   status = EntityStatus.REMOVED;
   unitOfWork.removeEntityState(identity);
 }
 public void refresh() {
   if (status == EntityStatus.LOADED) {
     unitOfWork.refresh(this);
   }
 }
 public void setAssociation(StateName stateName, EntityReference newEntity) {
   associations.put(stateName, newEntity);
   unitOfWork.setAssociation(identity, stateName, newEntity);
 }