Example usage for java.util LinkedHashSet addAll

List of usage examples for java.util LinkedHashSet addAll

Introduction

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

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.AbstractScriptableDataFactory.java

public final String[] getReferencedFields(final String query, final DataRow parameter) {
    try {/*w ww  .jav  a2  s.c om*/
        final String[] additionalFields = scriptingSupport.computeAdditionalQueryFields(query, parameter);
        if (additionalFields == null) {
            return null;
        }

        final String realQuery = scriptingSupport.computeQuery(query, parameter);
        if (realQuery == null) {
            throw new ReportDataFactoryException("Query '" + query + "' is not recognized."); //$NON-NLS-1$ //$NON-NLS-2$
        }

        String[] referencedFieldsInternal = getReferencedFieldsInternal(realQuery, parameter);
        if (referencedFieldsInternal == null) {
            return null;
        }

        final LinkedHashSet<String> fields = new LinkedHashSet<String>();
        fields.addAll(Arrays.asList(referencedFieldsInternal));
        fields.addAll(Arrays.asList(additionalFields));
        return fields.toArray(new String[fields.size()]);
    } catch (final ReportDataFactoryException rx) {
        logger.debug("Failed to compute referenced fields", rx); // NON-NLS
        return null;
    }
}

From source file:net.sf.maltcms.common.charts.overlay.nodes.OverlayNode.java

@Override
public Action[] getActions(boolean context) {
    List<?> interfaces = getAllInterfaces(getBean().getClass());
    List<?> superClasses = getAllSuperclasses(getBean().getClass());
    LinkedHashSet<Action> containerActions = new LinkedHashSet<>();
    for (Object o : interfaces) {
        Class<?> c = (Class) o;
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getName()));
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getSimpleName()));
    }//w ww. ja  v a2  s .c o m
    for (Object o : superClasses) {
        Class<?> c = (Class) o;
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getName()));
        containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + c.getSimpleName()));
    }
    containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/" + getBean().getClass().getName()));
    containerActions
            .addAll(actionsForPath("Actions/OverlayNodeActions/" + getBean().getClass().getSimpleName()));
    containerActions.add(null);
    containerActions.addAll(actionsForPath("Actions/OverlayNodeActions/DefaultActions"));
    containerActions.add(get(PropertiesAction.class));
    return containerActions.toArray(new Action[containerActions.size()]);
}

From source file:net.sf.maltcms.chromaui.project.spi.nodes.DescriptorNode.java

@Override
public Action[] getActions(boolean context) {
    List<?> interfaces = ClassUtils.getAllInterfaces(getBean().getClass());
    List<?> superClasses = ClassUtils.getAllSuperclasses(getBean().getClass());
    LinkedHashSet<Action> descriptorActions = new LinkedHashSet<>();
    for (Object o : interfaces) {
        Class<?> c = (Class) o;
        descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getName()));
        descriptorActions/*  w w w . j  a  va2 s  .  c  o  m*/
                .addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getSimpleName()));
    }
    for (Object o : superClasses) {
        Class<?> c = (Class) o;
        descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getName()));
        descriptorActions
                .addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getSimpleName()));
    }
    descriptorActions.addAll(
            Utilities.actionsForPath("Actions/DescriptorNodeActions/" + getBean().getClass().getName()));
    descriptorActions.addAll(
            Utilities.actionsForPath("Actions/DescriptorNodeActions/" + getBean().getClass().getSimpleName()));
    descriptorActions.add(null);
    descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/DefaultActions"));
    descriptorActions.add(SystemAction.get(PropertiesAction.class));
    return descriptorActions.toArray(new Action[descriptorActions.size()]);
}

From source file:ch.unibas.fittingwizard.presentation.fitting.FittingParameterPage.java

private LinkedHashSet<AtomTypeId> getAllAtomTypeIds(List<Molecule> molecules) {
    LinkedHashSet<AtomTypeId> allIds = new LinkedHashSet<>();
    for (Molecule molecule : molecules) {
        allIds.addAll(molecule.getAllAtomTypeIds());
    }/*from www . ja v a 2  s.c  o m*/
    return allIds;
}

From source file:org.tdar.core.service.BulkUploadTemplateService.java

/**
 * For the set of @link ResourceType entries, get all of the valid @link
 * BulkImportField fields that should be used.
 * /*from   www. ja  va 2  s  . c  o m*/
 * @param resourceTypes
 * @return
 */
public LinkedHashSet<CellMetadata> getAllValidFieldNames(ResourceType... resourceTypes) {
    List<ResourceType> resourceClasses = new ArrayList<ResourceType>(Arrays.asList(resourceTypes));
    if (ArrayUtils.isEmpty(resourceTypes)) {
        resourceClasses = Arrays.asList(getResourceTypesSupportingBulkUpload());
    }
    CellMetadata filename = CellMetadata.FILENAME;

    LinkedHashSet<CellMetadata> nameSet = new LinkedHashSet<CellMetadata>();
    nameSet.add(filename);
    for (ResourceType clas : resourceClasses) {
        nameSet.addAll(reflectionService.findBulkAnnotationsOnClass(clas.getResourceClass()));
    }

    Iterator<CellMetadata> fields = nameSet.iterator();
    while (fields.hasNext()) {
        CellMetadata field = fields.next();
        String displayName = field.getDisplayName();
        String key = field.getKey();
        logger.trace(field.getKey() + "-" + field.getName() + " " + displayName);
        if (!TdarConfiguration.getInstance().getLicenseEnabled()) {
            if ((key.equals(InformationResource.LICENSE_TEXT)
                    || key.equals(InformationResource.LICENSE_TYPE))) {
                fields.remove();
            }
        }
        if (!TdarConfiguration.getInstance().getCopyrightMandatory()) {
            if ((key.equals(InformationResource.COPYRIGHT_HOLDER)) || displayName.contains(CellMetadata
                    .getDisplayLabel(MessageHelper.getInstance(), InformationResource.COPYRIGHT_HOLDER))) {
                fields.remove();
            }
        }
    }

    return nameSet;
}

From source file:com.google.api.server.spi.request.ServletRequestParamReader.java

public ServletRequestParamReader(EndpointMethod method, HttpServletRequest servletRequest,
        ServletContext servletContext, ApiSerializationConfig serializationConfig) {
    super(method);

    this.servletRequest = servletRequest;
    this.servletContext = servletContext;

    LinkedHashSet<SimpleModule> modules = new LinkedHashSet<>();
    modules.addAll(READER_MODULES);
    this.objectReader = ConfiguredObjectMapper.builder().apiSerializationConfig(serializationConfig)
            .addRegisteredModules(modules).build().reader();
}

From source file:opennlp.tools.fca.ConceptLattice.java

public int AddIntent(List<Integer> intent, LinkedHashSet<Integer> extent, int generator) {
    //System.out.println("add intent "+intent+extent+generator);
    int generator_tmp = GetMaximalConcept(intent, generator);
    generator = generator_tmp;/*from   ww w  . j a v  a2s . c  o m*/
    //System.out.println("   max gen "+generator);
    if (conceptList.get(generator).getIntent().equals(intent)) {
        conceptList.get(generator).addExtents(extent);
        AddExtentToAncestors(extent, generator);
        return generator;
    }
    Set<Integer> generatorParents = conceptList.get(generator).getParents();
    Set<Integer> newParents = new HashSet<Integer>();
    for (int candidate : generatorParents) {
        if (!intent.containsAll(conceptList.get(candidate).getIntent())) {
            List<Integer> intersection = ListUtils.intersection(intent, conceptList.get(candidate).getIntent());
            LinkedHashSet<Integer> new_extent = new LinkedHashSet<Integer>();
            new_extent.addAll(conceptList.get(candidate).extent);
            new_extent.addAll(extent);
            candidate = AddIntent(intersection, new_extent, candidate);
        }

        boolean addParents = true;
        Iterator<Integer> iterator = newParents.iterator();
        while (iterator.hasNext()) {
            Integer parent = iterator.next();
            if (conceptList.get(parent).getIntent().containsAll(conceptList.get(candidate).getIntent())) {
                addParents = false;
                break;
            } else {
                if (conceptList.get(candidate).getIntent().containsAll(conceptList.get(parent).getIntent())) {
                    iterator.remove();
                }
            }
        }
        if (addParents) {
            newParents.add(candidate);
        }
    }

    FormalConcept newConcept = new FormalConcept();
    newConcept.setIntent(intent);
    LinkedHashSet<Integer> new_extent = new LinkedHashSet<Integer>();
    new_extent.addAll(conceptList.get(generator).extent);
    new_extent.addAll(extent);
    newConcept.addExtents(new_extent);
    newConcept.setPosition(conceptList.size());
    conceptList.add(newConcept);
    conceptList.get(generator).getParents().add(newConcept.position);
    conceptList.get(newConcept.position).childs.add(generator);
    for (int newParent : newParents) {
        if (conceptList.get(generator).getParents().contains(newParent)) {
            conceptList.get(generator).getParents().remove(newParent);
            conceptList.get(newParent).childs.remove(generator);
        }
        conceptList.get(newConcept.position).getParents().add(newParent);
        conceptList.get(newParent).addExtents(new_extent);
        AddExtentToAncestors(new_extent, newParent);
        conceptList.get(newParent).childs.add(newConcept.position);
    }

    return newConcept.position;
}

From source file:com.geewhiz.pacify.managers.FilterManager.java

public LinkedHashSet<Defect> doFilter() {
    LinkedHashSet<Defect> defects = new LinkedHashSet<Defect>();

    for (Object entry : pMarker.getFilesAndArchives()) {
        if (entry instanceof PFile) {
            defects.addAll(filterPFile((PFile) entry));
        } else if (entry instanceof PArchive) {
            defects.addAll(filterPArchive((PArchive) entry));
        } else {/*from   w  ww. j  ava2 s .  c o  m*/
            throw new NotImplementedException(
                    "Filter implementation for " + entry.getClass().getName() + " not implemented.");
        }
    }

    CheckForNotReplacedTokens checker = new CheckForNotReplacedTokens();
    defects.addAll(checker.checkForErrors(pMarker));

    if (defects.isEmpty()) {
        pMarker.getFile().delete();
    }

    return defects;
}

From source file:org.sonatype.nexus.httpclient.config.ConfigurationCustomizer.java

/**
 * Creates instance of {@link NexusHttpRoutePlanner} from passed in configuration, never {@code null}.
 *///ww  w  .ja  v a2 s .  c  o  m
@VisibleForTesting
NexusHttpRoutePlanner createRoutePlanner(final ProxyConfiguration proxy) {
    Map<String, HttpHost> proxies = new HashMap<>(2);

    // HTTP proxy
    ProxyServerConfiguration http = proxy.getHttp();
    if (http != null && http.isEnabled()) {
        HttpHost host = new HttpHost(http.getHost(), http.getPort());
        proxies.put(HTTP, host);
        proxies.put(HTTPS, host);
    }

    // HTTPS proxy
    ProxyServerConfiguration https = proxy.getHttps();
    if (https != null && https.isEnabled()) {
        HttpHost host = new HttpHost(https.getHost(), https.getPort());
        proxies.put(HTTPS, host);
    }

    // Non-proxy hosts (Java http.nonProxyHosts formatted glob-like patterns converted to single Regexp expression)
    LinkedHashSet<String> patterns = new LinkedHashSet<>();
    if (proxy.getNonProxyHosts() != null) {
        patterns.addAll(Arrays.asList(proxy.getNonProxyHosts()));
    }
    String nonProxyPatternString = Joiner.on("|")
            .join(Iterables.transform(patterns, GLOB_STRING_TO_REGEXP_STRING));
    Pattern nonProxyPattern = null;
    if (!Strings2.isBlank(nonProxyPatternString)) {
        try {
            nonProxyPattern = Pattern.compile(nonProxyPatternString, Pattern.CASE_INSENSITIVE);
        } catch (PatternSyntaxException e) {
            log.warn("Invalid non-proxy host regex: {}, using defaults", nonProxyPatternString, e);
        }
    }
    return new NexusHttpRoutePlanner(proxies, nonProxyPattern);
}

From source file:ch.unibas.fittingwizard.presentation.fitting.FittingParameterPage.java

private File getInitalCharges(MoleculeQueryService queryService) {
    LinkedHashSet<ChargeValue> userCharges = new LinkedHashSet<>();
    LinkedHashSet<AtomTypeId> atomTypesRequiringUserInput = new LinkedHashSet<>();

    List<Molecule> moleculesWithMissingUserCharges = queryService.findMoleculesWithMissingUserCharges();
    atomTypesRequiringUserInput.addAll(getAllAtomTypeIds(moleculesWithMissingUserCharges));

    boolean multipleMoleculesDefined = queryService.getNumberOfMolecules() > 1;
    if (multipleMoleculesDefined) {
        List<AtomTypeId> duplicates = queryService.findUnequalAndDuplicateAtomTypes();
        atomTypesRequiringUserInput.addAll(duplicates);
    }/*from   www  .  j  a v  a 2 s .c o  m*/

    if (atomTypesRequiringUserInput.size() > 0) {
        LinkedHashSet<ChargeValue> editedValues = editAtomTypeChargesDialog
                .editAtomTypes(atomTypesRequiringUserInput);
        if (editedValues == null) {
            // TODO ... no nested return
            return null;
        }
        userCharges.addAll(editedValues);
    }

    // fill up with all other values in order to generate a correct charges file.
    // due to the set, the already edited values will not be replaced.
    LinkedHashSet<ChargeValue> allCharges = queryService.getUserChargesFromMoleculesWithCharges();
    for (ChargeValue charge : allCharges) {
        if (!userCharges.contains(charge)) {
            userCharges.add(charge);
        }
    }

    File initalChargesFile = generateInitialChargesFileFromUserCharges(userCharges);
    return initalChargesFile;
}