Example usage for com.google.common.collect ImmutableRangeSet of

List of usage examples for com.google.common.collect ImmutableRangeSet of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableRangeSet of.

Prototype

public static <C extends Comparable> ImmutableRangeSet<C> of(Range<C> range) 

Source Link

Document

Returns an immutable range set containing the specified single range.

Usage

From source file:it.frob.auto.value.neuteredtostring.AutoValueNeuterToStringExtension.java

/**
 * Class constructor method generator./*from  w ww .j  a  v a2 s.  c  om*/
 *
 * @param properties the properties of the class constructor to generate.
 * @return a {@link MethodSpec} instance containing the class constructor.
 */
private static MethodSpec generateConstructor(Map<String, ExecutableElement> properties) {
    List<ParameterSpec> params = new ArrayList<ParameterSpec>();
    for (Map.Entry<String, ExecutableElement> entry : properties.entrySet()) {
        TypeName typeName = TypeName.get(entry.getValue().getReturnType());
        params.add(ParameterSpec.builder(typeName, entry.getKey()).build());
    }

    String body = String.format("super(%s)",
            Joiner.on(", ")
                    .join(FluentIterable
                            .from(ImmutableRangeSet.of(Range.closedOpen(0, properties.size()))
                                    .asSet(DiscreteDomain.integers()).descendingSet())
                            .transform(new Function<Integer, String>() {
                                @Override
                                public String apply(Integer input) {
                                    return "$N";
                                }
                            })));

    return MethodSpec.constructorBuilder().addParameters(params)
            .addStatement(body, properties.keySet().toArray()).build();
}

From source file:io.horizondb.model.core.fields.AbstractField.java

/**
 * {@inheritDoc}
 */
@Override
public RangeSet<Field> allValues() {
    return ImmutableRangeSet.of(Range.closed(minValue(), maxValue()));
}