Example usage for java.util List addAll

List of usage examples for java.util List addAll

Introduction

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

Prototype

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

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:com.aliyun.android.oss.http.OSSHttpTool.java

/**
 * ?CanonicalizedHeader, \n?/*from   w  w w.  j a v  a 2 s .co m*/
 */
public static String generateCanonicalizedHeader(Map<String, String> headers) {
    String ossHeader = "";
    List<String> list = new ArrayList<String>();
    list.addAll(headers.keySet());
    Collections.sort(list);

    String post = "";
    for (String s : list) {
        if (s.equals(post)) {
            ossHeader += "," + headers.get(s);
        } else {
            ossHeader += "\n" + s + ":" + headers.get(s);
        }
        post = s;
    }

    if (!Helper.isEmptyString(ossHeader)) {
        ossHeader = ossHeader.trim();
        ossHeader += "\n";
    }
    return ossHeader;
}

From source file:com.hmsinc.epicenter.webapp.remoting.AbstractRemoteService.java

/**
 * Prepends an "ALL" category to a list.
 * /*from  www  . j a  v  a  2  s  .c om*/
 * @param values
 * @return
 */
protected static Collection<KeyValueDTO> prependAllCategory(final Collection<KeyValueDTO> values,
        final String text) {
    final List<KeyValueDTO> dto = new ArrayList<KeyValueDTO>();
    dto.add(new KeyValueDTO("ALL", text));
    dto.addAll(values);
    return dto;
}

From source file:Main.java

public static List<Map<String, Object>> setFirstMapFromList(List<Map<String, Object>> list, String field,
        String value) {//ww  w  . j  ava2  s  .com

    List<Map<String, Object>> collection = new ArrayList<Map<String, Object>>();
    for (Iterator<Map<String, Object>> iter = list.iterator(); iter.hasNext();) {

        Map<String, Object> map = iter.next();
        String deField = map.get(field).toString();
        if (deField.equalsIgnoreCase(value)) {
            collection.add(map);
            collection.addAll(list);

            list.clear();
            list.addAll(collection);
            break;
        }
    }
    return list;
}

From source file:org.ect.reo.simulation.views.SimulationViewResults.java

/**
 * Add the chart categories to the simulation view, it will use the statisticsCategories provided by the simulation view
 *//*  www.  ja  v a2  s. com*/
public static void addChartCategories() {
    // Get the categories in a alphabetic order
    List<StatisticCategory> list = new ArrayList<StatisticCategory>();
    list.addAll(SimulationView.statisticCategories.values());
    Collections.sort(list);

    for (StatisticCategory category : list) {
        // Get all statistics from the category
        List<Statistic> statisticList = category.getAllStatistics(true);
        if ((statisticList != null) && (!statisticList.isEmpty())) {
            // If the user specified that he wants a chart for this category, create a tab for this statistic in the chartTabFolder
            if (category.isUseChart()) {
                CTabFolder chartCategoryTabFolder = createTabFolder(SimulationView.chartTabFolder,
                        category.getDescription());
                for (Statistic stat : category.getAllStatistics(true)) {
                    addChart(chartCategoryTabFolder, stat);
                }
            }
            // If the user specified that he wants to see the result for this category, create a tab for this statistic in the resultTabFolder
            if (category.isUseResult()) {
                CTabFolder resultCategoryTabFolder = createTabFolder(SimulationView.resultsTabFolder,
                        category.getDescription());
                for (Statistic stat : category.getAllStatistics(true)) {
                    if (category.getDescription() == SimulationView.COL_STATKEY) {
                        addResult(resultCategoryTabFolder, stat, category.getDescription(), true);
                    } else {
                        addResult(resultCategoryTabFolder, stat, category.getDescription(), false);
                    }
                }
            }
        }
    }
}

From source file:com.evolveum.midpoint.model.api.util.EvaluatedPolicyRuleUtil.java

private static List<EvaluatedPolicyRuleTriggerType> getChildTriggers(EvaluatedPolicyRuleTriggerType trigger) {
    if (trigger instanceof EvaluatedEmbeddingTriggerType) {
        return ((EvaluatedEmbeddingTriggerType) trigger).getEmbedded();
    } else if (trigger instanceof EvaluatedSituationTriggerType) {
        List<EvaluatedPolicyRuleTriggerType> rv = new ArrayList<>();
        for (EvaluatedPolicyRuleType rule : ((EvaluatedSituationTriggerType) trigger).getSourceRule()) {
            rv.addAll(rule.getTrigger());
        }//from www . j  av  a2s .c  o m
        return rv;
    } else {
        return Collections.emptyList();
    }
}

From source file:com.evolveum.midpoint.wf.impl.processors.primary.policy.ProcessSpecifications.java

static ProcessSpecifications createFromRules(List<EvaluatedPolicyRule> rules, PrismContext prismContext)
        throws ObjectNotFoundException {
    // Step 1: plain list of approval actions -> map: process-spec -> list of related actions/rules ("collected")
    LinkedHashMap<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> collectedSpecifications = new LinkedHashMap<>();
    for (EvaluatedPolicyRule rule : rules) {
        for (ApprovalPolicyActionType approvalAction : rule.getEnabledActions(ApprovalPolicyActionType.class)) {
            WfProcessSpecificationType spec = approvalAction.getProcessSpecification();
            collectedSpecifications.computeIfAbsent(spec, s -> new ArrayList<>())
                    .add(new ImmutablePair<>(approvalAction, rule));
        }//  ww w  .jav a2 s .  c om
    }
    // Step 2: resolve references
    for (WfProcessSpecificationType spec : new HashSet<>(collectedSpecifications.keySet())) { // cloned to avoid concurrent modification exception
        if (spec != null && spec.getRef() != null) {
            List<Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>>> matching = collectedSpecifications
                    .entrySet().stream()
                    .filter(e -> e.getKey() != null && spec.getRef().equals(e.getKey().getName()))
                    .collect(Collectors.toList());
            if (matching.isEmpty()) {
                throw new IllegalStateException("Process specification named '" + spec.getRef()
                        + "' referenced from an approval action couldn't be found");
            } else if (matching.size() > 1) {
                throw new IllegalStateException("More than one process specification named '" + spec.getRef()
                        + "' referenced from an approval action: " + matching);
            } else {
                // move all actions/rules to the referenced process specification
                List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> referencedSpecActions = matching
                        .get(0).getValue();
                referencedSpecActions.addAll(collectedSpecifications.get(spec));
                collectedSpecifications.remove(spec);
            }
        }
    }

    Map<String, Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> actionsMap = null;

    // Step 3: include other actions
    for (Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> processSpecificationEntry : collectedSpecifications
            .entrySet()) {
        WfProcessSpecificationType spec = processSpecificationEntry.getKey();
        if (spec == null || spec.getIncludeAction().isEmpty() && spec.getIncludeActionIfPresent().isEmpty()) {
            continue;
        }
        if (actionsMap == null) {
            actionsMap = createActionsMap(collectedSpecifications.values());
        }
        for (String actionToInclude : spec.getIncludeAction()) {
            processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, true);
        }
        for (String actionToInclude : spec.getIncludeActionIfPresent()) {
            processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, false);
        }
    }

    // Step 4: sorts process specifications and wraps into ProcessSpecification objects
    ProcessSpecifications rv = new ProcessSpecifications(prismContext);
    collectedSpecifications.entrySet().stream().sorted((ps1, ps2) -> {
        WfProcessSpecificationType key1 = ps1.getKey();
        WfProcessSpecificationType key2 = ps2.getKey();
        if (key1 == null) {
            return key2 == null ? 0 : 1; // non-empty (key2) records first
        } else if (key2 == null) {
            return -1; // non-empty (key1) record first
        }
        int order1 = defaultIfNull(key1.getOrder(), Integer.MAX_VALUE);
        int order2 = defaultIfNull(key2.getOrder(), Integer.MAX_VALUE);
        return Integer.compare(order1, order2);
    }).forEach(e -> rv.specifications.add(rv.new ProcessSpecification(e)));
    return rv;
}

From source file:forge.card.mana.ManaCost.java

/**
 * TODO: Write javadoc for this method.//from  w w  w .  j av a  2  s. co m
 * @param manaCost
 * @param manaCost2
 * @return
 */
public static ManaCost combine(ManaCost a, ManaCost b) {
    ManaCost res = new ManaCost(a.genericCost + b.genericCost);
    List<ManaCostShard> sh = new ArrayList<ManaCostShard>();
    sh.addAll(a.shards);
    sh.addAll(b.shards);
    res.sealClass(sh);
    return res;
}

From source file:com.megatome.j2d.support.JavadocSupport.java

/**
 * Find all values to be indexed within the specified list of files.
 * @param filesToIndex List of Javadoc files to parse
 * @return List of relevant values to be indexed in the docset
 * @throws BuilderException/*from   w  w  w.ja v a2 s.  c  o m*/
 */
public static List<SearchIndexValue> findSearchIndexValues(List<File> filesToIndex) throws BuilderException {
    final List<SearchIndexValue> values = new ArrayList<>();
    for (final File f : filesToIndex) {
        final List<SearchIndexValue> indexValues = indexFile(f);
        values.addAll(indexValues);
        final File parentDir = f.getParentFile();
        for (final SearchIndexValue searchIndexValue : indexValues) {
            if (extraIndexingTypes.contains(searchIndexValue.getType())) {
                final File classFile = getFile(parentDir, searchIndexValue.getPath());
                values.addAll(indexClassFile(classFile));
            }
        }
    }
    return values;
}

From source file:com.github.pfmiles.minvelocity.biztest.ApiCodeGenUtilTest.java

private static List<DeepAttrInfo> extractDeepInfos(Map<String, Object> resultInfo) {
    List<DeepAttrInfo> ret = new ArrayList<DeepAttrInfo>();
    for (Object v : resultInfo.values()) {
        if (v instanceof DeepAttrInfo) {
            ret.add((DeepAttrInfo) v);/* w  w  w  .  ja  va2  s  . c  o  m*/
            ret.addAll(extractDeepInfos((DeepAttrInfo) v));
        }
    }
    return ret;
}

From source file:com.citytechinc.cq.component.dialog.util.DialogUtil.java

private static void mergeDialogFields(DialogFieldConfig dialogFieldConfig, CtMethod method)
        throws ClassNotFoundException {
    if (dialogFieldConfig != null && method.hasAnnotation(DialogFieldOverride.class)) {
        DialogFieldOverride dialogField = (DialogFieldOverride) method.getAnnotation(DialogFieldOverride.class);
        if (StringUtils.isNotEmpty(dialogField.fieldLabel())) {
            dialogFieldConfig.setFieldLabel(dialogField.fieldLabel());
        }// w ww .  j  av  a  2s.  com

        if (StringUtils.isNotEmpty(dialogField.fieldDescription())) {
            dialogFieldConfig.setFieldDescription(dialogField.fieldDescription());
        }

        dialogFieldConfig.setRequired(dialogField.required());

        dialogFieldConfig.setHideLabel(dialogField.hideLabel());

        if (StringUtils.isNotEmpty(dialogField.defaultValue())) {
            dialogFieldConfig.setDefaultValue(dialogField.defaultValue());
        }

        if (StringUtils.isNotEmpty(dialogField.name())) {
            dialogFieldConfig.setName(dialogField.name());
        }

        dialogFieldConfig.setTab(dialogField.tab());

        dialogFieldConfig.setRanking(dialogField.ranking());

        if (dialogField.additionalProperties().length > 0) {
            List<Property> properties = new ArrayList<Property>();
            properties.addAll(Arrays.asList(dialogField.additionalProperties()));
            if (dialogField.mergeAdditionalProperties()) {
                properties.addAll(Arrays.asList(dialogFieldConfig.getAdditionalProperties()));
            }
            dialogFieldConfig.setAdditionalProperties(properties.toArray(new Property[properties.size()]));
        }

        if (dialogField.listeners().length > 0) {
            List<Listener> listeners = new ArrayList<Listener>();
            listeners.addAll(Arrays.asList(dialogField.listeners()));
            if (dialogField.mergeAdditionalProperties()) {
                listeners.addAll(Arrays.asList(dialogFieldConfig.getListeners()));
            }
            dialogFieldConfig.setListeners(listeners.toArray(new Listener[listeners.size()]));
        }

        if (StringUtils.isNotBlank(dialogField.title())) {
            dialogFieldConfig.setTitle(dialogField.title());
        }

        if (StringUtils.isNotBlank(dialogField.value())) {
            dialogFieldConfig.setValue(dialogField.value());
        }

        dialogFieldConfig.setDisabled(dialogField.disabled());

        if (StringUtils.isNotBlank(dialogField.cssClass())) {
            dialogFieldConfig.setCssClass(dialogField.cssClass());
        }

        dialogFieldConfig.setSuppressTouchUI(dialogField.suppressTouchUI());
    }

}