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:com.mirth.connect.model.ChannelProperties.java

public ChannelProperties() {
    clearGlobalChannelMap = true;/*from   ww  w .j  ava  2 s  .c  om*/
    messageStorageMode = MessageStorageMode.DEVELOPMENT;
    encryptData = false;
    initialState = DeployedState.STARTED;
    tags = new LinkedHashSet<String>();
    metaDataColumns = new ArrayList<MetaDataColumn>();
    attachmentProperties = AttachmentHandlerType.NONE.getDefaultProperties();
    archiveEnabled = true;
    resourceIds = new LinkedHashMap<String, String>();
    resourceIds.put(ResourceProperties.DEFAULT_RESOURCE_ID, ResourceProperties.DEFAULT_RESOURCE_NAME);
}

From source file:eionet.cr.web.util.columns.ReferringPredicatesColumn.java

@Override
public String format(Object object) {

    if (object instanceof SubjectDTO) {

        SubjectDTO subjectDTO = (SubjectDTO) object;

        // Collect labels of all predicates pointing to referringToHash (ignore derived object values).

        LinkedHashSet<String> labels = new LinkedHashSet<String>();
        Map<String, Collection<ObjectDTO>> predicatesObjects = subjectDTO.getPredicates();
        if (predicatesObjects != null && !predicatesObjects.isEmpty()) {

            for (String predicate : predicatesObjects.keySet()) {

                Collection<ObjectDTO> objects = predicatesObjects.get(predicate);
                if (objects != null && !objects.isEmpty()) {

                    for (ObjectDTO objectDTO : objects) {

                        if (objectDTO.getSourceObjectHash() == 0 && objectDTO.getHash() == referringToHash) {

                            String predicateLabel = JstlFunctions
                                    .getPredicateLabel(actionBean.getPredicateLabels(), predicate);
                            labels.add(predicateLabel);
                        }//from   w  w w  .jav a2 s.c  om
                    }
                }
            }
        }

        // Return the above-found labels as a comma-separated list.
        return labels.isEmpty() ? StringUtils.EMPTY : Util.toCSV(labels);
    } else {
        return object == null ? StringUtils.EMPTY : object.toString();
    }
}

From source file:com.glaf.jbpm.util.CustomFieldInstantiator.java

public static Object getValue(Class<?> type, Element propertyElement) {
    Object value = null;//from   www. jav a2  s . c  om
    if (type == String.class) {
        value = propertyElement.getText();
    } else if ((type == Integer.class) || (type == int.class)) {
        value = Integer.parseInt(propertyElement.getTextTrim());
    } else if ((type == Long.class) || (type == long.class)) {
        value = Long.parseLong(propertyElement.getTextTrim());
    } else if ((type == Float.class) || (type == float.class)) {
        value = new Float(propertyElement.getTextTrim());
    } else if ((type == Double.class) || (type == double.class)) {
        value = Double.parseDouble(propertyElement.getTextTrim());
    } else if ((type == Boolean.class) || (type == boolean.class)) {
        value = Boolean.valueOf(propertyElement.getTextTrim());
    } else if ((type == Character.class) || (type == char.class)) {
        value = Character.valueOf(propertyElement.getTextTrim().charAt(0));
    } else if ((type == Short.class) || (type == short.class)) {
        value = Short.valueOf(propertyElement.getTextTrim());
    } else if ((type == Byte.class) || (type == byte.class)) {
        value = Byte.valueOf(propertyElement.getTextTrim());
    } else if (type.isAssignableFrom(java.util.Date.class)) {
        value = DateUtils.toDate(propertyElement.getTextTrim());
    } else if (type.isAssignableFrom(List.class)) {
        value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>());
    } else if (type.isAssignableFrom(Set.class)) {
        value = getCollectionValue(propertyElement, new LinkedHashSet<Object>());
    } else if (type.isAssignableFrom(Collection.class)) {
        value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>());
    } else if (type.isAssignableFrom(Map.class)) {
        value = getMapValue(propertyElement, new LinkedHashMap<Object, Object>());
    } else if (type == Element.class) {
        value = propertyElement;
    } else {
        try {
            Constructor<?> constructor = type.getConstructor(new Class[] { String.class });
            if ((propertyElement.isTextOnly()) && (constructor != null)) {
                value = constructor.newInstance(new Object[] { propertyElement.getTextTrim() });
            }
        } catch (Exception ex) {
            logger.error("couldn't parse the bean property value '" + propertyElement.asXML() + "' to a '"
                    + type.getName() + "'");
            throw new RuntimeException(ex);
        }
    }

    return value;
}

From source file:ru.trett.cis.rest.CommonAPI.java

private Class getModelClass(String className) throws ClassMappingException {
    Reflections reflections = new Reflections("ru.trett.cis.models");
    Set<Class<? extends BaseEntity>> classes = reflections.getSubTypesOf(BaseEntity.class);
    Set<String> classNames = new LinkedHashSet<>();
    classes.forEach(x -> classNames.add(x.getSimpleName()));
    if (!classNames.contains(className))
        throw new ClassMappingException("Class is not Model.");
    try {//from   w  ww  .  j a va  2 s. co m
        return Class.forName("ru.trett.cis.models." + className);
    } catch (ClassNotFoundException e) {
        LOGGER.error(e.getMessage());
        return null;
    }
}

From source file:com.boundary.sdk.snmp.metric.PollerEntry.java

public List<Long> getHostListIds() {
    Set<Long> ids = new LinkedHashSet<Long>();
    for (HostListRef ref : hostLists) {
        if (ref.isEnabled()) {
            ids.add(ref.getId());/*from   www.  j  a va 2  s.  c o  m*/
        }
    }

    ArrayList<Long> list = new ArrayList<Long>();
    list.addAll(ids);
    return list;
}

From source file:edu.uiowa.icts.bluebutton.json.Encounter.java

public String getFindings() {
    if (this.findings.size() == 0) {
        return null;
    } else {/*  w w w.jav  a2 s .c  o m*/
        Set<String> findingNameSet = new LinkedHashSet<String>();
        for (Entry f : this.findings) {
            findingNameSet.add(f.getName());
        }
        return StringUtils.join(findingNameSet.toArray(), ", ");
    }
}

From source file:hudson.ClassicPluginStrategyTest.java

@Override
protected Hudson newHudson() throws Exception {
    File home = homeLoader.allocate();

    for (Recipe.Runner r : recipes) {
        r.decorateHome(this, home);
    }/*from  w w w . ja v  a 2  s.  c om*/
    LocalPluginManager pluginManager = new LocalPluginManager(home) {
        @Override
        protected Collection<String> loadBundledPlugins() {
            // Overriding so we can force loading of the detached plugins for testing
            Set<String> names = new LinkedHashSet<>();
            names.addAll(loadPluginsFromWar("/WEB-INF/plugins"));
            names.addAll(loadPluginsFromWar("/WEB-INF/detached-plugins"));
            return names;
        }
    };
    return new Hudson(home, createWebServer(), pluginManager);
}

From source file:com.phoenixnap.oss.ramlapisync.style.checkers.RequestBodySchemaStyleChecker.java

@Override
public Set<StyleIssue> checkActionStyle(RamlActionType key, RamlAction value, IssueLocation location,
        RamlRoot raml) {/*from  w  ww  . j a v  a2  s.  co  m*/
    logger.debug("Checking Action: " + key);
    Set<StyleIssue> issues = new LinkedHashSet<>();

    //Do we have a check for this verb?
    if (actionsToEnforce.contains(key.name())) {
        boolean schemaFound = false;
        // Now the response
        if (value.hasBody()) {
            Map<String, RamlMimeType> successResponse = value.getBody();
            if (SchemaHelper.containsBodySchema(successResponse, raml, true)) {
                schemaFound = true;
            }
        }

        if (!schemaFound) {
            issues.add(new StyleIssue(location, String.format(DESCRIPTION, key), value.getResource(), value));
        }
    }

    return issues;
}

From source file:org.openmrs.web.controller.user.UserListController.java

/**
 * @should get users just given action parameter
 * @should get all users if no name given
 * @should get users with a given role/*from  w  w  w.j  a  v  a 2s .co  m*/
 * @should include disabled users if requested
 */
@RequestMapping(value = "/admin/users/users")
public String displayUsers(ModelMap model, @RequestParam(value = "action", required = false) String action,
        @RequestParam(value = "name", required = false) String name,
        @RequestParam(value = "role", required = false) Role role,
        @RequestParam(value = "includeDisabled", required = false) Boolean includeDisabled) throws Exception {

    if (Context.isAuthenticated()) {
        List<User> users = getUsers(action, name, role, includeDisabled);
        Map<User, Set<Role>> userRolesMap = new HashMap<User, Set<Role>>(users.size());

        Map<User, Set<Role>> userInheritanceLineMap = new HashMap<User, Set<Role>>(users.size());
        Set<Role> inheritanceLineRoles = new LinkedHashSet<Role>();
        List<Role> helpList = new ArrayList<Role>();

        for (User user : users) {
            Set<Role> roles = new LinkedHashSet<Role>();
            if (role != null && !user.getRoles().contains(role)) {
                // condition -> user has role only via inheritance
                inheritanceLineRoles.add(role);
                for (Role r : user.getRoles()) {
                    if (r.getAllParentRoles().contains(role)) {
                        // condition -> r = role that inherits from filtered role
                        roles.add(r);
                        helpList.addAll(role.getChildRoles());
                        Role r2;
                        for (int i = 0; i < helpList.size(); i++) {
                            r2 = helpList.get(i);
                            if (r2.getAllChildRoles().contains(r)) {
                                // condition -> finding first child role that contains role, which inherits from filtered role
                                inheritanceLineRoles.add(r2);
                                helpList.clear();
                                helpList.addAll(r2.getAllChildRoles());
                                i = -1;
                            } else if (r2.equals(r)) {
                                inheritanceLineRoles.add(r2);
                                break;
                            }
                        }
                    }
                }
                userInheritanceLineMap.put(user, inheritanceLineRoles);
            } else if (role != null && user.getRoles().contains(role)) {
                // adding searched role on the first place for simplicity of dealing with it in JSTL
                roles.add(role);
            }

            roles.addAll(user.getRoles());
            userRolesMap.put(user, roles);
        }
        model.put("users", users);
        model.put("role", role);
        model.put("userInheritanceLineMap", userInheritanceLineMap);
        model.put("userRolesMap", userRolesMap);
    }
    return "module/legacyui/admin/users/users";
}

From source file:es.ua.dlsi.lexicalinformation.Corpus.java

/**
 * Method that retrieves all the lines containing a given surface form in the
 * corpus./* w  w w  .  ja  v a  2 s.com*/
 * @param word Word to be searched in the corpus
 * @return Returns the set of lines containing a given surface form in the
 * corpus.
 */
public Set<String> GetAllExamples(String word) {
    Set<String> examples = new LinkedHashSet<String>();
    LineIterator corpus_it = null;
    try {
        corpus_it = FileUtils.lineIterator(new File(this.path));
    } catch (FileNotFoundException ex) {
        System.err.println("Error while trying to open '" + this.path + "' file.");
        System.exit(-1);
    } catch (IOException ex) {
        System.err.println("Error while reading '" + this.path + "' file.");
        System.exit(-1);
    }
    while (corpus_it.hasNext()) {
        String line = corpus_it.nextLine();
        //If the surface form appears in the sentence...
        if (line.matches("^" + word + " .*") || line.matches(".* " + word + "$")
                || line.matches(".* " + word + " .*")) {
            examples.add(line);
        }
    }
    corpus_it.close();
    return examples;
}