Example usage for java.util Queue addAll

List of usage examples for java.util Queue addAll

Introduction

In this page you can find the example usage for java.util Queue addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this collection (optional operation).

Usage

From source file:org.eclipse.scada.da.utils.daemon.DaemonStarter.java

public static void main(final String[] args) throws Exception {
    if (args.length == 0) {
        throw new RuntimeException("syntax: DaemonStarter <daemon class name>");
    }//from  w  ww  .ja va  2 s.c  o  m

    final Queue<String> argList = new LinkedList<String>();
    argList.addAll(Arrays.asList(args));

    new DaemonStarter(Class.forName(argList.poll()), argList.toArray(new String[0]));

    while (true) {
        Thread.sleep(1000);
    }
}

From source file:Main.java

public static <T> Queue<T> unicon(Queue<T> queue1, Queue<T> queue2) {
    Queue queue = new LinkedList();
    queue.addAll(queue1);
    queue.addAll(queue2);//www . j  av  a2  s . co m
    return queue;
}

From source file:Main.java

public final static <T> Queue<T> unicon(Queue<T> queue1, Queue<T> queue2) {
    Queue queue = new LinkedList();
    queue.addAll(queue1);
    queue.addAll(queue2);/* w w w. jav  a  2  s  . c  om*/
    return queue;
}

From source file:org.jbpm.services.task.jaxb.ComparePair.java

public static void compareOrig(Object origObj, Object newObj, Class objClass) {
    ComparePair compare = new ComparePair(origObj, newObj, objClass);
    Queue<ComparePair> compares = new LinkedList<ComparePair>();
    compares.add(compare);//from  ww w .j a  v  a2s  .  c  o m
    while (!compares.isEmpty()) {
        compares.addAll(compares.poll().compare());
    }
}

From source file:org.jspringbot.keyword.expression.ELUtils.java

public static Object doCase(Object... args) {
    Object defaultValue = null;//from  ww w.  j a  va 2  s . c  o m

    Queue<Object> arguments = new LinkedList<Object>();
    arguments.addAll(Arrays.asList(args));

    while (!arguments.isEmpty()) {
        if (arguments.size() > 1) {
            boolean condition = (Boolean) arguments.remove();
            Object value = arguments.remove();
            if (condition) {
                return value;
            }
        } else {
            // default
            return arguments.remove();
        }
    }

    return defaultValue;
}

From source file:org.jspringbot.keyword.expression.ELUtils.java

public static Object doMap(Object... args) {
    Object defaultValue = null;//from   w w w.ja v a2 s. c  o m

    Queue<Object> arguments = new LinkedList<Object>();
    arguments.addAll(Arrays.asList(args));

    Object variable = arguments.remove();

    while (!arguments.isEmpty()) {
        if (arguments.size() > 1) {
            Object variableValue = arguments.remove();
            Object mapValue = arguments.remove();
            if (variable.equals(variableValue)) {
                return mapValue;
            }
        } else {
            // default
            return arguments.remove();
        }
    }

    return defaultValue;
}

From source file:fr.inria.atlanmod.emf.graphs.Connectedness.java

/**
 * Returns the {@link Set} of {@link EObject}s that can be reached by
 * navigating {@link EReference}s, starting from <code>initialEObject</code>
 * /*w w  w  .j  av  a  2 s.  co m*/
 * @param initialEObject
 *            The initial {@link EObject}
 * @return The {@link Set} of reachable {@link EObject}s
 */
private static Set<EObject> getReachableEObjects(EObject initialEObject) {
    Set<EObject> visited = new HashSet<>();
    Queue<EObject> next = new LinkedList<EObject>();
    next.add(initialEObject);

    while (!next.isEmpty()) {
        EObject activeEObject = next.poll();
        if (visited.add(activeEObject)) {
            next.addAll(activeEObject.eContents());
            next.addAll(activeEObject.eCrossReferences());
        }
    }

    return visited;
}

From source file:Main.java

public static <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> aClazz) {
    //Check class hierarchy
    for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
        T anno = c.getAnnotation(aClazz);
        if (anno != null) {
            return anno;
        }//from w w w . ja  v a  2s. com
    }

    //Check interfaces (breadth first)
    Queue<Class<?>> q = new LinkedList<Class<?>>();
    q.add(clazz);
    while (!q.isEmpty()) {
        Class<?> c = q.remove();
        if (c != null) {
            if (c.isInterface()) {
                T anno = c.getAnnotation(aClazz);
                if (anno != null) {
                    return anno;
                }
            } else {
                q.add(c.getSuperclass());
            }
            q.addAll(Arrays.asList(c.getInterfaces()));
        }
    }

    return null;
}

From source file:org.kuali.rice.krad.uif.lifecycle.ViewLifecycleUtils.java

/**
 * Return the lifecycle elements of the specified type from the given list
 *
 * <p>//from   w w  w  .j  a  va 2s .  c om
 * Elements that match, implement or are extended from the specified {@code elementType} are
 * returned in the result. If an element is a parent to other elements then these child elements
 * are searched for matching types as well.
 * </p>
 *
 * @param items list of elements from which to search
 * @param elementType the class or interface of the element type to return
 * @param <T> the type of the elements that are returned
 * @return List of matching elements
 */
public static <T extends LifecycleElement> List<T> getElementsOfTypeDeep(
        Collection<? extends LifecycleElement> items, Class<T> elementType) {
    if (items == null) {
        return Collections.emptyList();
    }

    List<T> elements = Collections.emptyList();

    @SuppressWarnings("unchecked")
    Queue<LifecycleElement> elementQueue = RecycleUtils.getInstance(LinkedList.class);
    elementQueue.addAll(items);

    try {
        while (!elementQueue.isEmpty()) {
            LifecycleElement currentElement = elementQueue.poll();
            if (currentElement == null) {
                continue;
            }

            if (elementType.isInstance(currentElement)) {
                if (elements.isEmpty()) {
                    elements = new ArrayList<T>();
                }

                elements.add(elementType.cast(currentElement));
            }

            elementQueue.addAll(getElementsForLifecycle(currentElement).values());
        }
    } finally {
        elementQueue.clear();
        RecycleUtils.recycle(elementQueue);
    }
    return elements;
}

From source file:com.streamsets.pipeline.lib.util.ProtobufTypeUtil.java

private static List<DescriptorProtos.DescriptorProto> getAllMessageTypesInDescriptorProto(
        DescriptorProtos.FileDescriptorProto fileDescriptorProto) {
    Queue<DescriptorProtos.DescriptorProto> queue = new LinkedList<>();
    queue.addAll(fileDescriptorProto.getMessageTypeList());
    List<DescriptorProtos.DescriptorProto> result = new ArrayList<>();
    while (!queue.isEmpty()) {
        DescriptorProtos.DescriptorProto descriptorProto = queue.poll();
        queue.addAll(descriptorProto.getNestedTypeList());
        result.add(descriptorProto);//  w w w .j a  va  2  s .  c o m
    }
    return result;
}