private static PropertyName toPropertyName(Cell cell, String name) { assert cell != null; assert name != null; String[] words = name.split("(_|-)+"); //$NON-NLS-1$ return PropertyName.newInstance(words); }
/** * Creates a new instance. * @param words the words which consists this name * @return the created instance * @throws IllegalArgumentException if some parameters were {@code null} */ public static PropertyName newInstance(String... words) { if (words == null) { throw new IllegalArgumentException("words must not be null"); //$NON-NLS-1$ } return newInstance(Arrays.asList(words)); }
private PropertyName getPropertyNameIfAccessor(Method method) { assert method != null; Matcher matcher = PROPERTY_ACCESSOR.matcher(method.getName()); if (matcher.matches() == false) { return null; } String name = matcher.group(1); List<String> words = new ArrayList<>(); int start = 0; for (int i = 1, n = name.length(); i < n; i++) { char c = name.charAt(i); if ('A' <= c && c <= 'Z') { words.add(name.substring(start, i)); start = i; } } words.add(name.substring(start)); return PropertyName.newInstance(words); }
/** * Parses a property name term and creates a new instance. * @param term the property name term * @return the created instance * @since 0.9.1 */ public static PropertyName parse(String term) { Objects.requireNonNull(term); if (term.isEmpty()) { throw new IllegalArgumentException(); } else if (term.indexOf('_') >= 0 || term.toUpperCase(Locale.ENGLISH).equals(term)) { String[] segments = term.split("_"); //$NON-NLS-1$ return newInstance(segments); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = term.length(); i < n; i++) { if (Character.isUpperCase(term.charAt(i))) { segments.add(term.substring(start, i)); start = i; } } segments.add(term.substring(start)); return newInstance(segments); } }
private PropertyName extract(Field field) { assert field != null; if (Modifier.isPublic(field.getModifiers()) == false) { return null; } if (TYPES.containsKey(field.getType()) == false) { return null; } String name = field.getName(); if (NAME.matcher(name).matches() == false) { return null; } List<String> words = new ArrayList<>(); int start = 0; for (int i = 1, n = name.length(); i < n; i++) { char c = name.charAt(i); if ('A' <= c && c <= 'Z') { words.add(name.substring(start, i)); start = i; } } words.add(name.substring(start)); return PropertyName.newInstance(words); }
for (String name : annotation.value()) { String[] words = name.split("(_|-)+"); //$NON-NLS-1$ PropertyName propertyName = PropertyName.newInstance(words); Method method = results.remove(propertyName); if (method == null) {
/** * 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; }
private Difference createDifference(long actual) { PropertyName name = PropertyName.newInstance("count"); return new Difference( new DataModelReflection(Collections.singletonMap(name, expected)), new DataModelReflection(Collections.singletonMap(name, actual)), "count verification was failed"); }
private Difference createDifference(long actual) { PropertyName name = PropertyName.newInstance("count"); return new Difference( new DataModelReflection(Collections.singletonMap(name, expected)), new DataModelReflection(Collections.singletonMap(name, actual)), "count verification was failed"); }
private Difference createDifference(long actual) { PropertyName name = PropertyName.newInstance("count"); return new Difference( new DataModelReflection(Collections.singletonMap(name, expected)), new DataModelReflection(Collections.singletonMap(name, actual)), "count verification was failed"); }
private Difference createDifference(long actual) { PropertyName name = PropertyName.newInstance("count"); return new Difference( new DataModelReflection(Collections.singletonMap(name, expected)), new DataModelReflection(Collections.singletonMap(name, actual)), "count verification was failed"); }