Example usage for com.google.common.collect Sets newLinkedHashSet

List of usage examples for com.google.common.collect Sets newLinkedHashSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newLinkedHashSet.

Prototype

public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements) 

Source Link

Document

Creates a mutable LinkedHashSet instance containing the given elements in order.

Usage

From source file:magma.DataGenerator.java

@SuppressWarnings({ "OverlyLongMethod", "PMD.NcssMethodCount" })
public static void main(String... args) throws IOException {
    Integer number = DEFAULT_NB_ENTITIES;
    String outputFileName = "output.csv";
    String inputFileName = "input.xlsx";

    for (int i = 0; i < args.length; i++) {
        if ("-n".equalsIgnoreCase(args[i])) {
            number = Integer.parseInt(args[++i]);
        } else if ("-o".equalsIgnoreCase(args[i])) {
            outputFileName = args[++i];//from  www  . j av  a  2 s .c  o m
        } else if ("-i".equalsIgnoreCase(args[i])) {
            inputFileName = args[++i];
        }
    }

    File inputFile = new File(inputFileName);
    if (!inputFile.exists()) {
        System.err.println(String.format("Input file %s does not exist.", inputFileName));
        return;
    }

    File outputFile = new File(outputFileName);
    if (outputFile.exists() && !outputFile.delete()) {
        System.err.println(String.format("Cannot delete output file %s.", outputFile));
        return;
    }
    if (!outputFile.createNewFile()) {
        System.err.println(String.format("Cannot create output file %s.", outputFile));
        return;
    }

    new MagmaEngine().extend(new MagmaJsExtension());

    ExcelDatasource eds = new ExcelDatasource("input", inputFile);
    Initialisables.initialise(eds);

    ValueTable table = eds.getValueTables().iterator().next();

    CsvDatasource target = new CsvDatasource("target");
    target.addValueTable(table, outputFile);

    try {
        Initialisables.initialise(target);
    } catch (DatasourceParsingException e) {
        e.printList();
        return;
    }

    ValueTable generated = new GeneratedValueTable(null, Sets.newLinkedHashSet(table.getVariables()), number);

    MultithreadedDatasourceCopier.Builder.newCopier()
            .withCopier(DatasourceCopier.Builder.newCopier().dontCopyMetadata()).from(generated).to(target)
            .as(table.getName()).build().copy();

    Disposables.dispose(eds, target);

}

From source file:cc.recommenders.collections.SublistSelector.java

public static <T> Set<T> shuffle(Set<T> in) {
    List<T> sublist = Lists.<T>newLinkedList();
    copyTo(in, sublist);//  www. j a  v a2 s.  c o m
    Collections.shuffle(sublist);
    Set<T> subset = Sets.newLinkedHashSet(sublist);
    return subset;
}

From source file:org.eclipseday.xtext.example.entitydsl.utils.EntityDslScopeProviderUtil.java

/**
 * // w w  w .j  av  a 2 s  . c om
 * @param scope
 * @param resourceSet
 * @return
 */
public static Set<EObject> unpack(final IScope scope, final ResourceSet resourceSet) {
    final Function<IEObjectDescription, EObject> function = new Function<IEObjectDescription, EObject>() {
        @Override
        public EObject apply(IEObjectDescription eObjectDescription) {
            return getEObject(eObjectDescription, resourceSet);
        }
    };

    final Iterable<EObject> unpackaged = Iterables.transform(scope.getAllElements(), function);
    return Collections.unmodifiableSet(Sets.newLinkedHashSet(unpackaged));
}

From source file:com.yahoo.bard.webservice.table.BaseSchema.java

/**
 * Constructor.//from w  w w  . j av a2 s.com
 *
 * @param granularity  The granularity for this schema.
 * @param columns  The columns for this schema.
 */
protected BaseSchema(Granularity granularity, Iterable<Column> columns) {
    this.granularity = granularity;
    this.columns = Sets.newLinkedHashSet(columns);
}

From source file:uk.ac.ucl.cs.cmic.giftcloud.request.HttpSetResponseProcessor.java

protected final Set<String> streamFromConnection(final InputStream inputStream) throws IOException {
    return Sets.newLinkedHashSet(HttpUtils.readEntityLines(inputStream));
}

From source file:net.roddrim.number5.tools.collect.FluentSet.java

public static <E> FluentSet<E> copyOf(@NonNull final Set<E> set) {
    return of(Sets.newLinkedHashSet(set));
}

From source file:com.fixedorgo.neuron.Synapse.java

/**
 * Main static factory method to get new {@link Synapse} Instance.
 * @param name of the {@link Synapse} or input variable name, must not be null.
 * @param rules that should be include into the Synapse inference, must not be null
 * @return new {@link Synapse} instance//from w  w w  . j ava  2 s . co  m
 */
public static Synapse synapse(String name, ImplicationRule... rules) {
    checkNotNull(name, "Synapse name must not be null");
    checkNotNull(rules, "Implication Rules must not be null");
    return new Synapse(name, Sets.newLinkedHashSet(asList(rules)));
}

From source file:org.gradle.api.publication.maven.internal.DefaultMavenDeployment.java

public DefaultMavenDeployment(PublishArtifact pomArtifact, PublishArtifact mainArtifact,
        Iterable<? extends PublishArtifact> attachedArtifacts) {
    this.pomArtifact = pomArtifact;
    this.mainArtifact = mainArtifact;
    this.attachedArtifacts = Sets.newLinkedHashSet(attachedArtifacts);
}

From source file:org.cinchapi.concourse.util.TSets.java

/**
 * Return a Set that contains all the elements in both {@code a} and
 * {@code b}.//w  w w. java 2 s . com
 * 
 * @param a
 * @param b
 * @return the union of the Sets
 */
public static <T> Set<T> union(Set<T> a, Set<T> b) {
    Set<T> union = Sets.newLinkedHashSet(a);
    union.addAll(b);
    return union;
}

From source file:gaffer.store.operation.handler.DeduplicateHandler.java

@Override
public CloseableIterable<T> doOperation(final Deduplicate<T> operation, final Context context,
        final Store store) throws OperationException {
    return new WrappedCloseableIterable<>(Sets.newLinkedHashSet(operation.getInput()));
}