org.springframework.util.CollectionUtils.mergeArrayIntoCollection()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中org.springframework.util.CollectionUtils.mergeArrayIntoCollection()方法的一些代码示例,展示了CollectionUtils.mergeArrayIntoCollection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.mergeArrayIntoCollection()方法的具体详情如下:
包路径:org.springframework.util.CollectionUtils
类名称:CollectionUtils
方法名:mergeArrayIntoCollection

CollectionUtils.mergeArrayIntoCollection介绍

[英]Merge the given array into the given Collection.
[中]将给定数组合并到给定集合中。

代码示例

代码示例来源:origin: spring-projects/spring-framework

public void addValueArray(Object values) {
  CollectionUtils.mergeArrayIntoCollection(values, this.values);
}

代码示例来源:origin: spring-projects/spring-framework

private List<HandlerInterceptor> initInterceptorList() {
  if (this.interceptorList == null) {
    this.interceptorList = new ArrayList<>();
    if (this.interceptors != null) {
      // An interceptor array specified through the constructor
      CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
    }
  }
  this.interceptors = null;
  return this.interceptorList;
}

代码示例来源:origin: gocd/gocd

public void addValueArray(Object values) {
  CollectionUtils.mergeArrayIntoCollection(values, this.values);
}

代码示例来源:origin: spring-projects/spring-framework

public void addInterceptors(HandlerInterceptor... interceptors) {
  if (!ObjectUtils.isEmpty(interceptors)) {
    CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
  }
}

代码示例来源:origin: org.springframework/spring-webmvc

private List<HandlerInterceptor> initInterceptorList() {
  if (this.interceptorList == null) {
    this.interceptorList = new ArrayList<>();
    if (this.interceptors != null) {
      // An interceptor array specified through the constructor
      CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
    }
  }
  this.interceptors = null;
  return this.interceptorList;
}

代码示例来源:origin: spring-projects/spring-framework

public void addValueArray(Object values) {
  CollectionUtils.mergeArrayIntoCollection(values, this.values);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a new HandlerExecutionChain.
 * @param handler the handler object to execute
 * @param interceptors the array of interceptors to apply
 * (in the given order) before the handler itself executes
 */
public HandlerExecutionChain(Object handler, @Nullable HandlerInterceptor... interceptors) {
  if (handler instanceof HandlerExecutionChain) {
    HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
    this.handler = originalChain.getHandler();
    this.interceptorList = new ArrayList<>();
    CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList);
    CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList);
  }
  else {
    this.handler = handler;
    this.interceptors = interceptors;
  }
}

代码示例来源:origin: org.springframework/spring-webmvc

public void addInterceptors(HandlerInterceptor... interceptors) {
  if (!ObjectUtils.isEmpty(interceptors)) {
    CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
  }
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * Create a new HandlerExecutionChain.
 * @param handler the handler object to execute
 * @param interceptors the array of interceptors to apply
 * (in the given order) before the handler itself executes
 */
public HandlerExecutionChain(Object handler, @Nullable HandlerInterceptor... interceptors) {
  if (handler instanceof HandlerExecutionChain) {
    HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
    this.handler = originalChain.getHandler();
    this.interceptorList = new ArrayList<>();
    CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList);
    CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList);
  }
  else {
    this.handler = handler;
    this.interceptors = interceptors;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testMergePrimitiveArrayIntoCollection() {
  int[] arr = new int[] {1, 2};
  List<Comparable<?>> list = new LinkedList<>();
  list.add(Integer.valueOf(3));
  CollectionUtils.mergeArrayIntoCollection(arr, list);
  assertEquals(Integer.valueOf(3), list.get(0));
  assertEquals(Integer.valueOf(1), list.get(1));
  assertEquals(Integer.valueOf(2), list.get(2));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testMergeArrayIntoCollection() {
  Object[] arr = new Object[] {"value1", "value2"};
  List<Comparable<?>> list = new LinkedList<>();
  list.add("value3");
  CollectionUtils.mergeArrayIntoCollection(arr, list);
  assertEquals("value3", list.get(0));
  assertEquals("value1", list.get(1));
  assertEquals("value2", list.get(2));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

public void addValueArray(Object values) {
  CollectionUtils.mergeArrayIntoCollection(values, this.values);
}

代码示例来源:origin: apache/servicemix-bundles

public void addValueArray(Object values) {
  CollectionUtils.mergeArrayIntoCollection(values, this.values);
}

代码示例来源:origin: org.springframework/spring-webmvc-portlet

private List<HandlerInterceptor> initInterceptorList() {
  if (this.interceptorList == null) {
    this.interceptorList = new ArrayList<HandlerInterceptor>();
    if (this.interceptors != null) {
      // An interceptor array specified through the constructor
      CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
    }
  }
  this.interceptors = null;
  return this.interceptorList;
}

代码示例来源:origin: apache/servicemix-bundles

private List<HandlerInterceptor> initInterceptorList() {
  if (this.interceptorList == null) {
    this.interceptorList = new ArrayList<HandlerInterceptor>();
    if (this.interceptors != null) {
      // An interceptor array specified through the constructor
      CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
    }
  }
  this.interceptors = null;
  return this.interceptorList;
}

代码示例来源:origin: org.springframework/spring-webmvc-portlet

public void addInterceptors(HandlerInterceptor... interceptors) {
  if (!ObjectUtils.isEmpty(interceptors)) {
    CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
  }
}

代码示例来源:origin: apache/servicemix-bundles

public void addInterceptors(HandlerInterceptor... interceptors) {
  if (!ObjectUtils.isEmpty(interceptors)) {
    CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
  }
}

代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core

private static Class<?>[] getVisibleClasses(Class<?>[] classes, ClassLoaderBridge loader) {
  if (ObjectUtils.isEmpty(classes))
    return classes;
  Set<Class<?>> classSet = new LinkedHashSet<Class<?>>(classes.length);
  CollectionUtils.mergeArrayIntoCollection(classes, classSet);
  // filter class collection based on visibility
  for (Iterator<Class<?>> iter = classSet.iterator(); iter.hasNext();) {
    Class<?> clzz = iter.next();
    if (!loader.canSee(clzz.getName())) {
      iter.remove();
    }
  }
  return (Class[]) classSet.toArray(new Class[classSet.size()]);
}

代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core

public Set<String> getComponentIds() {
  String[] names = getBeanFactory().getBeanDefinitionNames();
  Set<String> components = new LinkedHashSet<String>(names.length);
  CollectionUtils.mergeArrayIntoCollection(names, components);
  Set<String> filtered = MetadataFactory.filterIds(components);
  return Collections.unmodifiableSet(filtered);
}

代码示例来源:origin: spring-projects/spring-data-solr

public Builder to(String... destinations) {
  if (cf.getDestination() == null) {
    cf.setDestination(Arrays.asList(destinations));
  } else {
    ArrayList<String> values = new ArrayList<>(cf.getDestination());
    CollectionUtils.mergeArrayIntoCollection(destinations, values);
    cf.setDestination(values);
  }
  return this;
}

相关文章