List of usage examples for java.util LinkedList isEmpty
boolean isEmpty();
From source file:org.apache.hadoop.hbase.regionserver.CompactionPipeline.java
private boolean validateSuffixList(LinkedList<ImmutableSegment> suffix) { if (suffix.isEmpty()) { // empty suffix is always valid return true; }//from w w w. j a v a 2 s .c o m Iterator<ImmutableSegment> pipelineBackwardIterator = pipeline.descendingIterator(); Iterator<ImmutableSegment> suffixBackwardIterator = suffix.descendingIterator(); ImmutableSegment suffixCurrent; ImmutableSegment pipelineCurrent; for (; suffixBackwardIterator.hasNext();) { if (!pipelineBackwardIterator.hasNext()) { // a suffix longer than pipeline is invalid return false; } suffixCurrent = suffixBackwardIterator.next(); pipelineCurrent = pipelineBackwardIterator.next(); if (suffixCurrent != pipelineCurrent) { // non-matching suffix return false; } } // suffix matches pipeline suffix return true; }
From source file:com.github.helenusdriver.commons.lang3.reflect.ReflectionUtils.java
/** * Gets all members of a given type (up the super class hierarchy) annotated * with the specified annotation./*from w ww . j a v a2 s . co m*/ * * @author paouelle * * @param <T> the type of members to retrieve (either {@link Field}, * {@link Method}, or {@link Constructor}) * * @param type the type of members to retrieve * @param clazz the class from which to find all annotated members * @param annotation the annotation for which to find all members * @param up <code>true</code> to look up the class hierarchy; * <code>false</code> to only look at the specified class level * @return a list in the provided order for all annotated members * @throws NullPointerException if <code>type</code>, * <code>clazz</code> or <code>annotation</code> is <code>null</code> * @throws IllegalArgumentException if <code>type</code> is not * {@link Field}, {@link Method}, or {@link Constructor} */ public static <T extends Member> List<T> getAllMembersAnnotatedWith(Class<T> type, Class<?> clazz, Class<? extends Annotation> annotation, boolean up) { org.apache.commons.lang3.Validate.notNull(type, "invalid null member type"); org.apache.commons.lang3.Validate.notNull(clazz, "invalid null class"); org.apache.commons.lang3.Validate.notNull(annotation, "invalid null annotation class"); final LinkedList<Class<?>> classes = new LinkedList<>(); if (up) { while (clazz != null) { classes.push(clazz); clazz = clazz.getSuperclass(); } } else { classes.push(clazz); } final List<T> members = new ArrayList<>(12); while (!classes.isEmpty()) { clazz = classes.pop(); for (final T m : ReflectionUtils.getDeclaredMembers(type, clazz)) { if ((m instanceof AnnotatedElement) && ((AnnotatedElement) m).getAnnotationsByType(annotation).length > 0) { members.add(m); } } } return members; }
From source file:com.adobe.acs.commons.mcp.impl.processes.asset.HierarchicalElement.java
@SuppressWarnings("squid:S00112") default void visitAllFolders(CheckedConsumer<HierarchicalElement> visitor, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFunction) throws Exception { LinkedList<HierarchicalElement> nodes = new LinkedList<>(); nodes.add(this); while (!nodes.isEmpty()) { HierarchicalElement node = nodes.pop(); childFunction.apply(node).forEach(nodes::add); visitor.accept(node);/*from w ww . j a v a 2s . c o m*/ } }
From source file:com.adobe.acs.commons.mcp.impl.processes.asset.HierarchicalElement.java
@SuppressWarnings("squid:S00112") default void visitAllFiles(CheckedConsumer<HierarchicalElement> visitor, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFolderFunction, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFileFunction) throws Exception { LinkedList<HierarchicalElement> nodes = new LinkedList<>(); nodes.add(this); while (!nodes.isEmpty()) { HierarchicalElement node = nodes.pop(); childFolderFunction.apply(node).forEach(nodes::add); for (HierarchicalElement child : childFileFunction.apply(node).collect(Collectors.toList())) { visitor.accept(child);/*from w w w. j a v a 2 s . co m*/ } } }
From source file:org.tinygroup.jspengine.runtime.JspFactoryImpl.java
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) { try {// w w w . j ava 2s. c o m PageContext pc = null; if (USE_POOL) { LinkedList<PageContext> pcPool = (LinkedList<PageContext>) pool.get(); if (!pcPool.isEmpty()) { pc = pcPool.removeFirst(); } if (pc == null) { pc = new PageContextImpl(this); } } else { pc = new PageContextImpl(this); } pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush); return pc; } catch (Throwable ex) { /* FIXME: need to do something reasonable here!! */ log.fatal("Exception initializing page context", ex); return null; } }
From source file:com.github.helenusdriver.commons.lang3.reflect.ReflectionUtils.java
/** * Gets all members of a given type (up the super class hierarchy) annotated * with the specified annotation./*from w ww .j av a2 s . c o m*/ * * @author paouelle * * @param <T> the type of members to retrieve (either {@link Field}, * {@link Method}, or {@link Constructor}) * @param <A> the type of annotation to search for * * @param type the type of members to retrieve * @param clazz the class from which to find all annotated members * @param annotation the annotation for which to find all members * @param up <code>true</code> to look up the class hierarchy; * <code>false</code> to only look at the specified class level * @return a non-<code>null</code> map in the provided order for all annotated * members with their found annotations * @throws NullPointerException if <code>type</code>, * <code>clazz</code> or <code>annotation</code> is <code>null</code> * @throws IllegalArgumentException if <code>type</code> is not * {@link Field}, {@link Method}, or {@link Constructor} */ public static <T extends Member, A extends Annotation> Map<T, A[]> getAllAnnotationsForMembersAnnotatedWith( Class<T> type, Class<?> clazz, Class<A> annotation, boolean up) { org.apache.commons.lang3.Validate.notNull(type, "invalid null member type"); org.apache.commons.lang3.Validate.notNull(clazz, "invalid null class"); org.apache.commons.lang3.Validate.notNull(annotation, "invalid null annotation class"); final LinkedList<Class<?>> classes = new LinkedList<>(); if (up) { while (clazz != null) { classes.push(clazz); clazz = clazz.getSuperclass(); } } else { classes.push(clazz); } final Map<T, A[]> members = new LinkedHashMap<>(12); while (!classes.isEmpty()) { clazz = classes.pop(); for (final T m : ReflectionUtils.getDeclaredMembers(type, clazz)) { if (m instanceof AnnotatedElement) { final A[] as = ((AnnotatedElement) m).getAnnotationsByType(annotation); if (as.length > 0) { members.put(m, as); } } } } return members; }
From source file:com.espertech.esper.epl.core.ResultSetProcessorSimple.java
/** * Applies the select-clause to the given events returning the selected events. The number of events stays the * same, i.e. this method does not filter it just transforms the result set. * <p>//from w w w .j a va 2 s .c o m * Also applies a having clause. * @param exprProcessor - processes each input event and returns output event * @param events - input events * @param optionalHavingNode - supplies the having-clause expression * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream) * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set * @param exprEvaluatorContext context for expression evalauation * @return output events, one for each input event */ protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, Set<MultiKey<EventBean>> events, ExprEvaluator optionalHavingNode, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { LinkedList<EventBean> result = new LinkedList<EventBean>(); for (MultiKey<EventBean> key : events) { EventBean[] eventsPerStream = key.getArray(); Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if ((passesHaving == null) || (!passesHaving)) { continue; } EventBean resultEvent = exprProcessor.process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext); result.add(resultEvent); } if (!result.isEmpty()) { return result.toArray(new EventBean[result.size()]); } else { return null; } }
From source file:com.cyclopsgroup.waterview.web.RuntimeTreeNode.java
/** * Get node or child node by id// w w w . j av a 2 s . c om * * @param nodeId Node id * @return Node or null if not found */ public RuntimeTreeNode getNodeById(String nodeId) { LinkedList buffer = new LinkedList(); buffer.addLast(this); while (!buffer.isEmpty()) { RuntimeTreeNode node = (RuntimeTreeNode) buffer.removeFirst(); if (StringUtils.equals(nodeId, node.getNodeId())) { return node; } buffer.addAll(node.children.values()); } return null; }
From source file:org.apache.ddlutils.util.CallbackClosure.java
/** * {@inheritDoc}// ww w . jav a 2 s. co m */ public void execute(Object obj) throws DdlUtilsException { LinkedList queue = new LinkedList(); queue.add(obj.getClass()); while (!queue.isEmpty()) { Class type = (Class) queue.removeFirst(); Method callback = (Method) _callbacks.get(type); if (callback != null) { try { _parameters[_callbackTypePos] = obj; callback.invoke(_callee, _parameters); return; } catch (InvocationTargetException ex) { throw new DdlUtilsException(ex.getTargetException()); } catch (IllegalAccessException ex) { throw new DdlUtilsException(ex); } } if ((type.getSuperclass() != null) && !type.getSuperclass().equals(Object.class)) { queue.add(type.getSuperclass()); } Class[] baseInterfaces = type.getInterfaces(); if (baseInterfaces != null) { for (int idx = 0; idx < baseInterfaces.length; idx++) { queue.add(baseInterfaces[idx]); } } } }
From source file:org.jumpmind.db.util.CallbackClosure.java
/** * {@inheritDoc}/*from w w w .j a v a 2 s . c o m*/ */ public void execute(Object obj) throws DdlException { LinkedList queue = new LinkedList(); queue.add(obj.getClass()); while (!queue.isEmpty()) { Class type = (Class) queue.removeFirst(); Method callback = (Method) _callbacks.get(type); if (callback != null) { try { _parameters[_callbackTypePos] = obj; callback.invoke(_callee, _parameters); return; } catch (InvocationTargetException ex) { throw new DdlException(ex.getTargetException()); } catch (IllegalAccessException ex) { throw new DdlException(ex); } } if ((type.getSuperclass() != null) && !type.getSuperclass().equals(Object.class)) { queue.add(type.getSuperclass()); } Class[] baseInterfaces = type.getInterfaces(); if (baseInterfaces != null) { for (int idx = 0; idx < baseInterfaces.length; idx++) { queue.add(baseInterfaces[idx]); } } } }