/** * Parses the JSON representation for a property value and creates the property value directly. * * @see #fromStorage(JsonNode) * @see #of(Object) */ default Property<T> of(JsonNode node) { return of(fromStorage(node)); }
@Override public <T> Collection<ProjectEntity> searchWithPropertyValue( Class<? extends PropertyType<T>> propertyTypeClass, BiFunction<ProjectEntityType, ID, ProjectEntity> entityLoader, Predicate<T> predicate) { // Gets the property type String propertyTypeName = propertyTypeClass.getName(); PropertyType<T> propertyType = getPropertyTypeByName(propertyTypeName); // Search return propertyRepository.searchByProperty( propertyTypeName, entityLoader, t -> predicate.test(propertyType.fromStorage(t.getJson())) ); }
protected <T> T getPropertyValue(PropertyType<T> type, ProjectEntity entity) { // Supported entity? if (!type.getSupportedEntityTypes().contains(entity.getProjectEntityType())) { throw new PropertyUnsupportedEntityTypeException(type.getClass().getName(), entity.getProjectEntityType()); } // Checks for viewing if (!type.canView(entity, securityService)) { throw new AccessDeniedException("Property is not opened for viewing."); } // Gets the raw information from the repository TProperty t = propertyRepository.loadProperty( type.getClass().getName(), entity.getProjectEntityType(), entity.getId()); // If null, returns null if (t == null) { return null; } // Converts the stored value into an actual value return type.fromStorage(t.getJson()); }