@Test public void testEmptyQueue() { Queue<Object> queue = QueueUtils.emptyQueue(); assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue); assertTrue("Returned queue is not empty.", queue.isEmpty()); try { queue.add(new Object()); fail("Expecting UnsupportedOperationException for empty queue."); } catch (final UnsupportedOperationException ex) { } }
@SuppressWarnings("unchecked") public static <E> Queue<E> emptyQueue() { return (Queue<E>) EMPTY_QUEUE; }
QueueUtils { @SuppressWarnings("unchecked") public static <E> Queue<E> emptyQueue() { return (Queue<E>) EMPTY_QUEUE; } }
QueueUtils { @SuppressWarnings("unchecked") public static <E> Queue<E> emptyQueue() { return (Queue<E>) EMPTY_QUEUE; } private  QueueUtils(); }
QueueUtils { @SuppressWarnings("unchecked") public static <E> Queue<E> emptyQueue() { return (Queue<E>) EMPTY_QUEUE; } private  QueueUtils(); static Queue<E> unmodifiableQueue(final Queue<? extends E> queue); static Queue<E> predicatedQueue(final Queue<E> queue, final Predicate<? super E> predicate); static Queue<E> transformingQueue(final Queue<E> queue,
                                                 final Transformer<? super E, ? extends E> transformer); @SuppressWarnings("unchecked") // OK, empty queue is compatible with any type static Queue<E> emptyQueue(); }
QueueUtils { @SuppressWarnings("unchecked") public static <E> Queue<E> emptyQueue() { return (Queue<E>) EMPTY_QUEUE; } private  QueueUtils(); static Queue<E> unmodifiableQueue(final Queue<? extends E> queue); static Queue<E> predicatedQueue(final Queue<E> queue, final Predicate<? super E> predicate); static Queue<E> transformingQueue(final Queue<E> queue,
                                                 final Transformer<? super E, ? extends E> transformer); @SuppressWarnings("unchecked") // OK, empty queue is compatible with any type static Queue<E> emptyQueue(); @SuppressWarnings("rawtypes") // OK, empty queue is compatible with any type
    static final Queue EMPTY_QUEUE; }