@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);
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());
.endsWith("RandomAccessList")); checkedCollection = Collections.checkedCollection(newList("eight"), String.class); // no equals impl checkedSet = Collections.checkedSet(es, Size.class);
Collection<String> c = Collections.checkedCollection( new HashSet<String>(), String.class);
/** 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); }
/** 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); }
@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(); }
public void update() { dateLabel.setText(formatDate()); for (DateSwitcherListener listener : Collections.checkedCollection( listeners, DateSwitcherListener.class)) { listener.dateSwitched(this, calendar.getTime()); } dateLabel.requestFocusInWindow(); }
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());
if (type == null) throw new NullPointerException("type cannot be null"); try { Collection typeCheckedView = Collections.checkedCollection(destination, type); typeCheckedView.addAll(source); } catch (ClassCastException ex){
crls.addAll(Collections.checkedCollection(storeCRLs, X509CRL.class));