List of usage examples for org.springframework.data.util TypeInformation getProperty
@Nullable TypeInformation<?> getProperty(String property);
From source file:org.lightadmin.core.config.bootstrap.parsing.validation.TransientFieldMetadataValidator.java
@Override public Collection<? extends DomainConfigurationProblem> validateFieldMetadata( TransientFieldMetadata fieldMetadata, Class<?> domainType, DomainConfigurationValidationContext validationContext) { final String propertyPath = fieldMetadata.getProperty(); if (isBlank(propertyPath)) { return newArrayList(validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); }//from w w w .j a v a 2s. c o m final List<String> properties = properties(propertyPath); if (properties.isEmpty()) { return newArrayList(validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); } final TypeInformation<?> typeInformation = ClassTypeInformation.from(domainType); final Iterator<String> propertiesIterator = properties.iterator(); StringBuilder currentPropertyPath = null; while (propertiesIterator.hasNext()) { if (currentPropertyPath == null) { currentPropertyPath = new StringBuilder(propertiesIterator.next()); } else { currentPropertyPath.append(PROPERTY_SEPARATOR).append(propertiesIterator.next()); } if (typeInformation.getProperty(currentPropertyPath.toString()) == null) { return newArrayList( validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); } } return emptyList(); }
From source file:org.springframework.data.mapping.PropertyPath.java
/** * Creates a leaf {@link PropertyPath} (no nested ones with the given name and owning type. * /*from w ww .j a v a 2 s . co m*/ * @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); Assert.notNull(owningType); String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name); boolean isSpecli = org.apache.commons.lang3.StringUtils.contains(propertyName, "*"); String _propertyName = isSpecli ? propertyName.replaceAll("\\*(.*)", org.apache.commons.lang3.StringUtils.EMPTY) : propertyName; if (propertyName.startsWith("iF")) { _propertyName = "name"; } TypeInformation<?> propertyType = owningType.getProperty(_propertyName); if (!isSpecli) { if (propertyType == null) { throw new PropertyReferenceException(propertyName, owningType, base); } } else { if (true) { //for debug } } this.owningType = owningType; this.isCollection = propertyType == null ? false : propertyType.isCollectionLike(); if (propertyType == null) { throw new PropertyReferenceException(_propertyName, owningType, base); } this.type = propertyType.getActualType(); this.name = propertyName; }