static void checkProperty(DataModelDefinition<?> definition, PropertyName name) { PropertyType type = definition.getType(name); if (type == null) { throw new IllegalArgumentException(MessageFormat.format( "property \"{1}\" is not defined in {0}", definition.getClass().getName(), name)); } }
private Object describeProperty(DataModelReflection object, PropertyName property) { assert property != null; if (object == null) { return null; } Object value = object.getValue(property); if (value == null) { return null; } PropertyType type = definition.getType(property); switch (type) { case DATE: return dateFormat.format(((Calendar) value).getTime()); case TIME: return timeFormat.format(((Calendar) value).getTime()); case DATETIME: return datetimeFormat.format(((Calendar) value).getTime()); case DECIMAL: return String.format( "%s(scale=%d)", //$NON-NLS-1$ ((BigDecimal) value).toPlainString(), ((BigDecimal) value).scale()); case STRING: return toStringLiteral((String) value); default: return value; } }
/** * Returns a {@link VerifyRule} from since added rules. * @return the created {@link VerifyRule} */ public VerifyRule toVerifyRule() { List<PropertyName> keys = new ArrayList<>(); List<PropertyCondition<?>> properties = new ArrayList<>(); for (Map.Entry<PropertyName, Property> entry : propertyConditions.entrySet()) { Property property = entry.getValue(); if (property.key) { keys.add(entry.getKey()); } if (property.predicates.isEmpty() == false) { @SuppressWarnings({ "unchecked", "rawtypes" }) PropertyCondition<?> cond = new PropertyCondition( entry.getKey(), definition.getType(entry.getKey()).getRepresentation(), property.predicates); properties.add(cond); } } return new VerifyRuleInterpretor(keys, dataModelConditions, properties); }
definition)); PropertyType type = definition.getType(name); if (type != null && value != null && type.getRepresentation().isInstance(value) == false) { throw new IllegalArgumentException(MessageFormat.format(
/** * Returns the sub rule builder for the specified property. * Note that this model will be only accepted if all properties are accepted. * @param name the property name * @return the rule builder for the property * @throws IllegalArgumentException if the property does not exist, * or if some parameters were {@code null} */ public Property property(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); //$NON-NLS-1$ } String[] words = name.split("_|-|\\s+"); //$NON-NLS-1$ PropertyName propertyName = PropertyName.newInstance(words); PropertyType type = definition.getType(propertyName); if (type == null) { throw new IllegalArgumentException(MessageFormat.format( Messages.getString("VerifyRuleBuilder.errorUndefinedProperty"), //$NON-NLS-1$ definition.getModelClass().getName(), propertyName)); } Property subBuilder = propertyConditions.get(propertyName); if (subBuilder == null) { subBuilder = new Property(propertyName, type); propertyConditions.put(propertyName, subBuilder); } return subBuilder; }
if (definition.getType(property) == null) { throw new IOException(MessageFormat.format( Messages.getString("ExcelSheetDataModelSource.errorMissingProperty"), //$NON-NLS-1$
Class<?> type = definition.getType(name).getRepresentation(); if (Comparable.class.isAssignableFrom(type) == false) {
throw new IllegalArgumentException("name must not be null"); //$NON-NLS-1$ PropertyType type = definition.getType(name); if (type == null) { anyProperty(name, context);