List of usage examples for java.util Collections checkedCollection
public static <E> Collection<E> checkedCollection(Collection<E> c, Class<E> type)
From source file:Main.java
public static void main(String args[]) { List<String> arlst = new ArrayList<String>(); // populate the list arlst.add("CSS"); arlst.add("PHP"); arlst.add("HTML"); arlst.add("java2s.com"); // create typesafe view of the collection Collection<String> tslst = Collections.checkedCollection(arlst, String.class); System.out.println(tslst);// w w w .j a va2 s. c o m }
From source file:Main.java
@SuppressWarnings("unchecked") public static boolean checkListType(Object target, Class<?> classz) { try {//from w w w .jav a 2s . c o m if (Collections.checkedCollection((Collection) target, classz).size() > 0) { return true; } } catch (Exception e) { return false; } return false; }
From source file:org.openinfinity.core.async.ParallelServiceActivator.java
/** * Constructor for the class. Initiates collection interfaces of the class. *//* w w w. java 2s . c o m*/ public ParallelServiceActivator() { this.callables = Collections.checkedCollection(new ArrayList(), Callable.class); this.resultCache = new HashMap<String, Loadable>(); this.resultQueue = new LinkedList<Loadable>(); }
From source file:nz.net.orcon.kanban.tools.ListTools.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public <T> Collection<T> query(ObjectContentManager ocm, String baseSearchPath, Class<T> t, List<String> xpathQueries) { final org.apache.jackrabbit.ocm.query.Filter qmFilter = ocm.getQueryManager().createFilter(t); for (String xpathExpression : xpathQueries) { qmFilter.addJCRExpression(xpathExpression); }/*from ww w .j a v a 2 s.c o m*/ Collection objects = ocm.getObjects(ocm.getQueryManager().createQuery(qmFilter)); return Collections.checkedCollection(objects, t); }
From source file:nz.net.orcon.kanban.tools.ListTools.java
public Collection<Card> query(String boardId, String phaseId, String filterId, ObjectContentManager ocm) { Filter filter = (Filter) ocm.getObject(Filter.class, String.format(URI.FILTER_URI, boardId, filterId)); QueryManager qm = ocm.getQueryManager(); org.apache.jackrabbit.ocm.query.Filter qmFilter = qm.createFilter(Card.class); if (phaseId == null) { qmFilter.setScope(String.format(URI.BOARD_URI, boardId + "//")); } else {/* www . j ava 2 s . c o m*/ qmFilter.setScope(String.format(URI.PHASES_URI, boardId, phaseId + "//")); } if (filter != null) { for (Condition condition : filter.getConditions().values()) { String ex = genEx(condition.getOperation().getExpression(), condition.getFieldName(), condition.getValue()); qmFilter.addJCRExpression(ex); } } Query query = qm.createQuery(qmFilter); Collection objects = ocm.getObjects(query); Collection<Card> cards = Collections.checkedCollection(objects, Card.class); return cards; }
From source file:nz.net.orcon.kanban.tools.ListTools.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public <T> Collection<T> retrieveObjects(ObjectContentManager ocm, String searchUrl, List<String> jcrExpressions, Class<T> t) { final QueryManager qm = ocm.getQueryManager(); org.apache.jackrabbit.ocm.query.Filter qmFilter = qm.createFilter(t); qmFilter.setScope(searchUrl + "//"); for (String jcrExpression : jcrExpressions) { qmFilter.addJCRExpression(jcrExpression); }//from w ww. j av a2 s.c o m final Query query = qm.createQuery(qmFilter); final Collection objects = ocm.getObjects(query); final Collection<T> typedObjects = Collections.checkedCollection(objects, t); return typedObjects; }
From source file:org.dcache.xrootd.door.XrootdDoor.java
public void messageArrived(XrootdDoorAdressInfoMessage msg) { _log.debug("Received redirect msg from mover"); XrootdTransfer transfer = _transfers.get(msg.getXrootdFileHandle()); if (transfer != null) { transfer.setUUIDSupported(msg.isUUIDEnabledPool()); // REVISIT: pick the first IPv4 address from the // collection at this point, we can't determine, which of // the pool IP-addresses is the right one, so we select // the first Collection<NetIFContainer> interfaces = Collections.checkedCollection(msg.getNetworkInterfaces(), NetIFContainer.class); Inet4Address ip = getFirstIpv4(interfaces); if (ip != null) { InetSocketAddress address = new InetSocketAddress(ip, msg.getServerPort()); transfer.redirect(address);//from www. j ava 2 s .c o m } else { _log.warn("No valid IP-address received from pool. Redirection not possible"); transfer.redirect(null); } } }
From source file:org.openinfinity.cloud.util.filesystem.FileUtil.java
public static Collection<File> load(String filePath, boolean isRecursive) { Collection<File> fileCollection = Collections.checkedCollection(new ArrayList<File>(), File.class); File file = new File(filePath); checkAvailability(EXCEPTION_CAUSE_FILE_DOES_NOT_EXIST, file); doRecursionOnFileSystem(isRecursive, fileCollection, file); return Collections.unmodifiableCollection(fileCollection); }