/** * Generate a property id for given property. * @param property Property (not null) * @return Property id */ protected String generatePropertyId(PROPERTY property) { String id = (TypeUtils.isString(property.getClass())) ? (String) property : "property"; // check duplicates Integer count = generatedPropertyIds.get(id); if (count != null && count > 0) { int sequence = count.intValue() + 1; generatedPropertyIds.put(id, sequence); return id + sequence; } else { generatedPropertyIds.put(id, 1); return id; } }
private static boolean isIntrospectable(Class<?> propertyClass) { return propertyClass != Object.class && !propertyClass.isArray() && !propertyClass.isPrimitive() && !propertyClass.isEnum() && !TypeUtils.isString(propertyClass) && !TypeUtils.isNumber(propertyClass) && !TypeUtils.isTemporalOrCalendar(propertyClass) && !TypeUtils.isBoolean(propertyClass) && !Collection.class.isAssignableFrom(propertyClass); }
@SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, Class<T> targetType) throws IllegalArgumentException { ObjectUtils.argumentNotNull(key, "Property name must be not null"); ObjectUtils.argumentNotNull(targetType, "Property type must be not null"); Object value = properties.get(key); if (value != null) { if (TypeUtils.isAssignable(value.getClass(), targetType)) { return (T) value; } else if (TypeUtils.isString(value.getClass())) { return ConversionUtils.convertStringValue(value.toString(), targetType); } else { throw new IllegalArgumentException( "Property " + key + " type is not consistent " + "with required type: " + targetType.getName() + " (got type: " + value.getClass().getName() + ")"); } } return null; }
} else if (TypeUtils.isString(value.getClass())) { return (T) Enum.valueOf(enm, (String) value); } else {
/** * Get a suitable {@link BeanProperty} builder according to property type. * @param propertyDescriptor Property descriptor * @param annotations The annotations bound to the bean property * @return {@link BeanProperty} builder */ @SuppressWarnings("unchecked") private static BeanProperty.Builder<?> getPropertyBuilder(PropertyDescriptor propertyDescriptor, Annotation[] annotations) { // check type if (TypeUtils.isString(propertyDescriptor.getPropertyType())) { return StringBeanProperty.builder(propertyDescriptor.getName()); } if (TypeUtils.isBoolean(propertyDescriptor.getPropertyType())) { return BooleanBeanProperty.builder(propertyDescriptor.getName(), propertyDescriptor.getPropertyType().isPrimitive()); } if (TypeUtils.isNumber(propertyDescriptor.getPropertyType())) { return NumericBeanProperty.builder(propertyDescriptor.getName(), (Class<? extends Number>) propertyDescriptor.getPropertyType()); } if (TypeUtils.isDate(propertyDescriptor.getPropertyType()) || TypeUtils.isTemporal(propertyDescriptor.getPropertyType())) { return TemporalBeanProperty.builder(propertyDescriptor.getName(), propertyDescriptor.getPropertyType()); } // default return BeanProperty.builder(propertyDescriptor.getName(), propertyDescriptor.getPropertyType()); }
if (TypeUtils.isString(type)) { return (T) value;
if (TypeUtils.isString(value.getClass())) { return (String) value;
if (value != null) { if (TypeUtils.isString(definition.getType()) && !TypeUtils.isString(value.getClass())) { return value.toString(); if (!TypeUtils.isString(definition.getType()) && TypeUtils.isString(value.getClass())) { return ConversionUtils.convertStringValue((String) value, definition.getType());
if (TypeUtils.isString(value.getClass()) && Reader.class.isAssignableFrom(targetType)) { return (T) new StringReader((String) value);
/** * Check parameter field type * @param type Field type * @return <code>true</code> if type is admitted as view parameter value */ private static boolean isAdmittedParameterFieldType(Class<?> type) { return TypeUtils.isString(type) || TypeUtils.isNumber(type) || TypeUtils.isBoolean(type) || TypeUtils.isDate(type) || TypeUtils.isLocalTemporal(type) || TypeUtils.isEnum(type); }
@SuppressWarnings("unchecked") @Override protected SerializableFunction<String, ?> getCaptionFilterProvider(boolean useDefaultIfNotConfigured) { if (filterProvider == null && useDefaultIfNotConfigured) { if (getSelectProperty() != null && TypeUtils.isString(getSelectProperty().getType())) { return text -> QueryFilter.contains((TypedExpression<String>) getSelectProperty(), text, true); } } return filterProvider; }
if (TypeUtils.isString(targetType)) { return value;
ObjectUtils.argumentNotNull(type, "Type must be not null"); if (TypeUtils.isString(type)) {
@SuppressWarnings("rawtypes") @Override public <P extends Property> DatastorePropertySelectModeSingleSelectInputBuilder<T> dataSource(Datastore datastore, DataTarget<?> target, Iterable<P> properties) { @SuppressWarnings("unchecked") final DatastoreDataProvider<PropertyBox, String> datastoreDataProvider = DatastoreDataProvider.create(datastore, target, DatastoreDataProvider.asPropertySet(properties), value -> { if (TypeUtils.isString(selectionProperty.getType())) { return QueryFilter.startsWith((TypedExpression<String>) selectionProperty, value, true); } return null; }); builder.dataSource(datastoreDataProvider); setupDatastoreItemConverter(datastore, target, DatastoreDataProvider.asPropertySet(properties)); return new DefaultDatastorePropertySelectModeSingleSelectInputBuilder<>(this, datastoreDataProvider); }
if (TypeUtils.isString(propertyType)) {
if (TypeUtils.isString(propertyType)) {
if (TypeUtils.isString(propertyType)) {