/** * Create a new {@link PathProperty} from given <code>path</code>, using given {@link Path} <code>name</code> and * <code>type</code>. * @param <T> Property (path) type * @param path Path from which to obtain the property path name and type (not null) * @return {@link PathProperty} builder */ static <T> PathPropertyBuilder<T> create(Path<T> path) { ObjectUtils.argumentNotNull(path, "Path must be not null"); PathPropertyBuilder<T> builder = create(path.getName(), path.getType()); path.getParent().ifPresent(p -> builder.parent(p)); return builder; }
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[] }
/** * Create a new {@link PathProperty} with given <code>name</code> and <code>type</code>, setting this * {@link DataTarget} as property parent path. * @param <P> Property type * @param name Property name (not null) * @param type Property value type (not null) * @return Property builder */ default <P> PathPropertyBuilder<P> property(String name, Class<? extends P> type) { return PathProperty.<P>create(name, type).parent(this); }
public void dataMappable1() { // tag::datamappable1[] PathProperty<Integer> property = PathProperty.create("name", Integer.class) // .dataPath("mapping-name"); // <1> Optional<String> mapping = property.getDataPath(); // <2> // end::datamappable1[] }