本文整理了Java中java.util.List.addAll()
方法的一些代码示例,展示了List.addAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.addAll()
方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:addAll
[英]Inserts the objects in the specified collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.
[中]在此列表中的指定位置插入指定集合中的对象。对象是按照从集合的迭代器返回的顺序添加的。
代码示例来源:origin: spring-projects/spring-framework
/**
* Configure one or more factories to decorate the handler used to process
* WebSocket messages. This may be useful in some advanced use cases, for
* example to allow Spring Security to forcibly close the WebSocket session
* when the corresponding HTTP session expires.
* @since 4.1.2
*/
public WebSocketTransportRegistration setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories) {
this.decoratorFactories.addAll(Arrays.asList(factories));
return this;
}
代码示例来源:origin: skylot/jadx
public List<RegisterArg> getArguments(boolean includeThis) {
if (includeThis && thisArg != null) {
List<RegisterArg> list = new ArrayList<>(argsList.size() + 1);
list.add(thisArg);
list.addAll(argsList);
return list;
}
return argsList;
}
代码示例来源:origin: google/guava
public static void assertContainsAllOf(Iterable<?> actual, Object... expected) {
List<Object> expectedList = new ArrayList<>();
expectedList.addAll(Arrays.asList(expected));
for (Object o : actual) {
expectedList.remove(o);
}
if (!expectedList.isEmpty()) {
Assert.fail("Not true that " + actual + " contains all of " + Arrays.asList(expected));
}
}
代码示例来源:origin: ch.qos.logback/logback-classic
protected Class[] getParameterTypes() {
List<Class> fullTypeList = new ArrayList<Class>();
fullTypeList.addAll(DEFAULT_PARAM_TYPE_LIST);
for (int i = 0; i < matcherList.size(); i++) {
fullTypeList.add(Matcher.class);
}
return (Class[]) fullTypeList.toArray(CoreConstants.EMPTY_CLASS_ARRAY);
}
代码示例来源:origin: square/okhttp
/** Returns a snapshot of the calls currently being executed. */
public synchronized List<Call> runningCalls() {
List<Call> result = new ArrayList<>();
result.addAll(runningSyncCalls);
for (AsyncCall asyncCall : runningAsyncCalls) {
result.add(asyncCall.get());
}
return Collections.unmodifiableList(result);
}
代码示例来源:origin: square/okhttp
/**
* Returns an immutable map containing each field to its list of values.
*
* @param valueForNullKey the request line for requests, or the status line for responses. If
* non-null, this value is mapped to the null key.
*/
public static Map<String, List<String>> toMultimap(Headers headers, String valueForNullKey) {
Map<String, List<String>> result = new TreeMap<>(FIELD_NAME_COMPARATOR);
for (int i = 0, size = headers.size(); i < size; i++) {
String fieldName = headers.name(i);
String value = headers.value(i);
List<String> allValues = new ArrayList<>();
List<String> otherValues = result.get(fieldName);
if (otherValues != null) {
allValues.addAll(otherValues);
}
allValues.add(value);
result.put(fieldName, Collections.unmodifiableList(allValues));
}
if (valueForNullKey != null) {
result.put(null, Collections.unmodifiableList(Collections.singletonList(valueForNullKey)));
}
return Collections.unmodifiableMap(result);
}
}
代码示例来源:origin: jenkinsci/jenkins
public ProcStarter cmds(File program, String... args) {
commands = new ArrayList<String>(args.length+1);
commands.add(program.getPath());
commands.addAll(Arrays.asList(args));
return this;
}
代码示例来源:origin: androidannotations/androidannotations
private List<String> updateLocations(String path, List<String> possibleLocations) {
List<String> knownLocations = new ArrayList<>();
for (String location : possibleLocations) {
String expectedLocation = path + "/" + location;
File file = new File(expectedLocation + "/output.json");
if (file.exists()) {
Matcher matcher = OUTPUT_JSON_PATTERN.matcher(readJsonFromFile(file));
if (matcher.matches()) {
String relativeManifestPath = matcher.group(1);
File manifestFile = new File(expectedLocation + "/" + relativeManifestPath);
String manifestDirectory = manifestFile.getParentFile().getAbsolutePath();
knownLocations.add(manifestDirectory.substring(path.length()));
}
}
}
if (knownLocations.isEmpty()) {
knownLocations.addAll(possibleLocations);
}
return knownLocations;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Parse the given list of (potentially) comma-separated strings into a
* list of {@code MediaType} objects.
* <p>This method can be used to parse an Accept or Content-Type header.
* @param mediaTypes the string to parse
* @return the list of media types
* @throws InvalidMediaTypeException if the media type value cannot be parsed
* @since 4.3.2
*/
public static List<MediaType> parseMediaTypes(@Nullable List<String> mediaTypes) {
if (CollectionUtils.isEmpty(mediaTypes)) {
return Collections.emptyList();
}
else if (mediaTypes.size() == 1) {
return parseMediaTypes(mediaTypes.get(0));
}
else {
List<MediaType> result = new ArrayList<>(8);
for (String mediaType : mediaTypes) {
result.addAll(parseMediaTypes(mediaType));
}
return result;
}
}
代码示例来源:origin: spring-projects/spring-framework
arguments.add(getResolvableField(objectName, field));
attributeValue = new ResolvableAttribute(attributeValue.toString());
attributesToExpose.put(attributeName, attributeValue);
arguments.addAll(attributesToExpose.values());
return arguments.toArray();
代码示例来源:origin: spring-projects/spring-framework
private static Map<Class<? extends Throwable>, Method> initExceptionMappings(Class<?> handlerType) {
Map<Method, MessageExceptionHandler> methods = MethodIntrospector.selectMethods(handlerType,
(MethodIntrospector.MetadataLookup<MessageExceptionHandler>) method ->
AnnotatedElementUtils.findMergedAnnotation(method, MessageExceptionHandler.class));
Map<Class<? extends Throwable>, Method> result = new HashMap<>();
for (Map.Entry<Method, MessageExceptionHandler> entry : methods.entrySet()) {
Method method = entry.getKey();
List<Class<? extends Throwable>> exceptionTypes = new ArrayList<>();
exceptionTypes.addAll(Arrays.asList(entry.getValue().value()));
if (exceptionTypes.isEmpty()) {
exceptionTypes.addAll(getExceptionsFromMethodSignature(method));
}
for (Class<? extends Throwable> exceptionType : exceptionTypes) {
Method oldMethod = result.put(exceptionType, method);
if (oldMethod != null && !oldMethod.equals(method)) {
throw new IllegalStateException("Ambiguous @ExceptionHandler method mapped for [" +
exceptionType + "]: {" + oldMethod + ", " + method + "}");
}
}
}
return result;
}
代码示例来源:origin: spring-projects/spring-framework
private void updateFilters() {
if (this.filters.isEmpty()) {
return;
}
List<WebFilter> filtersToUse = this.filters.stream()
.peek(filter -> {
if (filter instanceof ForwardedHeaderTransformer && this.forwardedHeaderTransformer == null) {
this.forwardedHeaderTransformer = (ForwardedHeaderTransformer) filter;
}
})
.filter(filter -> !(filter instanceof ForwardedHeaderTransformer))
.collect(Collectors.toList());
this.filters.clear();
this.filters.addAll(filtersToUse);
}
代码示例来源:origin: apache/flink
public static InputGate createInputGate(Collection<InputGate> inputGates1, Collection<InputGate> inputGates2) {
List<InputGate> gates = new ArrayList<InputGate>(inputGates1.size() + inputGates2.size());
gates.addAll(inputGates1);
gates.addAll(inputGates2);
return createInputGate(gates.toArray(new InputGate[gates.size()]));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void multipleKeyRows() {
Map<String, Object> m = new HashMap<String, Object>() {{
put("key", 1);
put("seq", 2);
}};
kh.getKeyList().addAll(asList(m, m));
assertEquals("two rows should be in the list", 2, kh.getKeyList().size());
exception.expect(InvalidDataAccessApiUsageException.class);
exception.expectMessage(startsWith("The getKeys method should only be used when keys for a single row are returned."));
kh.getKeys();
}
代码示例来源:origin: skylot/jadx
private static void insertAtStart(BlockNode block, List<InsnNode> insns) {
List<InsnNode> blockInsns = block.getInstructions();
List<InsnNode> newInsnList = new ArrayList<>(insns.size() + blockInsns.size());
newInsnList.addAll(insns);
newInsnList.addAll(blockInsns);
blockInsns.clear();
blockInsns.addAll(newInsnList);
}
代码示例来源:origin: org.mockito/mockito-core
@Override
public Object[] getConstructorArgs() {
if (outerClassInstance == null) {
return constructorArgs;
}
List<Object> resultArgs = new ArrayList<Object>(constructorArgs.length + 1);
resultArgs.add(outerClassInstance);
resultArgs.addAll(Arrays.asList(constructorArgs));
return resultArgs.toArray(new Object[constructorArgs.length + 1]);
}
代码示例来源:origin: skylot/jadx
@Override
public List<IContainer> getBranches() {
List<IContainer> branches = new ArrayList<>(cases.size() + 1);
branches.addAll(cases);
branches.add(defCase);
return Collections.unmodifiableList(branches);
}
代码示例来源:origin: spring-projects/spring-framework
private static List<MediaType> initMediaTypes(@Nullable HttpMessageWriter<?> formWriter) {
List<MediaType> result = new ArrayList<>();
result.add(MediaType.MULTIPART_FORM_DATA);
if (formWriter != null) {
result.addAll(formWriter.getWritableMediaTypes());
}
return Collections.unmodifiableList(result);
}
代码示例来源:origin: alibaba/jstorm
public void declareStream(String streamId, boolean direct, Fields fields) {
if (_fields.containsKey(streamId)) {
throw new IllegalArgumentException("Fields for " + streamId + " already set");
}
List<String> fieldList = new ArrayList<>();
fieldList.add(TransactionCommon.BATCH_GROUP_ID_FIELD);
fieldList.addAll(fields.toList());
_fields.put(streamId, new StreamInfo(fieldList, direct));
}
代码示例来源:origin: prestodb/presto
@SafeVarargs
public static <T> TupleDomain<T> columnWiseUnion(TupleDomain<T> first, TupleDomain<T> second, TupleDomain<T>... rest)
{
List<TupleDomain<T>> domains = new ArrayList<>(rest.length + 2);
domains.add(first);
domains.add(second);
domains.addAll(Arrays.asList(rest));
return columnWiseUnion(domains);
}
内容来源于网络,如有侵权,请联系作者删除!