@Override public void setValue(Object entity, Object value) { EntityType<Object> entityType = BeanLocator.getInstance().getInstance(EntityTypeRepository.class).getEntityType(entity); MapAttribute attribute = (MapAttribute) entityType.getAttribute(property); if (attribute != null) { attribute.putElement(entity, key, value); } }
@Override public Object getValue(Object entity) { EntityType<Object> entityType = BeanLocator.getInstance().getInstance(EntityTypeRepository.class).getEntityType(entity); MapAttribute attribute = (MapAttribute) entityType.getAttribute(property); if (attribute == null) { return null; } else { return attribute.getElement(entity, key); } }
@Override public J getValue(Object entity) { J value = null; if (entity instanceof JavaMetaData) { value = ((JavaMetaData) entity).getAnnotation(annotationType.getJavaType()); } if (value == null) { Attribute metaAttribute = attributeType.getMetaAttribute(DerivedObject.META_ATTRIBUTE_CODE); if (metaAttribute != null) { DerivedObject derivedObject = (DerivedObject) metaAttribute.getValue(entity); if (derivedObject != null) { Object original = derivedObject.getOriginal(); if (original != null) { return getValue(original); } } } } return value; }
@Override public Serializable[] getKeys(Object entity) { EntityType<Object> entityType = entityTypeRepository.getEntityType(entity); IdentityService service = entityType.getService(IdentityService.class); return new Serializable[] {entityType.getCode(), service.getId(entityType, entity)}; }
@Override public <E> Serializable getId(EntityType<E> entityType, E entity) { return (Serializable) entityType.getAttribute(attributeCode).getValue(entity); }
@Override public Class<J> getReturnType() { return (Class<J>) annotationType.getJavaType(); }
@Override public String getCode() { return annotationType.getJavaType().getName().replace(".", "_"); }