public void collectionProperties2() { // tag::collprops2[] final ListPathProperty<String> STR = ListPathProperty.create("str", String.class) // <1> .elementConverter(Integer.class, v -> String.valueOf(v), v -> Integer.valueOf(v)); // <2> // end::collprops2[] }
/** * Create a new {@link PropertyBox} type {@link ListPathProperty}, using given <code>properties</code> as property * set. * @param <P> Property type * @param name Property (and path) name (not null) * @param properties Property set (not null) * @return a new {@link ListPathProperty} instance */ @SuppressWarnings("rawtypes") static <P extends Property> ListPathPropertyBuilder<PropertyBox> propertyBox(String name, Iterable<P> properties) { ObjectUtils.argumentNotNull(properties, "Properties must be not null"); return create(name, PropertyBox.class).withConfiguration(PropertySet.PROPERTY_CONFIGURATION_ATTRIBUTE, (properties instanceof PropertySet) ? (PropertySet<?>) properties : PropertySet.of(properties)); }
public void collectionProperties() { // tag::collprops[] final ListPathProperty<String> STR = ListPathProperty.create("str", String.class); // <1> final SetPathProperty<Integer> ITG = SetPathProperty.create("str", Integer.class); // <2> Class<?> elementType = STR.getElementType(); // <3> PropertyBox box = PropertyBox.create(STR, ITG); box.setValue(STR, Collections.singletonList("a")); // <4> List<String> listValue = box.getValue(STR); // <5> box.setValue(ITG, Collections.singleton(1)); // <6> Set<Integer> setValue = box.getValue(ITG); // <7> // end::collprops[] }