本文整理了Java中java.util.Collections.checkedCollection()
方法的一些代码示例,展示了Collections.checkedCollection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collections.checkedCollection()
方法的具体详情如下:
包路径:java.util.Collections
类名称:Collections
方法名:checkedCollection
[英]Returns a dynamically typesafe view of the specified collection. Trying to insert an element of the wrong type into this collection throws a ClassCastException. At creation time the types in c are not checked for correct type.
[中]返回指定集合的动态类型安全视图。尝试将错误类型的元素插入此集合会引发ClassCastException。在创建时,没有检查c中的类型是否正确。
代码示例来源:origin: stackoverflow.com
@SuppressWarnings("unchecked") // Just for this one statement
Collection<String> keys = Collections.checkedCollection(map.keySet(),
String.class);
// Now this statement is fully generic with no warnings
SortedSet<String> s = new TreeSet<String>(keys);
代码示例来源:origin: wildfly/wildfly
List<Void> nonRandomAccessList = new LinkedList<>();
classes.add(Collections.checkedCollection(randomAccessList, Void.class).getClass());
classes.add(Collections.checkedCollection(nonRandomAccessList, Void.class).getClass());
classes.add(Collections.checkedList(randomAccessList, Void.class).getClass());
classes.add(Collections.checkedList(nonRandomAccessList, Void.class).getClass());
代码示例来源:origin: protostuff/protostuff
.endsWith("RandomAccessList"));
checkedCollection = Collections.checkedCollection(newList("eight"),
String.class); // no equals impl
checkedSet = Collections.checkedSet(es, Size.class);
代码示例来源:origin: stackoverflow.com
Collection<String> c = Collections.checkedCollection(
new HashSet<String>(), String.class);
代码示例来源:origin: org.glassfish.main.common/amx-core
/**
Create a checked Collection<String>, first verifying that all elements
are in fact String.
@param c the Collection
@throws ClassCastException
*/
public static <T> Collection<T> checkedCollection(final Collection<?> c, final Class<T> theClass)
{
final Collection<T> cc = checkCollection(c, theClass);
return Collections.checkedCollection(cc, theClass);
}
代码示例来源:origin: org.glassfish.common/amx-core
/**
Create a checked Collection<String>, first verifying that all elements
are in fact String.
@param c the Collection
@throws ClassCastException
*/
public static <T> Collection<T> checkedCollection(final Collection<?> c, final Class<T> theClass)
{
final Collection<T> cc = checkCollection(c, theClass);
return Collections.checkedCollection(cc, theClass);
}
代码示例来源:origin: com.github.rinde/rinlog
@Override
protected final void doUpdate(Set<Parcel> onMap, long time) {
final Collection<Parcel> inCargo = Collections.checkedCollection(
pdpModel.get().getContents(vehicle.get()), Parcel.class);
parcels.clear();
parcels.addAll(onMap);
parcels.addAll(onMap);
parcels.addAll(inCargo);
updateCurrent();
}
代码示例来源:origin: sdedit/sdedit
public void update() {
dateLabel.setText(formatDate());
for (DateSwitcherListener listener : Collections.checkedCollection(
listeners, DateSwitcherListener.class)) {
listener.dateSwitched(this, calendar.getTime());
}
dateLabel.requestFocusInWindow();
}
代码示例来源:origin: org.wildfly/wildfly-clustering-marshalling-jboss
classes.add(Collections.checkedCollection(Collections.emptyList(), Void.class).getClass());
classes.add(Collections.checkedList(Collections.emptyList(), Void.class).getClass());
classes.add(Collections.checkedMap(Collections.emptyMap(), Void.class, Void.class).getClass());
代码示例来源:origin: au.net.zeus.jgdms/jgdms-platform
if (type == null) throw new NullPointerException("type cannot be null");
try {
Collection typeCheckedView = Collections.checkedCollection(destination, type);
typeCheckedView.addAll(source);
} catch (ClassCastException ex){
代码示例来源:origin: luisgoncalves/xades4j
crls.addAll(Collections.checkedCollection(storeCRLs, X509CRL.class));
内容来源于网络,如有侵权,请联系作者删除!