Example usage for java.util LinkedHashSet LinkedHashSet

List of usage examples for java.util LinkedHashSet LinkedHashSet

Introduction

In this page you can find the example usage for java.util LinkedHashSet LinkedHashSet.

Prototype

public LinkedHashSet() 

Source Link

Document

Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).

Usage

From source file:org.craftercms.commons.ebus.config.EBusBeanAutoConfiguration.java

private static Set<Method> findHandlerMethods(final Class<?> handlerType,
        final ReflectionUtils.MethodFilter listenerMethodFilter) {

    final Set<Method> handlerMethods = new LinkedHashSet<Method>();

    if (handlerType == null) {
        return handlerMethods;
    }/* www.j  av a 2 s  .  co m*/

    Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>();
    Class<?> specifiedHandlerType = null;
    if (!Proxy.isProxyClass(handlerType)) {
        handlerTypes.add(handlerType);
        specifiedHandlerType = handlerType;
    }
    handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
    for (Class<?> currentHandlerType : handlerTypes) {
        final Class<?> targetClass = (specifiedHandlerType != null ? specifiedHandlerType : currentHandlerType);
        ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
            @Override
            public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException {
                Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
                Method bridgeMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
                if (listenerMethodFilter.matches(specificMethod)
                        && (bridgeMethod == specificMethod || !listenerMethodFilter.matches(bridgeMethod))) {
                    handlerMethods.add(specificMethod);
                }
            }
        }, ReflectionUtils.USER_DECLARED_METHODS);
    }

    return handlerMethods;
}

From source file:io.fabric8.camel.FabricLocatorEndpoint.java

@Override
public synchronized void groupEvent(Group<CamelNodeState> group, GroupEvent event) {
    Map<String, CamelNodeState> members;
    if (event == GroupEvent.DISCONNECTED || !isStarted()) {
        members = Collections.emptyMap();
    } else {/*from   w w  w  .  ja  v a2 s.co  m*/
        members = group.members();
    }
    //Find what has been removed.
    Set<String> removed = new LinkedHashSet<String>();

    for (Map.Entry<String, Processor> entry : processors.entrySet()) {
        String key = entry.getKey();
        if (!members.containsKey(key)) {
            removed.add(key);
        }
    }

    //Add existing processors
    for (Map.Entry<String, CamelNodeState> entry : members.entrySet()) {
        try {
            String key = entry.getKey();
            if (!processors.containsKey(key)) {
                Processor p = getProcessor(entry.getValue().consumer);
                processors.put(key, p);
                loadBalancer.addProcessor(p);
            }
        } catch (URISyntaxException e) {
            LOG.warn("Unable to add endpoint " + entry.getValue().consumer, e);
        }
    }

    //Update the list by removing old and adding new.
    for (String key : removed) {
        Processor p = processors.remove(key);
        loadBalancer.removeProcessor(p);
    }
}

From source file:edu.stanford.muse.graph.GroupsGraph.java

/** replaces the existing node if payload already exists. only one payload item can be present in this graph */
public void addNode(Node<SimilarGroup<T>> n) {
    allNodes.put(n.payload, n);//  w w  w .j a  va 2  s .  c  o m
    for (T t : n.payload.elements) {
        Set<Node<SimilarGroup<T>>> nodes = elementToNodes.get(t);
        if (nodes == null) {
            nodes = new LinkedHashSet<Node<SimilarGroup<T>>>();
            elementToNodes.put(t, nodes);
        }
        nodes.add(n);
    }
}

From source file:com.eurodisney.streamit.solr.product.web.SearchController.java

@ResponseBody
@RequestMapping(value = "/autocomplete", produces = "application/json")
public Set<String> autoComplete(Model model, @RequestParam("term") String query,
        @PageableDefault(page = 0, size = 1) Pageable pageable) {
    if (!StringUtils.hasText(query)) {
        return Collections.emptySet();
    }//from w  w  w . j av  a  2s  .c om

    FacetPage<Product> result = productService.autocompleteNameFragment(query, pageable);

    Set<String> titles = new LinkedHashSet<String>();
    for (Page<FacetFieldEntry> page : result.getFacetResultPages()) {
        for (FacetFieldEntry entry : page) {
            if (entry.getValue().contains(query)) { // we have to do this as we do not use terms vector or a string field
                titles.add(entry.getValue());
            }
        }
    }
    return titles;
}

From source file:com.couchbase.client.spring.cache.CouchbaseCacheManager.java

/**
 * Populates all caches.//from   w w  w.ja va2s.  c om
 *
 * @return a collection of loaded caches.
 */
@Override
protected final Collection<? extends Cache> loadCaches() {
    Collection<Cache> caches = new LinkedHashSet<Cache>();

    for (Map.Entry<String, Bucket> cache : clients.entrySet()) {
        caches.add(new CouchbaseCache(cache.getKey(), cache.getValue(), getTtl(cache.getKey())));
    }

    return caches;
}

From source file:gr.abiss.calipso.domain.SpaceRole.java

public SpaceRole(long id, Space space, RoleType roleType) {
    this.id = id;
    this.space = space;
    this.roleTypeId = roleType.getId();
    this.roleCode = createRoleCode();
    this.userSpaceRoles = new LinkedHashSet<UserSpaceRole>();
    this.roleSpaceStdFields = new LinkedHashSet<RoleSpaceStdField>();
}

From source file:com.enonic.cms.core.security.group.GroupEntity.java

public Set<GroupEntity> getMemberships(boolean includeDeleted) {
    if (includeDeleted) {
        return memberships;
    }//from  w w  w  .j  a v a 2  s .  co  m

    Set<GroupEntity> notDeletedMemberships = new LinkedHashSet<GroupEntity>();
    for (GroupEntity membership : memberships) {
        if (!membership.isDeleted()) {
            notDeletedMemberships.add(membership);
        }
    }
    return notDeletedMemberships;
}

From source file:edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph.java

@Override
public Collection<V> getNeighbors(V vertex) {
    if (!containsVertex(vertex))
        return null;
    Collection<V> neighbors = new LinkedHashSet<V>();
    for (E edge : getIncoming_internal(vertex))
        neighbors.add(this.getSource(edge));
    for (E edge : getOutgoing_internal(vertex))
        neighbors.add(this.getDest(edge));
    return Collections.unmodifiableCollection(neighbors);
}

From source file:mitm.application.djigzo.impl.DefaultUserPreferencesSelector.java

/**
 * Returns a ordered (possibly empty) set of UserPreferences that match the domain of the user. A domain
 * is first matched against the wildcard domain (eg. *.example.com) and then matched agains the fully 
 * qualified domain (example.com). //from ww w  . j av a2  s .  c o  m
 */
@Override
public Set<UserPreferences> select(User user) {
    Set<UserPreferences> selected = new LinkedHashSet<UserPreferences>();

    String domain = EmailAddressUtils.getDomain(user.getEmail());

    if (StringUtils.isNotEmpty(domain)) {
        UserPreferences wildcardPreferences = domainManager.getDomainPreferences("*." + domain);

        if (wildcardPreferences == null) {
            /*
             * Check if there is a wildcard for one level up
             */
            String upperDomain = DomainUtils.getUpperLevelDomain(domain);

            if (StringUtils.isNotEmpty(upperDomain)) {
                wildcardPreferences = domainManager.getDomainPreferences("*." + upperDomain);
            }
        }

        /*
         * Get the prefs of the domain itself (if present)
         */
        UserPreferences domainPreferences = domainManager.getDomainPreferences(domain);

        /* 
         * add the preferences from least specific to most specific. A wildcard domain is less
         * specific than a non wildcard domain.
         */
        if (wildcardPreferences != null) {
            selected.add(wildcardPreferences);
        }

        if (domainPreferences != null) {
            selected.add(domainPreferences);
        }
    }

    return selected;
}

From source file:org.openmrs.module.webservices.rest.web.controller.SettingsFormController.java

/**
 * @return// w ww. j  av  a2s. c  o m
 */
@ModelAttribute("globalPropertiesModel")
public GlobalPropertiesModel getModel() {
    List<GlobalProperty> editableProps = new ArrayList<GlobalProperty>();

    Set<String> props = new LinkedHashSet<String>();
    props.add(RestConstants.URI_PREFIX_GLOBAL_PROPERTY_NAME);
    props.add(RestConstants.ALLOWED_IPS_GLOBAL_PROPERTY_NAME);
    props.add(RestConstants.MAX_RESULTS_DEFAULT_GLOBAL_PROPERTY_NAME);
    props.add(RestConstants.MAX_RESULTS_ABSOLUTE_GLOBAL_PROPERTY_NAME);

    //remove the properties we dont want to edit
    for (GlobalProperty gp : Context.getAdministrationService()
            .getGlobalPropertiesByPrefix(RestConstants.MODULE_ID)) {
        if (props.contains(gp.getProperty()))
            editableProps.add(gp);
    }

    return new GlobalPropertiesModel(editableProps);
}