@SuppressWarnings("unchecked") private <T> LinkedList<T> stackFor(Class<T> type) { lock.check(); LinkedList<T> result = typeToStack.get(type); if (result == null) { result = CollectionFactory.newLinkedList(); typeToStack.put(type, result); } return result; }
private static void addPropertiesFromExtendedInterfaces(Class forClass, List<PropertyDescriptor> descriptors) throws IntrospectionException { Class[] interfaces = forClass.getInterfaces(); if (interfaces.length == 0){ return; } LinkedList<Class> queue = CollectionFactory.newLinkedList(); // Seed the queue addInterfacesRecursively(queue, forClass); while (!queue.isEmpty()) { Class c = queue.removeFirst(); BeanInfo info = Introspector.getBeanInfo(c); // Duplicates occur and are filtered out in ClassPropertyAdapter which stores // a property name to descriptor map. addAll(descriptors, info.getPropertyDescriptors()); } }
/** * Tries to find an element under this element (including itself) accepted by the given predicate. * * @param predicate * Predicate to accept the element * @return the element if found. null if not found. * @since 5.2.3 */ public Element getElement(Predicate<Element> predicate) { LinkedList<Element> queue = CollectionFactory.newLinkedList(); queue.add(this); while (!queue.isEmpty()) { Element e = queue.removeFirst(); if (predicate.accept(e)) return e; for (Element child : e.childElements()) { queue.addLast(child); } } // Exhausted the entire tree return null; }
public void handleEvent(Component instance, ComponentEvent event) { Object result; if (handles.length == 1) { // simple / common case for a single @PageActivationContext result = handles[0].get(instance); } else { LinkedList<Object> list = CollectionFactory.newLinkedList(); // iterate backwards for (int i = handles.length - 1; i > -1; i--) { FieldHandle handle = handles[i]; Object value = handle.get(instance); // ignore trailing nulls if (value != null || !list.isEmpty()) { list.addFirst(value); } } result = list.isEmpty() ? null : list; } event.storeResult(result); } };
LinkedList<CoercionTuple> queue = CollectionFactory.newLinkedList();