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:org.sonar.api.workflow.condition.ResolutionCondition.java

public ResolutionCondition(String... resolutions) {
    this(Sets.newLinkedHashSet(Arrays.asList(resolutions)));
}

From source file:org.gradle.plugins.ide.idea.model.ModuleLibrary.java

public ModuleLibrary(Collection<? extends Path> classes, Collection<? extends Path> javadoc,
        Collection<? extends Path> sources, Collection<JarDirectory> jarDirectories, String scope) {
    this.classes = Sets.newLinkedHashSet(classes);
    this.jarDirectories = Sets.newLinkedHashSet(jarDirectories);
    this.javadoc = Sets.newLinkedHashSet(javadoc);
    this.sources = Sets.newLinkedHashSet(sources);
    this.scope = scope;
    this.exported = false;
}

From source file:com.cinchapi.common.collect.Collections.java

/**
 * Ensure that the specified {@code collection} is a {@link Set} or
 * transform it into one if it is not.//from www. j  av  a  2  s.c om
 * 
 * @param collection the collection to ensure
 * @return a {@link Set} with all the distinct elements in the
 *         {@code collection}
 */
public static <T> Set<T> ensureSet(Collection<T> collection) {
    if (collection instanceof Set) {
        return (Set<T>) collection;
    } else {
        return Sets.newLinkedHashSet(collection);
    }

}

From source file:rabbit.data.internal.xml.merge.LaunchEventTypeMerger.java

@Override
protected LaunchEventType doMerge(LaunchEventType t1, LaunchEventType t2) {
    LaunchEventType result = new LaunchEventType();
    result.setLaunchModeId(t1.getLaunchModeId());
    result.setLaunchTypeId(t1.getLaunchTypeId());
    result.setName(t1.getName());/*from w w  w . ja  v  a  2  s .c o  m*/
    result.setCount(t1.getCount() + t2.getCount());
    result.setTotalDuration(t1.getTotalDuration() + t2.getTotalDuration());

    Set<String> fileIds = Sets.newLinkedHashSet(t1.getFilePath());
    fileIds.addAll(t2.getFilePath());
    result.getFilePath().addAll(fileIds);
    return result;
}

From source file:org.eclipse.sirius.ui.tools.internal.actions.session.OpenSessionAction.java

/**
 * Looks for selected {@link IFile}s to open sessions.
 * //from ww w  .ja  va2s .co  m
 * {@inheritDoc}
 */
@Override
protected boolean updateSelection(IStructuredSelection selection) {
    if (selection != null) {
        this.selectedFiles = Sets.newLinkedHashSet(Iterables.filter(selection.toList(), IFile.class));
    }

    return super.updateSelection(selection) && selectedFiles != null && !selectedFiles.isEmpty();
}

From source file:org.apache.whirr.RolePredicates.java

/**
 * @param roles/*from  ww w  .  java2s .  c  om*/
 * @return A {@link Predicate} that matches {@link Instance}s whose roles
 * contain at least one of <code>roles</code>.
 */
public static Predicate<Instance> anyRoleIn(final Set<String> roles) {
    return new Predicate<Instance>() {
        @Override
        public boolean apply(Instance instance) {
            Set<String> copy = Sets.newLinkedHashSet(instance.getRoles());
            copy.retainAll(roles);
            return !copy.isEmpty();
        }
    };
}

From source file:com.torodb.integration.mongo.v3m0.jstests.CoreIT.java

private static ScriptClassifier createScriptClassifier() {
    Set<Script> workingSet = getWorkingSet(), noArraysWorkingSet = getNoArraysWorkingSet(),
            greenplumWorkingSet = getGreenplumWorkingSet(), catastrophicSet = getCatastrophicSet(),
            greenplumCatastrophicSet = Sets
                    .newLinkedHashSet(Iterables.concat(getCatastrophicSet(), getGreenplumCatastrophicSet())),
            falsePositiveSet = getFalsePositiveSet(), notImplementedSet = getNotImplementedSet(),
            noArraysNotImplemented = getNoArraysNotImplementedSet(), ignoredSet = getIgnoredSet(),
            allSet = Sets.newLinkedHashSet(Iterables.concat(workingSet, catastrophicSet, falsePositiveSet,
                    notImplementedSet, ignoredSet));
    return new Builder().addScripts(Mongo, Postgres, WORKING, workingSet)
            .addScripts(Mongo, Postgres, NOT_IMPLEMENTED, notImplementedSet)
            .addScripts(Mongo, Postgres, FALSE_POSITIVE, falsePositiveSet)
            .addScripts(Mongo, Postgres, CATASTROPHIC, catastrophicSet)
            .addScripts(Mongo, Postgres, IGNORED, ignoredSet)

            .addScripts(Mongo, MySQL, WORKING, noArraysWorkingSet)
            .addScripts(Mongo, MySQL, NOT_IMPLEMENTED, noArraysNotImplemented)
            .addScripts(Mongo, MySQL, FALSE_POSITIVE, falsePositiveSet)
            .addScripts(Mongo, MySQL, CATASTROPHIC, catastrophicSet)
            .addScripts(Mongo, MySQL, IGNORED, ignoredSet)

            .addScripts(Mongo, Greenplum, WORKING, greenplumWorkingSet)
            .addScripts(Mongo, Greenplum, NOT_IMPLEMENTED, noArraysNotImplemented)
            .addScripts(Mongo, Greenplum, FALSE_POSITIVE, falsePositiveSet)
            .addScripts(Mongo, Greenplum, CATASTROPHIC, greenplumCatastrophicSet)
            .addScripts(Mongo, Greenplum, IGNORED, ignoredSet)

            .addScripts(MongoReplSet, Postgres, CATASTROPHIC, allSet)
            .addScripts(MongoReplSet, Greenplum, CATASTROPHIC, allSet)
            .addScripts(MongoReplSet, MySQL, CATASTROPHIC, allSet)

            .build();/*from w  w  w. j a  va  2s .  c om*/
}

From source file:com.googlecode.blaisemath.graph.GraphSupport.java

/**
 * Constructs with the set of nodes. The nodes are copied from the supplied
 * collection into a new data structure.
 * @param directed if graph is directed//from  w  w  w .  j  av  a  2s.c  o m
 * @param nodes graph's nodes
 */
public GraphSupport(boolean directed, Iterable<V> nodes) {
    this.directed = directed;
    this.nodes = Collections.unmodifiableSet(Sets.newLinkedHashSet(nodes));
}

From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.OpenRepresentationListener.java

/**
 * {@inheritDoc}//from   www  .  j av a2 s.  c  o m
 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
public void doubleClick(final DoubleClickEvent event) {
    if (event != null && event.getSelection() instanceof IStructuredSelection) {
        List<?> selection = ((IStructuredSelection) event.getSelection()).toList();
        Iterable<DRepresentation> representationToOpen = getRepresentationsToOpen(selection);
        if (!Iterables.isEmpty(representationToOpen)) {
            new OpenRepresentationsAction(Sets.newLinkedHashSet(representationToOpen)).run();
        }
    }
}

From source file:com.cloudera.oryx.kmeans.common.Centers.java

/**
 * Create a new instance from the given points. Any duplicate
 * points in the {@code Iterable} instance will be removed.
 * /*from  w w  w. ja va 2  s  . c  om*/
 * @param points The points
 * @throws IllegalArgumentException if the input is empty
 */
public Centers(Iterable<RealVector> points) {
    this.centers = ImmutableList.copyOf(Sets.newLinkedHashSet(points));
}