+ Property.class.getName() + "] type"); PropertyBox.Builder box = PropertyBox.builder(ps).invalidAllowed(true); for (Property property : ps) { com.vaadin.data.Property<?> itemProperty = item.getItemProperty(property);
@SuppressWarnings("unchecked") @Override @Deprecated public O add(Map<Path<?>, Object> values) { if (values != null && !values.isEmpty()) { final PropertySet<?> propertySet = getDefinition().getPropertySet().orElse(asPropertySet(values.keySet())); final PropertyBox propertyBox = PropertyBox.builder(propertySet).invalidAllowed(true).build(); final PathPropertySetAdapter adapter = PathPropertySetAdapter.create(propertySet); for (Entry<Path<?>, Object> entry : values.entrySet()) { adapter.getProperty(entry.getKey()).ifPresent(p -> { if (entry.getValue() != null) { propertyBox.setValue((Property<Object>) p, entry.getValue()); } }); } getDefinition().addValue(propertyBox); return getActualOperation(); } return getActualOperation(); }
final PropertyBox.Builder builder = PropertyBox.builder(propertySet).invalidAllowed(true);
final PropertyBox.Builder builder = PropertyBox.builder(propertySet).invalidAllowed(true); final PathPropertySetAdapter adapter = PathPropertySetAdapter.create(propertySet); for (Property property : propertySet) {
/** * Decode a document into a {@link PropertyBox} value using given property set. * @param context Resolution context * @param parent Optional parent field name expression * @param document Document to decode * @return Decoded PropertyBox instance * @throws InvalidExpressionException If an error occurred */ private static PropertyBox decodePropertyBox(final MongoDocumentContext<?> context, final String parent, Map<String, Object> document) throws InvalidExpressionException { // PropertyBox builder final PropertyBox propertyBox = PropertyBox.builder(context.getPropertySet()).invalidAllowed(true).build(); // Adapter final PathPropertyBoxAdapter adapter = PathPropertyBoxAdapter.builder(propertyBox) .pathMatcher(DocumentPathMatcher.INSTANCE).build(); // decode decodeDocument(context, parent, document, propertyBox, adapter); return propertyBox; }
/** * Clone this PropertyBox using given <code>propertySet</code>, i.e. create a new PropertyBox and copy all given set * property values from this box to the newly created box. * @param <P> Actual property type * @param propertySet Property set of the cloned PropertyBox (not null) * @return A new, cloned, PropertyBox instance with given property set */ @SuppressWarnings("unchecked") default <P extends Property> PropertyBox cloneBox(PropertySet<P> propertySet) { ObjectUtils.argumentNotNull(propertySet, "Property set must be not null"); Builder builder = builder(propertySet).invalidAllowed(true); propertySet.forEach(p -> { if (!p.isReadOnly()) { this.getValueIfPresent(p).ifPresent(v -> builder.set(p, v)); } }); return builder.invalidAllowed(this.isInvalidAllowed()).build(); }
/** * Read the property values from given bean instance into a {@link PropertyBox} with this property set. * <p> * By default, the created PropertyBox allows invalid values, so no property value validation is performed. * </p> * <p> * Any {@link PropertyValueConverter} will be applied to read values from bean data model. * </p> * @param instance Bean instance from which read the property values (not null) * @return The PropertyBox containing the property values read from the given bean instance * @throws PropertyAccessException Error accessing bean properties */ default PropertyBox read(T instance) { return read(PropertyBox.builder(this).invalidAllowed(true).build(), instance, false); }
@SuppressWarnings("unchecked") @Override public <T> PropertyBox read(T instance) { ObjectUtils.argumentNotNull(instance, "Bean instance must be not null"); BeanPropertySet<T> propertySet = getPropertySet((Class<T>) instance.getClass()); return propertySet.read(PropertyBox.builder(propertySet).invalidAllowed(true).build(), instance); }
@Override public PropertyBox getValue(boolean validate) { final PropertyBox value = (getCurrentValue() != null) ? getCurrentValue() : PropertyBox.builder(getPropertySet()).invalidAllowed(true).build(); flush(value, validate); return value; }
/** * Clone this PropertyBox, i.e. create a new PropertyBox with same property set of this box and copy all the * property values from this box to the newly created box. * @return A new, cloned, PropertyBox instance */ default PropertyBox cloneBox() { return builder(this).invalidAllowed(this.isInvalidAllowed()).copyValues(this).build(); }
public void propertyBox2() { // tag::propertybox2[] final PathProperty<Long> ID = PathProperty.create("id", Long.class).withValidator(Validator.notNull()); // <1> final StringProperty NAME = StringProperty.create("name").withValidator(Validator.notBlank()); // <2> final PropertySet<?> PROPERTIES = PropertySet.of(ID, NAME); PropertyBox propertyBox = PropertyBox.create(PROPERTIES); propertyBox.setValue(ID, null); // <3> propertyBox = PropertyBox.builder(PROPERTIES).invalidAllowed(true).build(); // <4> propertyBox.validate(); // <5> // end::propertybox2[] }
@Override public PropertyBox getValue(boolean validate) { PropertyBox value = PropertyBox.builder(propertySet).invalidAllowed(!validate).build(); flush(value, validate); return value; }