@Nullable public TypeInformation<?> getProperty(String fieldname) { int separatorIndex = fieldname.indexOf('.'); if (separatorIndex == -1) { return fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation).orElse(null); } String head = fieldname.substring(0, separatorIndex); TypeInformation<?> info = getProperty(head); if (info == null) { return null; } return info.getProperty(fieldname.substring(separatorIndex + 1)); }
public TypeInformation<?> getProperty(String fieldname) { int separatorIndex = fieldname.indexOf('.'); if (separatorIndex == -1) { if (fieldTypes.containsKey(fieldname)) { return fieldTypes.get(fieldname); } TypeInformation<?> propertyInformation = getPropertyInformation(fieldname); if (propertyInformation != null) { fieldTypes.put(fieldname, propertyInformation); } return propertyInformation; } String head = fieldname.substring(0, separatorIndex); TypeInformation<?> info = fieldTypes.get(head); return info == null ? null : info.getProperty(fieldname.substring(separatorIndex + 1)); }
/** * Returns the property information for the property with the given name or throw {@link IllegalArgumentException} if * the type information cannot be resolved. Supports property traversal through dot notation. * * @param property * @return * @throws IllegalArgumentException if the type information cannot be resolved. * @since 2.0 */ default TypeInformation<?> getRequiredProperty(String property) { TypeInformation<?> typeInformation = getProperty(property); if (typeInformation != null) { return typeInformation; } throw new IllegalArgumentException( String.format("Could not find required property %s on %s!", property, getType())); }
public AbstractPersistentProperty(Field field, PropertyDescriptor propertyDescriptor, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) { Assert.notNull(field); Assert.notNull(simpleTypeHolder); Assert.notNull(owner); this.name = field.getName(); this.rawType = field.getType(); this.information = owner.getTypeInformation().getProperty(this.name); this.propertyDescriptor = propertyDescriptor; this.field = field; this.association = isAssociation() ? createAssociation() : null; this.owner = owner; this.simpleTypeHolder = simpleTypeHolder; }
/** * Creates a leaf {@link PropertyPath} (no nested ones with the given name and owning type. * * @param name must not be {@literal null} or empty. * @param owningType must not be {@literal null}. * @param base the {@link PropertyPath} previously found. */ PropertyPath(String name, TypeInformation<?> owningType, List<PropertyPath> base) { Assert.hasText(name, "Name must not be null or empty!"); Assert.notNull(owningType, "Owning type must not be null!"); Assert.notNull(base, "Perviously found properties must not be null!"); String propertyName = Introspector.decapitalize(name); TypeInformation<?> propertyType = owningType.getProperty(propertyName); if (propertyType == null) { throw new PropertyReferenceException(propertyName, owningType, base); } this.owningType = owningType; this.typeInformation = propertyType; this.isCollection = propertyType.isCollectionLike(); this.name = propertyName; this.actualTypeInformation = propertyType.getActualType() == null ? propertyType : propertyType.getRequiredActualType(); }
/** * Creates a leaf {@link PropertyPath} (no nested ones with the given name and owning type. * * @param name must not be {@literal null} or empty. * @param owningType must not be {@literal null}. * @param base the {@link PropertyPath} previously found. */ PropertyPath(String name, TypeInformation<?> owningType, PropertyPath base) { Assert.hasText(name); Assert.notNull(owningType); String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name); TypeInformation<?> type = owningType.getProperty(propertyName); if (type == null) { throw new PropertyReferenceException(propertyName, owningType, base); } this.owningType = owningType; this.isCollection = type.isCollectionLike(); this.type = type.getActualType(); this.name = propertyName; }