当前位置: 首页>>代码示例>>Java>>正文


Java PropertyValueConverter类代码示例

本文整理汇总了Java中com.holonplatform.core.property.PropertyValueConverter的典型用法代码示例。如果您正苦于以下问题:Java PropertyValueConverter类的具体用法?Java PropertyValueConverter怎么用?Java PropertyValueConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertyValueConverter类属于com.holonplatform.core.property包,在下文中一共展示了PropertyValueConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public T write(PropertyBox propertyBox, T instance, boolean ignoreMissing) {
	ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");
	ObjectUtils.argumentNotNull(instance, "Bean instance must be not null");

	propertyBox.stream().filter(p -> !p.isReadOnly()).filter(p -> Path.class.isAssignableFrom(p.getClass()))
			.map(p -> (Path<?>) p).forEach(p -> {
				getProperty(p, ignoreMissing).ifPresent(bp -> {
					final Property<Object> property = ((Property) p);
					final Object boxValue = propertyBox.getValue(property);
					Object value = boxValue;
					// check conversion
					if (!TypeUtils.isAssignable(bp.getType(), property.getType())) {
						value = property.getConverter()
								.filter(c -> TypeUtils.isAssignable(bp.getType(), c.getModelType()))
								.map(c -> ((PropertyValueConverter) c).toModel(boxValue, property))
								.orElse(boxValue);
					}
					write(bp, p.getType(), value, instance);
				});
			});

	return instance;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:26,代码来源:DefaultBeanPropertySet.java

示例2: input7

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
public void input7() {
	// tag::input7[]
	Input<Integer> integerInput = Components.input.number(Integer.class).build();

	Input<Boolean> booleanInput = Input.from(integerInput, // <1>
			Converter.from(value -> Result.ok((value == null) ? null : (value ? 1 : 0)),
					value -> (value == null) ? Boolean.FALSE : (value.intValue() > 0)));

	Boolean boolValue = booleanInput.getValue();

	final Property<Boolean> BOOL_PROPERTY = PathProperty.create("bool", Boolean.class);
	booleanInput = Input.from(integerInput, BOOL_PROPERTY, PropertyValueConverter.numericBoolean(Integer.class)); // <2>

	Input<Long> longInput = Input.from(new TextField(), // <3>
			Converter.from(value -> Result.ok((value == null) ? null : value.toString()),
					value -> (value == null || value.trim().isEmpty()) ? null : Long.parseLong(value)));
	// end::input7[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:19,代码来源:ExampleInput.java

示例3: processBeanProperty

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Builder<?> processBeanProperty(Builder<?> property, Class<?> beanOrNestedClass) {
	property.getAnnotation(Enumerated.class).ifPresent(a -> {
		final EnumType enumType = a.value();
		if (enumType == EnumType.STRING) {
			((Builder) property).converter(PropertyValueConverter.enumByName());
		} else {
			((Builder) property).converter(PropertyValueConverter.enumByOrdinal());
		}
		LOGGER.debug(() -> "JpaEnumeratedBeanPropertyPostProcessor: setted property [" + property
				+ "] value converter to default enumeration converter using [" + enumType.name() + "] mode");
	});
	return property;
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:16,代码来源:JpaEnumeratedBeanPropertyPostProcessor.java

示例4: processPropertyResult

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
/**
 * Process a query result value bound to given <code>property</code>, applying any suitable property value
 * conversion.
 * @param property Property
 * @param value Result value
 * @return Processed value
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object processPropertyResult(Property property, Object value) {
	return property.getConverter()
			.filter(c -> value == null
					|| TypeUtils.isAssignable(value.getClass(), ((PropertyValueConverter<?, ?>) c).getModelType()))
			.map(c -> ((PropertyValueConverter<?, Object>) c).fromModel(value, property)).orElse(value);
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:15,代码来源:AbstractConverter.java

示例5: builtinConverters

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
public void builtinConverters() {
	// tag::bultincnv[]
	PropertyValueConverter.numericBoolean(Integer.class); // <1>
	PropertyValueConverter.localDate(); // <2>
	PropertyValueConverter.localDateTime(); // <3>
	PropertyValueConverter.enumByOrdinal(); // <4>
	PropertyValueConverter.enumByName(); // <5>
	// end::bultincnv[]
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:10,代码来源:ExampleProperty.java

示例6: checkupPropertyValue

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
/**
 * Check property value before putting it in PropertyBox.
 * @param <T> Property and value type
 * @param property Property
 * @param value Property value
 * @return Checked property value
 * @throws TypeMismatchException Value is not consistent with property type
 */
@SuppressWarnings("unchecked")
protected <T> T checkupPropertyValue(Property<T> property, T value) throws TypeMismatchException {
	return validatePropertyValue(property,
			property.getConverter()
					.filter(c -> (value == null || TypeUtils.isAssignable(value.getClass(), c.getModelType())))
					.map(cv -> ((PropertyValueConverter<T, Object>) cv).fromModel(value, property))
					.orElseGet(() -> checkValueTypeConsistency(property, value)));
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:17,代码来源:AbstractPropertyBox.java

示例7: fromModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public E fromModel(String value, Property<E> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	if (value != null) {
		try {
			return Enum.valueOf((Class<E>) ((enumType != null) ? enumType : property.getType()), value);
		} catch (@SuppressWarnings("unused") IllegalArgumentException e) {
			throw new PropertyConversionException(property, "Unable to convert value to required Enum type "
					+ ((enumType != null) ? enumType : property.getType()) + "invalid enum value: " + value);
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:15,代码来源:EnumByNameConverter.java

示例8: toModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public String toModel(E value, Property<E> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	if (value != null) {
		return value.name();
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:9,代码来源:EnumByNameConverter.java

示例9: fromModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public LocalDateTime fromModel(Date value, Property<LocalDateTime> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return ConversionUtils.toLocalDateTime(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:LocalDateTimeConverter.java

示例10: toModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public Date toModel(LocalDateTime value, Property<LocalDateTime> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return ConversionUtils.fromLocalDateTime(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:LocalDateTimeConverter.java

示例11: fromModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public TYPE fromModel(MODEL value, Property<TYPE> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return fromModel.apply(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:CallbackPropertyValueConverter.java

示例12: toModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public MODEL toModel(TYPE value, Property<TYPE> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return toModel.apply(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:CallbackPropertyValueConverter.java

示例13: getConverter

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public Optional<PropertyValueConverter<T, ?>> getConverter() {
	return Optional.ofNullable(converter);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:5,代码来源:AbstractProperty.java

示例14: fromModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public LocalDate fromModel(Date value, Property<LocalDate> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return ConversionUtils.toLocalDate(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:LocalDateConverter.java

示例15: toModel

import com.holonplatform.core.property.PropertyValueConverter; //导入依赖的package包/类
@Override
public Date toModel(LocalDate value, Property<LocalDate> property)
		throws com.holonplatform.core.property.PropertyValueConverter.PropertyConversionException {
	return ConversionUtils.fromLocalDate(value);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:6,代码来源:LocalDateConverter.java


注:本文中的com.holonplatform.core.property.PropertyValueConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。