}
public static Entity createEntityInstanceFromParent(
Field idField, ClassInfo info, Object obj,
Key parentKey, ClassInfo parentInfo, Field parentField){
Entity entity = null;
Id id = idField.getAnnotation(Id.class);
Class<?> type = idField.getType();
if(id != null){
switch(id.value()) {
case NONE:
Object idVal = null;
idVal = Util.readField(obj, idField);
if(idVal == null)
throw new SienaException("Id Field " + idField.getName() + " value null");
String keyVal = Util.toString(idField, idVal);
entity = new Entity(getKindWithAncestorField(info, parentInfo, parentField), keyVal, parentKey);
break;
case AUTO_INCREMENT:
// manages String ID as not long!!!
if(Long.TYPE == type || Long.class.isAssignableFrom(type)){
entity = new Entity(getKindWithAncestorField(info, parentInfo, parentField), parentKey);
}else {
Object idStringVal = null;
idStringVal = Util.readField(obj, idField);
if(idStringVal == null)
throw new SienaException("Id Field " + idField.getName() + " value null");
String keyStringVal = Util.toString(idField, idStringVal);
entity = new Entity(getKindWithAncestorField(info, parentInfo, parentField), keyStringVal, parentKey);
}
break;
case UUID:
entity = new Entity(getKindWithAncestorField(info, parentInfo, parentField), UUID.randomUUID().toString(), parentKey);
break;
default:
throw new SienaRestrictedApiException("DB", "createEntityInstance", "Id Generator "+id.value()+ " not supported");
}
}