@Override public <T> boolean containsValue(Path<T> path) { return getProperty(path).map(p -> getPropertyBox().containsValue(p)).orElse(false); }
/** * Get the value of given <code>property</code> using given <code>propertyBox</code>. * @param <T> Property type * @param propertyBox The PropertyBox value (may be null) * @param property The property for which to obtain the value * @return Optional property value, empty if the given PropertyBox was <code>null</code> */ protected <T> Optional<T> getPropertyValue(PropertyBox propertyBox, Property<T> property) { if (propertyBox != null) { // check vitual property if (VirtualProperty.class.isAssignableFrom(property.getClass())) { if (((VirtualProperty<T>) property).getValueProvider() != null) { return Optional.ofNullable( ((VirtualProperty<T>) property).getValueProvider().getPropertyValue(propertyBox)); } return null; } // get the property value if (propertyBox.containsValue(property)) { return Optional.ofNullable(propertyBox.getValue(property)); } } return Optional.empty(); }
/** * Get the value of given <code>property</code> using given <code>propertyBox</code>. * @param <T> Property type * @param propertyBox PropertyBox * @param property Property * @return Property value */ protected <T> T getPropertyValue(PropertyBox propertyBox, Property<T> property) { if (VirtualProperty.class.isAssignableFrom(property.getClass())) { if (((VirtualProperty<T>) property).getValueProvider() != null) { return ((VirtualProperty<T>) property).getValueProvider().getPropertyValue(propertyBox); } return null; } if (propertyBox.containsValue(property)) { return propertyBox.getValue(property); } return null; }
/** * Get the value of given <code>property</code> using given <code>propertyBox</code>. * @param <T> Property type * @param propertyBox PropertyBox * @param property Property * @return Property value */ protected <T> T getPropertyValue(PropertyBox propertyBox, Property<T> property) { if (VirtualProperty.class.isAssignableFrom(property.getClass())) { if (((VirtualProperty<T>) property).getValueProvider() != null) { return ((VirtualProperty<T>) property).getValueProvider().getPropertyValue(propertyBox); } return null; } if (propertyBox.containsValue(property)) { return propertyBox.getValue(property); } return null; }
if (oid != null) { boolean idPropertyHasValue = documentContext.getDocumentIdProperty().map(p -> value.containsValue(p)) .orElse(false);
public void propertyBox() { // tag::propertybox[] final PathProperty<Long> ID = PathProperty.create("id", Long.class); final StringProperty NAME = StringProperty.create("name"); final PropertySet<?> PROPERTIES = PropertySet.of(ID, NAME); PropertyBox propertyBox = PropertyBox.create(ID, NAME); // <1> propertyBox = PropertyBox.create(PROPERTIES); // <2> propertyBox.setValue(ID, 1L); // <3> propertyBox.setValue(NAME, "testName"); // <4> propertyBox = PropertyBox.builder(PROPERTIES).set(ID, 1L).set(NAME, "testName").build(); // <5> Long id = propertyBox.getValue(ID); // <6> String name = propertyBox.getValueIfPresent(NAME).orElse("default"); // <7> boolean containsNotNullId = propertyBox.containsValue(ID); // <8> PropertyBox ids = propertyBox.cloneBox(ID); // <9> // end::propertybox[] }