/** * Checks whether given property is a {@link CollectionProperty} of {@link PropertyBox} type. * @param property The property to check * @return whether given property is a {@link CollectionProperty} of {@link PropertyBox} type */ private static boolean isPropertyBoxCollectionProperty(Property<?> property) { return (CollectionProperty.class.isAssignableFrom(property.getClass()) && PropertyBox.class.isAssignableFrom(((CollectionProperty<?, ?>) property).getElementType())); }
.filter(p -> CollectionProperty.class.isAssignableFrom(p.getClass())) .map(p -> (CollectionProperty<?, ?>) p) .filter(cp -> PropertyBox.class.isAssignableFrom(cp.getElementType())) .map(cp -> (CollectionProperty<PropertyBox, Collection<PropertyBox>>) cp).orElse(null); if (collectionProperty != null) { final PropertySet<?> propertySet = collectionProperty.getConfiguration() .getParameter(PropertySet.PROPERTY_CONFIGURATION_ATTRIBUTE) .orElseThrow(() -> new InvalidExpressionException(
private static <T, P extends Path<T> & Property<T>> boolean isPropertyBoxCollectionProperty(P property, T value) { return (CollectionProperty.class.isAssignableFrom(property.getClass()) && PropertyBox.class.isAssignableFrom(((CollectionProperty<?, ?>) property).getElementType()) && Collection.class.isAssignableFrom(value.getClass())); }
@Override public String present(Property<T> property, T value) { ObjectUtils.argumentNotNull(property, "Property must be not null"); // check TemporalType ParameterSet.Builder<?> builder = ParameterSet.builder().withParameters(property.getConfiguration()); property.getConfiguration().getTemporalType() .ifPresent(t -> builder.withParameter(StringValuePresenter.TEMPORAL_TYPE, t)); final ParameterSet parameters = builder.build(); // check collection property if (value != null && CollectionProperty.class.isAssignableFrom(property.getClass()) && Collection.class.isAssignableFrom(value.getClass())) { final Class<?> elementType = ((CollectionProperty<?, ?>) property).getElementType(); return ((Collection<?>) value).stream().map(v -> presentValue(elementType, v, parameters)) .collect(Collectors.joining(",")); } // default presentation return presentValue(property.getType(), value, parameters); }
Class<?> type = collection ? ((CollectionProperty<?, ?>) property).getElementType() : property.getType();