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() 

Source Link

Document

Creates a mutable, empty LinkedHashSet instance.

Usage

From source file:org.summer.dsl.xbase.scoping.featurecalls.AbstractStaticMethodsFeatureForTypeProvider.java

public final Iterable<JvmFeature> getAllFeatures(JvmTypeReference declarator,
        Iterable<JvmTypeReference> hierarchy) {
    Set<JvmFeature> result = Sets.newLinkedHashSet();
    if (declarator != null) {
        collectFeatures(null, hierarchy, result);
    } else {//from  ww  w  .  jav a  2s .  c om
        collectFeatures(null, null, result);
    }
    return result;
}

From source file:org.eclipse.emf.compare.ide.ui.internal.logical.view.ExplorersViewSelectionLMVHandler.java

/**
 * Retrieve the files associated with the given selection.
 * //from   ww  w.  j a  va 2 s .c o m
 * @param part
 *            the {@link IWorkbenchPart} of the editor.
 * @param selection
 *            the {@link ISelection}.
 * @return the files associated with the given selection.
 */
@Override
public Collection<IFile> getFiles(IWorkbenchPart part, ISelection selection) {
    final Set<IFile> files = Sets.newLinkedHashSet();
    if (selection instanceof TreeSelection) {
        Object element = ((TreeSelection) selection).getFirstElement();
        if (element instanceof IFile) {
            files.add((IFile) element);
        }
    }
    return files;
}

From source file:org.smartdeveloperhub.harvesters.it.backend.Project.java

public Project() {
    this.versions = Sets.newLinkedHashSet();
    this.components = Sets.newLinkedHashSet();
    this.topIssues = Sets.newLinkedHashSet();
    this.issues = Sets.newLinkedHashSet();
}

From source file:org.lunifera.doc.dsl.conversion.AbstractRichTextValueConverter.java

protected List<String> getTrailingSubsequences() {
    if (trailingSubsequences != null)
        return trailingSubsequences;
    String trailingTerminal = getTrailingTerminal();
    List<String> result = Collections.emptyList();
    if (trailingTerminal.length() >= 1) {
        Set<String> unique = Sets.newLinkedHashSet();
        for (int i = 0; i < trailingTerminal.length() - 1; i++) {
            addIfAbsent(trailingTerminal.substring(i + 1), unique);
            addIfAbsent(trailingTerminal.substring(0, i + 1), unique);
        }//from   w  w w. ja va2s . c om
        result = ImmutableList.copyOf(unique);
    }
    trailingSubsequences = result;
    return result;
}

From source file:org.xacml4j.v30.spi.pdp.RequestContextHandlerChain.java

@Override
public Collection<String> getFeatures() {
    Set<String> features = Sets.newLinkedHashSet();
    for (RequestContextHandler h : handlers) {
        features.addAll(h.getFeatures());
    }//from w ww. ja  v a 2s .c om
    return features;
}

From source file:com.facebook.buck.graph.AbstractAcyclicDepthFirstPostOrderTraversal.java

/**
 * Performs a depth-first, post-order traversal over a DAG.
 * @param initialNodes The nodes from which to perform the traversal. Not allowed to contain
 *     {@code null}.//from   w w  w.j a v a  2  s  .  co  m
 * @throws CycleException if a cycle is found while performing the traversal.
 */
@SuppressWarnings("PMD.PrematureDeclaration")
public void traverse(Iterable<? extends T> initialNodes) throws CycleException, IOException {
    // This corresponds to the current chain of nodes being explored. Enforcing this invariant makes
    // this data structure useful for debugging.
    Deque<Explorable> toExplore = Lists.newLinkedList();
    for (T node : initialNodes) {
        toExplore.add(new Explorable(node));
    }

    Set<T> inProgress = Sets.newHashSet();
    LinkedHashSet<T> explored = Sets.newLinkedHashSet();

    while (!toExplore.isEmpty()) {
        Explorable explorable = toExplore.peek();
        T node = explorable.node;

        // This could happen if one of the initial nodes is a dependency of the other, for example.
        if (explored.contains(node)) {
            toExplore.removeFirst();
            continue;
        }

        inProgress.add(node);

        // Find children that need to be explored to add to the stack.
        int stackSize = toExplore.size();
        for (Iterator<T> iter = explorable.children; iter.hasNext();) {
            T child = iter.next();
            if (inProgress.contains(child)) {
                throw createCycleException(child, toExplore);
            } else if (!explored.contains(child)) {
                toExplore.addFirst(new Explorable(child));

                // Without this break statement:
                // (1) Children will be explored in reverse order instead of the specified order.
                // (2) CycleException may contain extra nodes.
                // Comment out the break statement and run the unit test to verify this for yourself.
                break;
            }
        }

        if (stackSize == toExplore.size()) {
            // Nothing was added to toExplore, so the current node can be popped off the stack and
            // marked as explored.
            toExplore.removeFirst();
            inProgress.remove(node);
            explored.add(node);

            // Now that the internal state of this traversal has been updated, notify the observer.
            onNodeExplored(node);
        }
    }

    Preconditions.checkState(inProgress.isEmpty(), "No more nodes should be in progress.");

    onTraversalComplete(Iterables.unmodifiableIterable(explored));
}

From source file:it.infn.mw.iam.core.IamTokenService.java

@Override
public Set<OAuth2RefreshTokenEntity> getAllRefreshTokensForUser(String id) {
    Set<OAuth2RefreshTokenEntity> results = Sets.newLinkedHashSet();
    results.addAll(refreshTokenRepo.findValidRefreshTokensForUser(id, new Date()));
    return results;
}

From source file:org.gradle.internal.FastActionSet.java

public void add(Action<T> action) {
    if (action instanceof FastActionSet) {
        addOtherSet((FastActionSet<T>) action);
        return;/*from  w w  w .ja  v a 2 s.  c  om*/
    }
    if (action == DO_NOTHING) {
        return;
    }
    if (singleAction == null && multipleActions == null) {
        // first element in the set
        this.singleAction = action;
        return;
    }
    if (multipleActions != null) {
        // already a composite set
        multipleActions.add(action);
        return;
    }
    if (singleAction == action || singleAction.equals(action)) {
        // de-duplicate
        return;
    }
    // at least 2 elements
    multipleActions = Sets.newLinkedHashSet();
    multipleActions.add(singleAction);
    multipleActions.add(action);
    singleAction = null;
}

From source file:org.eclipse.xtext.ui.editor.hover.ProblemAnnotationHover.java

@Override
protected Object getHoverInfoInternal(final ITextViewer textViewer, final int lineNumber, final int offset) {
    final Set<String> messages = Sets.newLinkedHashSet();
    List<Annotation> annotations = getAnnotations(lineNumber, offset);
    for (Annotation annotation : annotations) {
        String text = annotation.getText();
        if (text != null) {
            messages.add(text.trim());//w  ww . j a  va  2s. co m
        }
    }
    if (messages.size() > 0)
        return formatInfo(messages);
    return null;
}

From source file:org.richfaces.javascript.LibraryResource.java

public static Iterable<LibraryResource> of(Iterable<LibraryScriptString> scripts) {
    LinkedHashSet<LibraryResource> resources = Sets.newLinkedHashSet();
    for (LibraryScriptString scriptString : scripts) {
        resources.add(scriptString.getResource());
    }/*from w w  w  . ja  v  a2 s  .  c  o  m*/
    return resources;
}