/** * 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); }
if (type != null && value != null && type.getRepresentation().isInstance(value) == false) { throw new IllegalArgumentException(MessageFormat.format( Messages.getString("DataModelDefinition.errorInconsistentPropertyValue"), //$NON-NLS-1$
/** * Returns property type kind corresponded to the property name and type. * @param name property name * @param type property type * @return property type kind, or {@code null} without suitable corresponded kind * @throws IllegalArgumentException if some parameters were {@code null} */ public static PropertyType getType(PropertyName name, Class<?> type) { if (name == null) { throw new IllegalArgumentException("name must not be null"); //$NON-NLS-1$ } if (type == null) { throw new IllegalArgumentException("type must not be null"); //$NON-NLS-1$ } PropertyType kind = TYPES.get(type); if (kind == null) { return null; } if (kind.getRepresentation() == Calendar.class) { List<String> words = name.getWords(); if (words.contains(PropertyType.DATE.name().toLowerCase())) { return PropertyType.DATE; } else if (words.contains(PropertyType.TIME.name().toLowerCase())) { return PropertyType.TIME; } else if (words.contains(PropertyType.DATETIME.name().toLowerCase())) { return PropertyType.DATETIME; } } return kind; }
Class<?> expect = types[i].getRepresentation(); Class<?> actual = value.getClass(); if (expect.isAssignableFrom(actual) == false) {
Class<?> type = definition.getType(name).getRepresentation(); if (Comparable.class.isAssignableFrom(type) == false) {