protected void assignType(PropertyDescriptor prop, FieldImpl field, io.github.ibuildthecloud.gdapi.annotation.Field f) { if (f.type() != FieldType.NONE) { field.setTypeEnum(f.type()); return; } if (!StringUtils.isEmpty(f.typeString())) { field.setType(f.typeString()); return; } if (f.password()) { field.setTypeEnum(FieldType.PASSWORD); return; } assignSimpleType(prop.getPropertyType(), field); List<TypeAndName> types = new ArrayList<FieldType.TypeAndName>(); Method readMethod = prop.getReadMethod(); if (readMethod != null) { getTypes(readMethod.getGenericReturnType(), types); } if (types.size() == 1) { field.setType(types.get(0).getName()); } else if (types.size() > 1) { types.remove(0); field.setSubTypesList(types); } }
fieldImpl.setType(FieldType.toString(FieldType.REFERENCE, factory.getSchema(relationship.getObjectType()).getId()));
public FieldImpl(Field field) { this.name = field.getName(); this.description = field.getDescription(); this.validChars = field.getValidChars(); this.invalidChars = field.getInvalidChars(); this.create = field.isCreate(); this.readOnCreateOnly = field.isReadOnCreateOnly(); this.transform = field.getTransform(); this.update = field.isUpdate(); this.includeInList = field.isIncludeInList(); this.nullable = field.isNullable(); this.unique = field.isUnique(); this.required = field.isRequired(); this.min = field.getMin(); this.max = field.getMax(); this.minLength = field.getMinLength(); this.maxLength = field.getMaxLength(); this.defaultValue = field.getDefault(); this.options = field.getOptions() == null ? null : new ArrayList<String>(field.getOptions()); this.displayIndex = field.getDisplayIndex(); this.attributes = new HashMap<String, Object>(field.getAttributes()); if (field instanceof FieldImpl) { this.readMethod = ((FieldImpl)field).getReadMethod(); this.defaultIsNull = ((FieldImpl)field).isDefaultIsNull(); } setType(field.getType()); }