private <C extends Collection<T>> GenericCollectionPropertyBuilder<T, C> toCollection(Supplier<C> emptyCollSupplier) { if (isDefaultValueSet()) { throw new IllegalStateException("The default value is already set!"); } GenericCollectionPropertyBuilder<T, C> result = new GenericCollectionPropertyBuilder<>(getName(), getParser(), emptyCollSupplier, getType()); for (PropertyConstraint<? super T> validator : getConstraints()) { result.require(validator.toCollectionConstraint()); } return result; }
private static PropertyDescriptor<List<String>> propertyFor(String stmtName) { return PropertyFactory.enumListProperty("check" + StringUtils.capitalize(stmtName) + "LoopTypes", LOOP_TYPES_MAPPINGS) .desc("List of loop types in which " + stmtName + " statements will be checked") .defaultValue(DEFAULTS) .build(); }
/** * Specify default values. To specify an empty * default value, use {@link #emptyDefaultValue()}. * * @param head First value * @param tail Rest of the values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValues(V head, V... tail) { List<V> tmp = new ArrayList<>(tail.length + 1); tmp.add(head); tmp.addAll(Arrays.asList(tail)); return super.defaultValue(getDefaultValue(tmp)); }
@SuppressWarnings("unchecked") @Override public PropertyDescriptor<C> build() { // Note: the unchecked cast is safe because pre-7.0.0, // we only allow building property descriptors for lists. // C is thus always List<V>, and the cast doesn't fail // Post-7.0.0, the multi-value property classes will be removed // and C will be the actual type parameter of the returned property // descriptor return (PropertyDescriptor<C>) new GenericMultiValuePropertyDescriptor<>( getName(), getDescription(), 0f, getDefaultValue(), getConstraints(), parser, multiValueDelimiter, type ); }
/** * Specify default values. To specify an empty * default value, use {@link #emptyDefaultValue()}. * * @param head First value * @param tail Rest of the values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValues(V head, V... tail) { List<V> tmp = new ArrayList<>(tail.length + 1); tmp.add(head); tmp.addAll(Arrays.asList(tail)); return super.defaultValue(getDefaultValue(tmp)); }
/** * Specify that the default value is an empty collection. * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> emptyDefaultValue() { return super.defaultValue(getDefaultValue(Collections.<V>emptyList())); }
/** * Returns a builder for a property having as value a list of integers. The * format of the individual items is the same as for {@linkplain #intProperty(String) intProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Integer, List<Integer>> intListProperty(String name) { return intProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }
/** * Specify a default value. * * @param val List of values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValue(Collection<? extends V> val) { super.defaultValue(getDefaultValue(val)); return this; }
/** * Returns a builder for a property having as value a list of decimal numbers. The * format of the individual items is the same as for {@linkplain #doubleProperty(String) doubleProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Double, List<Double>> doubleListProperty(String name) { return doubleProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }
private <C extends Collection<T>> GenericCollectionPropertyBuilder<T, C> toCollection(Supplier<C> emptyCollSupplier) { if (isDefaultValueSet()) { throw new IllegalStateException("The default value is already set!"); } GenericCollectionPropertyBuilder<T, C> result = new GenericCollectionPropertyBuilder<>(getName(), getParser(), emptyCollSupplier, getType()); for (PropertyConstraint<? super T> validator : getConstraints()) { result.require(validator.toCollectionConstraint()); } return result; }
/** * Returns a builder for a property having as value a list of long integers. The * format of the individual items is the same as for {@linkplain #longIntProperty(String)} longIntProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Long, List<Long>> longIntListProperty(String name) { return longIntProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }
private static PropertyDescriptor<List<String>> propertyFor(String stmtName) { return PropertyFactory.enumListProperty("check" + StringUtils.capitalize(stmtName) + "LoopTypes", LOOP_TYPES_MAPPINGS) .desc("List of loop types in which " + stmtName + " statements will be checked") .defaultValue(DEFAULTS) .build(); }
/** * Returns a builder for a property having as value a list of {@code <T>}. The * format of the individual items is the same as for {@linkplain #enumProperty(String, Map)}. * * @param name Name of the property to build * @param nameToValue Map of labels to values. The null key is ignored. * @param <T> Value type of the property * * @return A new builder */ public static <T> GenericCollectionPropertyBuilder<T, List<T>> enumListProperty(String name, Map<String, T> nameToValue) { return enumProperty(name, nameToValue).toList().delim(MultiValuePropertyDescriptor.DEFAULT_DELIMITER); }
@SuppressWarnings("unchecked") @Override public PropertyDescriptor<C> build() { // Note: the unchecked cast is safe because pre-7.0.0, // we only allow building property descriptors for lists. // C is thus always List<V>, and the cast doesn't fail // Post-7.0.0, the multi-value property classes will be removed // and C will be the actual type parameter of the returned property // descriptor return (PropertyDescriptor<C>) new GenericMultiValuePropertyDescriptor<>( getName(), getDescription(), 0f, getDefaultValue(), getConstraints(), parser, multiValueDelimiter, type ); }
/** * Returns a builder for a property having as value a list of {@code <T>}. The * format of the individual items is the same as for {@linkplain #enumProperty(String, Map)}. * * @param name Name of the property to build * @param nameToValue Map of labels to values. The null key is ignored. * @param <T> Value type of the property * * @return A new builder */ public static <T> GenericCollectionPropertyBuilder<T, List<T>> enumListProperty(String name, Map<String, T> nameToValue) { return enumProperty(name, nameToValue).toList().delim(MultiValuePropertyDescriptor.DEFAULT_DELIMITER); }
/** * Returns a builder for a property having as value a list of integers. The * format of the individual items is the same as for {@linkplain #intProperty(String) intProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Integer, List<Integer>> intListProperty(String name) { return intProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }
/** * Specify that the default value is an empty collection. * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> emptyDefaultValue() { return super.defaultValue(getDefaultValue(Collections.<V>emptyList())); }
/** * Specify a default value. * * @param val List of values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValue(Collection<? extends V> val) { super.defaultValue(getDefaultValue(val)); return this; }
/** * Returns a builder for a property having as value a list of decimal numbers. The * format of the individual items is the same as for {@linkplain #doubleProperty(String) doubleProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Double, List<Double>> doubleListProperty(String name) { return doubleProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }
/** * Returns a builder for a property having as value a list of long integers. The * format of the individual items is the same as for {@linkplain #longIntProperty(String)} longIntProperty}. * * @param name Name of the property to build * * @return A new builder */ public static GenericCollectionPropertyBuilder<Long, List<Long>> longIntListProperty(String name) { return longIntProperty(name).toList().delim(MultiValuePropertyDescriptor.DEFAULT_NUMERIC_DELIMITER); }