private static boolean isEntity(java.lang.reflect.Field field) { TypeInformation typeInformation = ClassTypeInformation.from(field.getType()); TypeInformation<?> actualType = typeInformation.getActualType(); boolean isComplexType = actualType == null ? false : !SIMPLE_TYPE_HOLDER.isSimpleType(actualType.getType()); return isComplexType && !actualType.isCollectionLike() && !Map.class.isAssignableFrom(typeInformation.getType()); }
/** * Adds custom type information to the given {@link DBObject} if necessary. That is if the value * is not the same as the one given. This is usually the case if you store a subtype of the actual * declared type of the property. * * @param type * @param value must not be {@literal null}. * @param dbObject must not be {@literal null}. */ protected void addCustomTypeKeyIfNecessary( TypeInformation<?> type, Object value, DBObject dbObject) { TypeInformation<?> actualType = type != null ? type.getActualType() : null; Class<?> reference = actualType == null ? Object.class : actualType.getType(); Class<?> valueType = ClassUtils.getUserClass(value.getClass()); boolean notTheSameClass = !valueType.equals(reference); if (notTheSameClass) { typeMapper.writeType(valueType, dbObject); } }
/** * Configures the {@link JsonSchemaProperty} to reflect the given type. * * @param type must not be {@literal null}. * @return */ public JsonSchemaProperty with(TypeInformation<?> type) { Assert.notNull(type, "Type must not be null!"); this.type = toJsonSchemaType(type); if (isDate(type)) { return withFormat(JsonSchemaFormat.DATE_TIME); } if (type.isCollectionLike()) { if (Set.class.equals(type.getType())) { this.uniqueItems = true; } this.items = Collections.singletonMap("type", toJsonSchemaType(type.getActualType())); } return this; }
static String typeKey(TypeInformation<?> type) { return StringUtils.uncapitalize(type.getActualType().getType().getSimpleName()); }
/** * Creates a new {@link Item} for the given {@link TypeInformation} and properties. * * @param type must not be {@literal null}. * @param properties must not be {@literal null}. */ public Item(TypeInformation<?> type, Collection<AbstractJsonSchemaProperty<?>> properties) { this.type = toJsonSchemaType(type.getActualType()); this.properties = new PropertiesContainer(properties); }