本文整理汇总了Java中org.databene.commons.BeanUtil.hasProperty方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtil.hasProperty方法的具体用法?Java BeanUtil.hasProperty怎么用?Java BeanUtil.hasProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.databene.commons.BeanUtil
的用法示例。
在下文中一共展示了BeanUtil.hasProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFeatures
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
/** Provides a {@link Map} of all properties and public attributes of a class assigned to their Java type.
* @param type the Java class to examine
* @return a {@link Map} of all properties and public attributes of a class assigned to their Java type */
public static Map<String, Class<?>> getFeatures(Class<?> type) {
Map<String, Class<?>> features = new OrderedMap<String, Class<?>>();
for (Field field : type.getDeclaredFields()) {
if (WizardUtil.isPublic(field) || BeanUtil.hasProperty(type, field.getName())) {
features.put(field.getName(), field.getType());
}
}
return features;
}
示例2: parseRestrictionChildren
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private void parseRestrictionChildren(Element restriction,
SimpleTypeDescriptor descriptor) {
Element[] children = XMLUtil.getChildElements(restriction);
for (Element child : children) {
String nodeName = localName(child);
String value = child.getAttribute(VALUE);
if (ENUMERATION.equals(nodeName)) {
if (PrimitiveType.STRING.equals(descriptor.getPrimitiveType()))
descriptor.addValue("'" + value + "'");
else
descriptor.addValue(value);
} else if (MIN_INCLUSIVE.equals(nodeName)) {
descriptor.setMin(value);
descriptor.setMinInclusive(true);
} else if (MIN_EXCLUSIVE.equals(nodeName)) {
descriptor.setMin(value);
descriptor.setMinInclusive(false);
} else if (MAX_INCLUSIVE.equals(nodeName)) {
descriptor.setMax(value);
descriptor.setMaxInclusive(true);
} else if (MAX_EXCLUSIVE.equals(nodeName)) {
descriptor.setMax(value);
descriptor.setMaxInclusive(false);
} else if (LENGTH.equals(nodeName)) {
int length = Integer.parseInt(value);
descriptor.setMinLength(length);
descriptor.setMaxLength(length);
} else if (BeanUtil.hasProperty(descriptor.getClass(), nodeName)) {
BeanUtil.setPropertyValue(descriptor, nodeName, value, false);
} else
LOGGER.warn("Ignoring restriction " + nodeName + ": " + value);
}
}
示例3: createConvertingGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor,
Generator<?> generator, BeneratorContext context) {
Converter<?, ?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
if (converter != null) {
if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN))
BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
return WrapperFactory.applyConverter((Generator) generator, converter);
}
return generator;
}
示例4: createConvertingGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor, Generator generator, BeneratorContext context) {
Converter<?,?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
if (converter != null) {
if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN)) {
BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
}
generator = WrapperFactory.applyConverter(generator, converter);
}
return generator;
}
示例5: setBeanProperty
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static void setBeanProperty(Object bean, String detailName, Object detailValue, Context context) {
if (detailValue != null && BeanUtil.hasProperty(bean.getClass(), detailName)) {
try {
PropertyDescriptor propertyDescriptor = BeanUtil.getPropertyDescriptor(bean.getClass(), detailName);
Class<?> propertyType = propertyDescriptor.getPropertyType();
Object propertyValue = detailValue;
if (detailValue instanceof String && StorageSystem.class.isAssignableFrom(propertyType))
propertyValue = context.get(propertyValue.toString());
BeanUtil.setPropertyValue(bean, detailName, propertyValue, false);
} catch (RuntimeException e) {
throw new RuntimeException("Error setting '" + detailName + "' of class " + bean.getClass().getName(), e);
}
}
}
示例6: createConvertingGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor, Generator<?> generator, BeneratorContext context) {
Converter<?,?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
if (converter != null) {
if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN)) {
BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
}
generator = DescriptorUtil.createConvertingGenerator(descriptor, generator, context);
}
return generator;
}