spring中对集合的操作放在公共的类CollectionUtils方法中
1、对以下方法进行简单说明一下
public static <E> Iterator<E> toIterator(Enumeration<E> enumeration) {
return new EnumerationIterator<E>(enumeration);
}
这个方法里spring实现了一个针对Enumeration的Iterator适配EnumerationIterator.并取消了remove方法
private static class EnumerationIterator<E> implements Iterator<E> {
private Enumeration<E> enumeration;
public EnumerationIterator(Enumeration<E> enumeration) {
this.enumeration = enumeration;
}
public boolean hasNext() {
return this.enumeration.hasMoreElements();
}
public E next() {
return this.enumeration.nextElement();
}
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException("Not supported");
}
}
2、下面的方法是对Map<key, List<value>>进了一次封装。方便后面的使用ÿ