/** * Provide access to the entity's type. * * @param entity * @return * @throws ClassCastException * if entity is not an instance of {@link DynamicEntityImpl} */ public static DynamicType getType(DynamicEntity entity) throws ClassCastException { return ((DynamicEntityImpl) entity).getType(); }
/** * Provide access to the entity's type. * * @param entity * @return * @throws ClassCastException * if entity is not an instance of {@link DynamicEntityImpl} */ public static DynamicType getType(DynamicEntity entity) throws ClassCastException { return ((DynamicEntityImpl) entity).getType(); }
/** * Provide access to the entity's type. * * @param entity * @return * @throws ClassCastException * if entity is not an instance of {@link DynamicEntityImpl} */ public static DynamicType getType(DynamicEntity entity) throws ClassCastException { return ((DynamicEntityImpl) entity).getType(); }
public boolean isSet(String propertyName) { return isSet(getType().getMapping(propertyName)); }
@Override public String marshal(Object v) throws Exception { if (null == v) { return null; } String href = null; String version = context.getVersion(); if (version != null) { href = baseURI + version + "/" + context.getName() + "/entity/" + v.getClass().getSimpleName() + "/" + IdHelper.stringifyId((DynamicEntityImpl) v, ((DynamicEntityImpl) v).getType().getName(), context); } else { href = baseURI + context.getName() + "/entity/" + v.getClass().getSimpleName() + "/" + IdHelper.stringifyId((DynamicEntityImpl) v, ((DynamicEntityImpl) v).getType().getName(), context); } return href; } }
@Override public String marshal(Object v) throws Exception { if (null == v) { return null; } String href = null; String version = context.getVersion(); if (version != null) { href = baseURI + version + "/" + context.getName() + "/entity/" + v.getClass().getSimpleName() + "/" + IdHelper.stringifyId((DynamicEntityImpl) v, ((DynamicEntityImpl) v).getType().getName(), context); } else { href = baseURI + context.getName() + "/entity/" + v.getClass().getSimpleName() + "/" + IdHelper.stringifyId((DynamicEntityImpl) v, ((DynamicEntityImpl) v).getType().getName(), context); } return href; } }
public DynamicEntity set(String propertyName, Object value) { DatabaseMapping mapping = getType().getMapping(propertyName); checkSetType(mapping, value); Object currentValue = mapping.getAttributeValueFromObject(this); if (currentValue instanceof ValueHolderInterface) { ((ValueHolderInterface) currentValue).setValue(value); } else { mapping.setAttributeValueInObject(this, value); } return this; }
@SuppressWarnings("unchecked") public <T> T get(String propertyName) { DatabaseMapping mapping = getType().getMapping(propertyName); Object value = mapping.getAttributeValueFromObject(this); if (mapping.isForeignReferenceMapping() && mapping.isLazy()) { // Force basic indirection to be instantiated if (value instanceof ValueHolderInterface) { value = ((ValueHolderInterface) value).getValue(); } // Force transparent indirection to be instantiated if (value instanceof IndirectContainer) { ((IndirectContainer) value).getValueHolder().getValue(); } } try { return (T) value; } catch (ClassCastException cce) { throw DynamicException.invalidGetPropertyType(mapping, cce); } }
return (T) value; } catch (ClassCastException cce) { ClassDescriptor descriptor = getType().getDescriptor(); DatabaseMapping dm = null; if (descriptor != null) {
return (T) value; } catch (ClassCastException cce) { ClassDescriptor descriptor = getType().getDescriptor(); DatabaseMapping dm = null; if (descriptor != null) {