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:exec.validate_evaluation.streaks.EditStreakGenerationIo.java

public Set<ICompletionEvent> readCompletionEvents(String zip) {
    Set<ICompletionEvent> es = Sets.newLinkedHashSet();
    Directory dir = new Directory(dirIn);
    try (IReadingArchive ra = dir.getReadingArchive(zip)) {
        while (ra.hasNext()) {
            CompletionEvent ce = ra.getNext(CompletionEvent.class);
            ce.context = TypeErasureVisitor.erase(ce.context);
            es.add(ce);/*  w w w. j  a  va2  s.co m*/
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return es;
}

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

/**
 * Retrieve the files associated with the given editor (via its {@link IWorkbenchPart}).
 * /*from  w  w w. j a v a2  s .  com*/
 * @param part
 *            the {@link IWorkbenchPart} of the editor.
 * @param selection
 *            the {@link ISelection}.
 * @return the files associated with the given editor (via its {@link IWorkbenchPart}).
 */
@Override
public Collection<IFile> getFiles(IWorkbenchPart part, ISelection selection) {
    final Set<IFile> files = Sets.newLinkedHashSet();
    if (part instanceof IEditorPart) {
        IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
        if (editorInput instanceof IFileEditorInput) {
            files.add(((IFileEditorInput) editorInput).getFile());
        }
    }
    return files;
}

From source file:org.jclouds.vcloud.xml.ovf.NetworkSectionHandler.java

public NetworkSection getResult() {
    NetworkSection system = new NetworkSection(info, networks);
    this.info = null;
    this.networks = Sets.newLinkedHashSet();
    return system;
}

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

/**
 * Perform an optimized intersection calculation, assuming that both
 * {@code a} and {@code b} are sorted sets.
 * // ww  w .j  av  a  2 s  . co  m
 * @param a
 * @param b
 * @return the intersection of the Sets
 */
@SuppressWarnings("unchecked")
private static <T> Set<T> sortedIntersection(SortedSet<T> a, SortedSet<T> b) {
    Set<T> intersection = Sets.newLinkedHashSet();
    if (a.isEmpty() || b.isEmpty()) {
        return intersection;
    }
    Iterator<T> ait = a.iterator();
    Iterator<T> bit = b.iterator();
    Comparator<? super T> comp = a.comparator();
    boolean ago = true;
    boolean bgo = true;
    T aelt = null;
    T belt = null;
    while (((ago && ait.hasNext()) || !ago) && ((bgo && bit.hasNext()) || !bgo)) {
        aelt = ago ? ait.next() : aelt;
        belt = bgo ? bit.next() : belt;
        int order = comp == null ? ((Comparable<T>) aelt).compareTo(belt) : comp.compare(aelt, belt);
        if (order == 0) {
            intersection.add(aelt);
            ago = true;
            bgo = true;
        } else if (order > 0) {
            bgo = true;
            ago = false;
        } else {
            ago = true;
            bgo = false;
        }
    }
    return intersection;
}

From source file:com.textocat.textokit.commons.cas.FSTypeUtils.java

/**
 * Example:/*from ww w  .ja  v  a  2s  . c om*/
 * <p>
 * Result for type 'org.test.internal.Foobar':
 * </p>
 * <p>
 * org, org.test, org.test.internal
 * </p>
 *
 * @param t
 * @return namespaces of given type name ordered ordered from top-level to
 * the lowest.
 */
public static LinkedHashSet<String> getNamespaces(Type t) {
    if (t == null) {
        throw new NullPointerException("type");
    }
    LinkedHashSet<String> result = Sets.newLinkedHashSet();
    String[] nameSplit = t.getName().split("\\.");
    List<String> packageNames = Lists.newArrayList(nameSplit);
    // remove type short name
    packageNames.remove(packageNames.size() - 1);
    // generate namespaces
    Joiner nsJoiner = Joiner.on('.');
    for (int i = 0; i < packageNames.size(); i++) {
        String ns = nsJoiner.join(packageNames.subList(0, i + 1));
        result.add(ns);
    }
    assert result.size() == packageNames.size();
    return result;
}

From source file:org.splevo.ui.handler.vpm.CombineGroupsHandler.java

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    ISelection curSelection = HandlerUtil.getCurrentSelection(event);
    if (curSelection != null && curSelection instanceof IStructuredSelection) {
        IStructuredSelection selection = (IStructuredSelection) curSelection;

        Set<VariationPointGroup> groupsToMerge = Sets.newLinkedHashSet();
        for (Object selectedItem : selection.toList()) {
            if (selectedItem instanceof VariationPointGroup) {
                groupsToMerge.add((VariationPointGroup) selectedItem);
            }//from  w ww.  ja  va 2 s . c o  m
        }

        combineGroups(groupsToMerge);

    }

    return null;
}

From source file:com.github.glue.mvc.general.DefaultContainer.java

public <T> Set<T> getInstances(Class<T> type) {
    Set<T> instances = Sets.newLinkedHashSet();
    for (Map.Entry<String, Object> entry : context.entrySet()) {
        Object instance = entry.getValue();
        if (type.isInstance(instance)) {
            instances.add((T) instance);
        }/*  w  w  w. ja v a  2s  . co  m*/
    }
    return instances;
}

From source file:org.artifactory.storage.db.fs.dao.TasksDao.java

@Nonnull
public Set<TaskRecord> load(String taskType) throws SQLException {
    ResultSet resultSet = null;//from w w  w .j ava2  s . c o  m
    Set<TaskRecord> entries = Sets.newLinkedHashSet();
    try {
        resultSet = jdbcHelper.executeSelect("SELECT * FROM tasks WHERE task_type = ?", taskType);
        while (resultSet.next()) {
            entries.add(taskFromResultSet(resultSet));
        }
        return entries;
    } finally {
        DbUtils.close(resultSet);
    }
}

From source file:com.textocat.textokit.commons.cas.AITOverlapIndex.java

@Override
public Set<A> getOverlapping(int begin, int end) {
    Set<A> result = Sets.newLinkedHashSet();
    List<OffsetsWithValue<A>> resultList = tree.getOverlapping(begin, end);
    result.addAll(Lists.transform(resultList, new Function<OffsetsWithValue<A>, A>() {
        @Override/*from  w  w w.j a v  a 2  s .co  m*/
        public A apply(OffsetsWithValue<A> input) {
            return input.getValue();
        }
    }));
    return result;
}

From source file:com.nzion.dto.UserLoginDto.java

public Set<String> getAuthoritiesByRole() {
    Set<String> authorities = Sets.newLinkedHashSet();
    for (String role : this.roles) {
        UserType userType = UserType.valueOf(role);
        if (userType != null)
            authorities.add(userType.toString());
    }/*from w  w w.jav  a 2 s  . co m*/
    return authorities;
}