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.apache.apex.malhar.lib.appdata.schemas.Fields.java

/**
 * Creates a set of fields from the given collection of fields.
 * @param fields The collection object to create this {@link Fields} object from.
 *//*  w ww .j a  va 2  s . c o  m*/
public Fields(Collection<String> fields) {
    this.fields = Sets.newLinkedHashSet();

    for (String field : fields) {
        Preconditions.checkNotNull(field);
        if (!this.fields.add(field)) {
            throw new IllegalArgumentException("Duplicate field: " + field);
        }
    }

    fieldsList = Lists.newArrayList();
    fieldsList.addAll(fields);
}

From source file:com.github.djabry.platform.service.security.DefaultPermissionMapper.java

@PostConstruct
public void setupMap() {

    m = Maps.newLinkedHashMap();//from  w  w w  . ja  v  a2s.c  o m

    Set<Permission> appPermissions = Sets.newLinkedHashSet();
    appPermissions.add(Permission.AUTHENTICATE);
    m.put(Role.APPLICATION, appPermissions);

    Set<Permission> userPermissions = Sets.newLinkedHashSet(appPermissions);
    userPermissions.add(Permission.READ_OWN);
    userPermissions.add(Permission.CREATE_OWN);
    userPermissions.add(Permission.UPDATE_OWN);
    userPermissions.add(Permission.DELETE_OWN);

    m.put(Role.USER, userPermissions);

    m.put(Role.APPLICATION, appPermissions);

    Set<Permission> adminPermissions = Sets.newLinkedHashSet(userPermissions);
    adminPermissions.add(Permission.READ_ANY);
    adminPermissions.add(Permission.CREATE_ANY);
    adminPermissions.add(Permission.DELETE_ANY);
    adminPermissions.add(Permission.UPDATE_ANY);

    m.put(Role.ADMINISTRATOR, adminPermissions);

}

From source file:org.eclipse.xtext.ide.serializer.impl.InsertionPointFinder.java

protected Set<AbstractElement> collectAdjacent(ISerState start,
        Function<ISerState, List<? extends ISerState>> followers) {
    LinkedList<ISerState> todo = new LinkedList<>();
    Set<ISerState> seen = Sets.newHashSet();
    todo.addAll(followers.apply(start));
    Set<AbstractElement> result = Sets.newLinkedHashSet();
    while (!todo.isEmpty()) {
        ISerState next = todo.pop();//ww  w  .  j  a v a2 s. com
        if (!seen.add(next)) {
            continue;
        }
        if (next.getType() == SerStateType.ELEMENT
                && !GrammarUtil.isUnassignedAction(next.getGrammarElement())) {
            result.add(next.getGrammarElement());
        } else {
            todo.addAll(followers.apply(next));
        }
    }
    return result;
}

From source file:org.ldp4j.server.data.impl.CoreRuntimeDelegate.java

public CoreRuntimeDelegate() {
    this.mediaTypes = Sets.newLinkedHashSet();
    this.providers = Lists.newCopyOnWriteArrayList();
    populateMediaTypeProviders();
}

From source file:org.eclipse.buildship.ui.workspace.AddBuildshipNatureHandler.java

private Set<FixedRequestAttributes> collectGradleBuilds(List<?> elements) {
    Set<FixedRequestAttributes> builds = Sets.newLinkedHashSet();
    AdapterFunction<IProject> adapterFunction = AdapterFunction.forType(IProject.class);
    for (Object element : elements) {
        IProject project = adapterFunction.apply(element);
        if (project != null && !GradleProjectNature.isPresentOn(project)) {
            IPath location = project.getLocation();
            if (location != null) {
                builds.add(FixedRequestAttributesBuilder.fromWorkspaceSettings(location.toFile()).build());
            }/*from w w w  . j a  v  a2 s  . com*/
        }

    }
    return builds;
}

From source file:org.eclipse.emf.compare.match.eobject.PairCharDistance.java

/**
 * This method returns a {@link Set} of {@link String}s called "pairs". For example,
 * /*from www  .  j  av a  2s.c  o  m*/
 * <pre>
 * pairs(&quot;MyString&quot;)
 * </pre>
 * 
 * returns ["My","yS","St","tr","ri","in","ng"]
 * 
 * @param source
 *            The {@link String} to process.
 * @return A {@link Set} of {@link String} corresponding to the possibles pairs of the source one.
 */
private Set<String> pairs(String source) {
    final Set<String> result = Sets.newLinkedHashSet();
    if (source != null) {
        final int length = source.length();
        for (int i = 0; i < length - 1; i++) {
            result.add(source.substring(i, i + 2));
        }
    }
    return result;
}

From source file:org.smartdeveloperhub.harvesters.it.frontend.issue.Linker.java

public Linker(final IndividualHelper helper) {
    this.helper = helper;
    this.inferredTypes = Sets.newLinkedHashSet();
}

From source file:org.richfaces.resource.optimizer.ResourceLibraryExpander.java

/**
 * Expands resource libraries (.reslib) in collection of resource keys.
 *
 * @param resources resource keys to be expanded
 * @return collection with all resource libraries expanded to particular resource keys (keeps ordering)
 *///from   www . j a  v a 2 s . com
public Collection<ResourceKey> expandResourceLibraries(Collection<ResourceKey> resources) {
    ResourceLibraryFactory factory = ServiceTracker.getService(ResourceLibraryFactory.class);
    Collection<ResourceKey> expandedResources = Sets.newLinkedHashSet();

    for (ResourceKey resourceKey : resources) {
        if (resourceKey.getResourceName().endsWith(ResourceLibraryRenderer.RESOURCE_LIBRARY_EXTENSION)) {

            String libraryName = resourceKey.getLibraryName();
            String resourceName = resourceKey.getResourceName().substring(0,
                    resourceKey.getResourceName().length()
                            - ResourceLibraryRenderer.RESOURCE_LIBRARY_EXTENSION.length());
            ResourceLibrary resourceLibrary = factory.getResourceLibrary(resourceName, libraryName);

            if (resourceLibrary == null) {
                throw new IllegalArgumentException(
                        "Resource library is null: " + libraryName + ":" + resourceName);
            }

            for (ResourceKey expandedKey : resourceLibrary.getResources()) {
                expandedResources.add(expandedKey);
            }

        } else {
            expandedResources.add(resourceKey);
        }
    }

    return expandedResources;
}

From source file:org.obeonetwork.dsl.environment.design.services.ReferencesService.java

public List<Reference> getOppositeReferences(DSemanticDiagram diagram) {
    Collection<StructuredType> structuredTypes = DesignServices.getDisplayedStructuredTypes(diagram);
    Set<Reference> references = Sets.newLinkedHashSet();
    for (StructuredType structuredType : structuredTypes) {
        references.addAll(structuredType.getOwnedReferences());
    }/*w ww . jav a 2 s . c  o  m*/
    Map<String, Reference> map = new HashMap<String, Reference>();
    for (Reference ref : references) {
        if (ref.getOppositeOf() != null) {
            String key1 = ref.getOppositeOf().hashCode() + "" + ref.hashCode();
            String key2 = ref.hashCode() + "" + ref.getOppositeOf().hashCode();
            if (map.get(key1) == null && map.get(key2) == null) {
                map.put(key1, ref);
            }
        }
    }
    return new ArrayList<Reference>(map.values());
}

From source file:de.tu_berlin.dima.oligos.DenseSchema.java

public Set<String> tablesIn(final String schema) {
    Set<String> tables = Sets.newLinkedHashSet();
    for (ColumnId column : columns) {
        if (column.getSchema().equals(schema)) {
            String table = column.getTable();
            tables.add(table);//from  ww  w.  java  2s.c  om
        }
    }
    return tables;
}