Example usage for java.util Collection addAll

List of usage examples for java.util Collection addAll

Introduction

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

Prototype

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

Source Link

Document

Adds all of the elements in the specified collection to this collection (optional operation).

Usage

From source file:org.logicblaze.lingo.DefaultResultJoinStrategy.java

public RemoteInvocationResult mergeResponses(RemoteInvocationResult currentResult,
        RemoteInvocationResult newResult, int responseCount) {
    Object value = currentResult.getValue();
    Object newValue = newResult.getValue();
    if (value instanceof Collection) {
        Collection coll = (Collection) value;
        if (newValue instanceof Collection) {
            coll.addAll((Collection) newValue);
        } else {/*from  w ww  .j av  a 2s.co  m*/
            coll.add(newValue);
        }
    } else if (value instanceof Map && newValue instanceof Map) {
        Map map = (Map) value;
        map.putAll((Map) newValue);
    }
    return currentResult;
}

From source file:com.antonjohansson.svncommit.core.utils.Bash.java

/**
 * Creates a temporary bash script with the given command lines.
 *
 * @param commandLines The command lines to add to the bash script.
 * @return Returns the bash script {@link File}.
 */// w w  w.  jav a 2  s.  com
private File getTemporaryScriptFile(Collection<String> commandLines) {
    Collection<String> lines = new ArrayList<>();
    lines.add("#!/bin/bash");
    lines.addAll(commandLines);
    return getTemporaryFile(lines, "temporary-script");
}

From source file:logicProteinHypernetwork.analysis.complexes.ComplexToMinimalNetworkStates.java

/**
 * Returns all minimal network states belonging to given complex.
 * /*from   ww w .jav a2  s . co m*/
 * @param c the complex
 * @return the minimal network states
 */
public Collection<MinimalNetworkState> transform(Complex c) {
    ProteinSubnetwork naiveComplex = FilterUtils.createInducedSubgraph(c, ppin);

    Collection<MinimalNetworkState> mns = new ArrayList<MinimalNetworkState>();

    for (Interaction i : naiveComplex.getEdges()) {
        try {
            mns.addAll(minimalNetworkStates.getMinimalNetworkStates(i));
        } catch (NullPointerException ex) {
            // happens if artificially inserted interactions occur. These do not hurt since they won't have any competitors.
        }
    }

    return mns;
}

From source file:org.socialsignin.springsocial.security.signin.SpringSocialSecurityAuthenticationFactory.java

private Collection<? extends GrantedAuthority> addAuthority(Authentication authentication,
        GrantedAuthority newAuthority) {
    Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    authorities.addAll(authentication.getAuthorities());
    if (newAuthority != null) {
        if (!authorities.contains(newAuthority)) {
            authorities.add(newAuthority);
        }//w  w  w  .j a v a 2  s  .  co  m
    }

    return authorities;
}

From source file:org.socialsignin.springsocial.security.signin.SpringSocialSecurityAuthenticationFactory.java

private Collection<? extends GrantedAuthority> addAuthorities(Authentication authentication,
        Collection<GrantedAuthority> newAuthorities) {
    Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    authorities.addAll(authentication.getAuthorities());
    if (newAuthorities != null) {
        for (GrantedAuthority newAuthority : newAuthorities) {
            if (!authorities.contains(newAuthority)) {
                authorities.add(newAuthority);
            }//from   w  w  w.j a  v  a 2  s .c om
        }
    }

    return authorities;
}

From source file:com.riil.base.resmodel.impl.file.BinFileUtils.java

public static Collection<File> getFiles(String[] filePath) {

    // S_LOGGER.error("WorkSpace is:" +
    // ServerEnvUtil.RIIL_WORK_SPACE_FOLDER);

    Collection<File> retFiles;

    retFiles = null;/* w  w  w  .jav  a2 s  .  c o m*/
    for (int i = 0; i < filePath.length; i++) {
        File t_binf = new File(filePath[i]);
        if (!t_binf.exists()) {
            S_LOGGER.warn(" resmodel folder " + filePath[i] + " was not found.");
            continue;
        }
        try {
            if (retFiles == null) {
                retFiles = FileUtils.listFiles(t_binf, null, false);
            } else {
                Collection<File> files = FileUtils.listFiles(t_binf, null, true);
                retFiles.addAll(files);
            }
        } catch (Exception e) {
            S_LOGGER.error("", e);

            if (retFiles != null) {
                return retFiles;
            } else {
                return new ArrayList<File>();
            }

        }
    }
    return retFiles;
}

From source file:ca.uhn.fhir.rest.method.SummaryEnumParameter.java

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest,
        BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
    Set<SummaryEnum> value = getSummaryValueOrNull(theRequest);
    if (value == null || value.isEmpty()) {
        return null;
    }/* www  .jav  a2s . c  om*/

    if (myInnerCollectionType == null) {
        return value.iterator().next();
    }

    try {
        Collection retVal = myInnerCollectionType.newInstance();
        retVal.addAll(value);
        return retVal;
    } catch (InstantiationException e) {
        throw new InternalErrorException("Failed to instantiate " + myInnerCollectionType, e);
    } catch (IllegalAccessException e) {
        throw new InternalErrorException("Failed to instantiate " + myInnerCollectionType, e);
    }
}

From source file:net.sourceforge.fenixedu.dataTransferObject.degreeAdministrativeOffice.gradeSubmission.MarkSheetManagementCreateBean.java

public Collection<MarkSheetEnrolmentEvaluationBean> getAllEnrolmentEvalutionBeans() {
    final Collection<MarkSheetEnrolmentEvaluationBean> result = new ArrayList<MarkSheetEnrolmentEvaluationBean>();
    result.addAll(getEnrolmentEvaluationBeans());
    result.addAll(getImpossibleEnrolmentEvaluationBeans());
    return result;
}

From source file:com.assemblade.server.model.View.java

public Collection<String> getAttributeNames() {
    Collection<String> attributeNames = super.getAttributeNames();
    attributeNames.addAll(Arrays.asList("asb-view-point"));
    return attributeNames;
}

From source file:com.hp.autonomy.idol.parametricvalues.IdolParametricValuesService.java

@Override
public Set<QueryTagInfo> getAllParametricValues(final IdolParametricRequest idolParametricRequest)
        throws AciErrorException {
    final Collection<String> fieldNames = new HashSet<>();
    fieldNames.addAll(idolParametricRequest.getFieldNames());
    if (fieldNames.isEmpty()) {
        fieldNames.addAll(getTagNames());
    }//from  ww w . j  a  v a2 s  . c o m

    final Set<QueryTagInfo> results;
    if (fieldNames.isEmpty()) {
        results = Collections.emptySet();
    } else {
        final AciParameters aciParameters = new AciParameters(TagActions.GetQueryTagValues.name());
        aciParameters.add(QueryParams.Combine.name(), CombineParam.Simple);
        aciParameters.add(QueryParams.Text.name(), idolParametricRequest.getQueryText());
        aciParameters.add(QueryParams.FieldText.name(), idolParametricRequest.getFieldText());
        aciParameters.add(QueryParams.DatabaseMatch.name(),
                new Databases(idolParametricRequest.getDatabases()));
        aciParameters.add(QueryParams.MinDate.name(), formatDate(idolParametricRequest.getMinDate()));
        aciParameters.add(QueryParams.MaxDate.name(), formatDate(idolParametricRequest.getMaxDate()));
        aciParameters.add(QueryParams.AnyLanguage.name(), true);
        aciParameters.add(GetQueryTagValuesParams.DocumentCount.name(), true);
        aciParameters.add(GetQueryTagValuesParams.MaxValues.name(), MAX_VALUES);
        aciParameters.add(GetQueryTagValuesParams.FieldName.name(),
                StringUtils.join(fieldNames.toArray(), ','));
        aciParameters.add(GetQueryTagValuesParams.Sort.name(), SortParam.DocumentCount.name());

        final GetQueryTagValuesResponseData responseData = contentAciService.executeAction(aciParameters,
                queryTagValuesResponseProcessor);
        final List<FlatField> fields = responseData.getField();
        results = new LinkedHashSet<>(fields.size());
        for (final FlatField field : fields) {
            final List<JAXBElement<? extends Serializable>> valueElements = field.getValueOrSubvalueOrValues();
            final LinkedHashSet<QueryTagCountInfo> values = new LinkedHashSet<>(valueElements.size());
            for (final JAXBElement<?> element : valueElements) {
                if (VALUE_NODE_NAME.equals(element.getName().getLocalPart())) {
                    final TagValue tagValue = (TagValue) element.getValue();
                    values.add(new QueryTagCountInfo(tagValue.getValue(), tagValue.getCount()));
                }
            }
            final String fieldName = getFieldNameFromPath(field.getName().get(0));
            if (!values.isEmpty()) {
                results.add(new QueryTagInfo(fieldName, values));
            }
        }
    }

    return results;
}