    @Test
    public void testGlobalLengthValueLengthValueValueUsesToStringBuilderChops2() {
        this.buildAndCheck(this.builder()//
                .globalLength(15)//
                .valueLength(5)//
                .value("1234567") //
                .value(builder -> {
                    builder.valueLength(6); //
                    assertEquals(5, builder.valueLength, "valueLength"); // increase ignored.

                    assertEquals(builder.buffer.length() + 5, builder.globalLength, "globalLength");

                    builder.value("abcdefghij"); // expected "abcde" to be added.
                    builder.value("IGNORED");
                })//
                .value("1234567"), "12345abcde12345");
    }

    @Test
    public void testGlobalLengthValueLengthValueValueUsesToStringBuilderChops2() {
        this.buildAndCheck(this.builder()//
                .globalLength(15)//
                .valueLength(5)//
                .value("1234567") //
                .value(new UsesToStringBuilder() {

                    @Override
                    public void buildToString(final ToStringBuilder builder) {
                        builder.valueLength(6); //
                        assertEquals(5, builder.valueLength, "valueLength"); // increase ignored.

                        assertEquals(builder.buffer.length() + 5, builder.globalLength, "globalLength");

                        builder.value("abcdefghij"); // expected "abcde" to be added.
                        builder.value("IGNORED");
                    }
                })//
                .value("1234567"), "12345abcde12345");
    }

Replace Anonymous With Lambda walkingkooka.ToStringBuilderTest.testGlobalLengthValueLengthValueValueUsesToStringBuilderChops2.buildAndCheck.value.value.new UsesToStringBuilder with builder -> {builder.valueLength(6); in method public testGlobalLengthValueLengthValueValueUsesToStringBuilderChops2() : void from class walkingkooka.ToStringBuilderTest


    private UsesToStringBuilder usesToStringBuilder(final String label, final Object value) {
        return builder -> {
            if (null != label) {
                builder.label(label);
            }
            builder.value(value);
        };
    }

    private UsesToStringBuilder usesToStringBuilder(final String label, final Object value) {
        return new UsesToStringBuilder() {

            @Override
            public void buildToString(final ToStringBuilder builder) {
                if (null != label) {
                    builder.label(label);
                }
                builder.value(value);
            }
        };
    }

Replace Anonymous With Lambda walkingkooka.ToStringBuilderTest.usesToStringBuilder.new UsesToStringBuilder with builder -> {if(null != label){builder.label(label); in method private usesToStringBuilder(label String, value Object) : UsesToStringBuilder from class walkingkooka.ToStringBuilderTest


    private Builder<String> builder(final String product) {
        return () -> product;
    }

    private Builder<String> builder(final String product) {
        return new Builder<>() {
            @Override
            public String build() throws BuilderException {
                return product;
            }
        };
    }

Replace Anonymous With Lambda walkingkooka.build.BuilderTestingTest.builder.new Builder<> with () -> product in method private builder(product String) : Builder<String> from class walkingkooka.build.BuilderTestingTest


    private Builder<String> builderBuildThrows(final String message) {
        return () -> {
            throw new BuilderException(message);
        };
    }

    private Builder<String> builderBuildThrows(final String message) {
        return new Builder<>() {
            @Override
            public String build() throws BuilderException {
                throw new BuilderException(message);
            }
        };
    }

Replace Anonymous With Lambda walkingkooka.build.BuilderTestingTest.builderBuildThrows.new Builder<> with () -> {throw new BuilderException(message); in method private builderBuildThrows(message String) : Builder<String> from class walkingkooka.build.BuilderTestingTest


    /**
     * Creates a new {@link FakeIterable}
     */
    static <T> FakeIterable<T> create() {
        return new FakeIterable<>();
    }

    /**
     * Creates a new {@link FakeIterable}
     */
    static <T> FakeIterable<T> create() {
        return new FakeIterable<T>();
    }

Replace Generic With Diamond FakeIterable<T> with FakeIterable<> in method package create() : FakeIterable<T> from class walkingkooka.collect.iterable.FakeIterable


    /**
     * Creates a new {@link IteratorIterable}.
     */
    static <T> IteratorIterable<T> with(final Iterator<T> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        return new IteratorIterable<>(iterator);
    }

    /**
     * Creates a new {@link IteratorIterable}.
     */
    static <T> IteratorIterable<T> with(final Iterator<T> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        return new IteratorIterable<T>(iterator);
    }

Replace Generic With Diamond IteratorIterable<T> with IteratorIterable<> in method package with(iterator Iterator<T>) : IteratorIterable<T> from class walkingkooka.collect.iterable.IteratorIterable


    /**
     * Wraps the given {@link Iterable}
     */
    static <T> ReadOnlyIterable<T> wrap(final Iterable<T> iterable) {
        Objects.requireNonNull(iterable, "iterable");

        return new ReadOnlyIterable<>(iterable);
    }

    /**
     * Wraps the given {@link Iterable}
     */
    static <T> ReadOnlyIterable<T> wrap(final Iterable<T> iterable) {
        Objects.requireNonNull(iterable, "iterable");

        return new ReadOnlyIterable<T>(iterable);
    }

Replace Generic With Diamond ReadOnlyIterable<T> with ReadOnlyIterable<> in method package wrap(iterable Iterable<T>) : ReadOnlyIterable<T> from class walkingkooka.collect.iterable.ReadOnlyIterable


    static <T> Iterable<T> wrap(final Iterable<T> iterable) {
        Objects.requireNonNull(iterable, "iterable");

        Iterable<T> result;
        if (iterable instanceof ReverseIterable) {
            final ReverseIterable<T> reverseIterable = Cast.to(iterable);
            result = reverseIterable.iterable;
        } else {
            result = new ReverseIterable<>(iterable);
        }

        return result;
    }

    static <T> Iterable<T> wrap(final Iterable<T> iterable) {
        Objects.requireNonNull(iterable, "iterable");

        Iterable<T> result;
        if (iterable instanceof ReverseIterable) {
            final ReverseIterable<T> reverseIterable = Cast.to(iterable);
            result = reverseIterable.iterable;
        } else {
            result = new ReverseIterable<T>(iterable);
        }

        return result;
    }

Replace Generic With Diamond ReverseIterable<T> with ReverseIterable<> in method package wrap(iterable Iterable<T>) : Iterable<T> from class walkingkooka.collect.iterable.ReverseIterable


    @SafeVarargs
    static <T> ArrayIterator<T> with(final T... items) {
        Objects.requireNonNull(items, "items");

        return new ArrayIterator<>(items.clone());
    }

    @SafeVarargs
    static <T> ArrayIterator<T> with(final T... items) {
        Objects.requireNonNull(items, "items");

        return new ArrayIterator<T>(items.clone());
    }

Replace Generic With Diamond ArrayIterator<T> with ArrayIterator<> in method package with(items T...) : ArrayIterator<T> from class walkingkooka.collect.iterator.ArrayIterator


    static <E> EnumerationIterator<E> adapt(final Enumeration<E> enumeration) {
        Objects.requireNonNull(enumeration, "enumeration");

        return new EnumerationIterator<>(enumeration);
    }

    static <E> EnumerationIterator<E> adapt(final Enumeration<E> enumeration) {
        Objects.requireNonNull(enumeration, "enumeration");

        return new EnumerationIterator<E>(enumeration);
    }

Replace Generic With Diamond EnumerationIterator<E> with EnumerationIterator<> in method package adapt(enumeration Enumeration<E>) : EnumerationIterator<E> from class walkingkooka.collect.iterator.EnumerationIterator


    static <T> FakeIterator<T> create() {
        return new FakeIterator<>();
    }

    static <T> FakeIterator<T> create() {
        return new FakeIterator<T>();
    }

Replace Generic With Diamond FakeIterator<T> with FakeIterator<> in method package create() : FakeIterator<T> from class walkingkooka.collect.iterator.FakeIterator


    /**
     * Factory that creates a {@link LimitedIterator} skipping the with if the wrapped has a lesser
     * count.
     */
    static <E> LimitedIterator<E> wrap(final Iterator<E> iterator, final int count) {
        Objects.requireNonNull(iterator, "iterator");
        if (count < 0) {
            throw new IllegalArgumentException("Count " + count + " must be greater than 0");
        }

        LimitedIterator<E> result;

        for (; ; ) {
            Iterator<E> wrapped = iterator;
            if (iterator instanceof LimitedIterator) {
                final LimitedIterator<E> limited = Cast.to(iterator);
                if (count >= limited.countdown) {
                    result = limited;
                    break;
                }
                wrapped = limited.iterator;
            }
            result = new LimitedIterator<>(wrapped, count);
            break;
        }

        return result;
    }

    /**
     * Factory that creates a {@link LimitedIterator} skipping the with if the wrapped has a lesser
     * count.
     */
    static <E> LimitedIterator<E> wrap(final Iterator<E> iterator, final int count) {
        Objects.requireNonNull(iterator, "iterator");
        if (count < 0) {
            throw new IllegalArgumentException("Count " + count + " must be greater than 0");
        }

        LimitedIterator<E> result;

        for (; ; ) {
            Iterator<E> wrapped = iterator;
            if (iterator instanceof LimitedIterator) {
                final LimitedIterator<E> limited = Cast.to(iterator);
                if (count >= limited.countdown) {
                    result = limited;
                    break;
                }
                wrapped = limited.iterator;
            }
            result = new LimitedIterator<E>(wrapped, count);
            break;
        }

        return result;
    }

Replace Generic With Diamond LimitedIterator<E> with LimitedIterator<> in method package wrap(iterator Iterator<E>, count int) : LimitedIterator<E> from class walkingkooka.collect.iterator.LimitedIterator


    static <E> OneIterator<E> with(final E value) {
        return new OneIterator<>(value);
    }

    static <E> OneIterator<E> with(final E value) {
        return new OneIterator<E>(value);
    }

Replace Generic With Diamond OneIterator<E> with OneIterator<> in method package with(value E) : OneIterator<E> from class walkingkooka.collect.iterator.OneIterator


    /**
     * Wraps the given {@link Iterator} only if it is not already a {@link ReadOnlyIterator}
     */
    static <T> ReadOnlyIterator<T> wrap(final Iterator<T> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        return iterator instanceof ReadOnlyIterator ?
                Cast.to(iterator) :
                new ReadOnlyIterator<>(iterator);
    }

    /**
     * Wraps the given {@link Iterator} only if it is not already a {@link ReadOnlyIterator}
     */
    static <T> ReadOnlyIterator<T> wrap(final Iterator<T> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        return iterator instanceof ReadOnlyIterator ?
                Cast.to(iterator) :
                new ReadOnlyIterator<T>(iterator);
    }

Replace Generic With Diamond ReadOnlyIterator<T> with ReadOnlyIterator<> in method package wrap(iterator Iterator<T>) : ReadOnlyIterator<T> from class walkingkooka.collect.iterator.ReadOnlyIterator


    /**
     * Before copying performs a check just in case the given {@link Iterator} is a {@link
     * ReverseIterator}. If it is then the iterator is unwrapped.
     */
    static <E> Iterator<E> with(final Iterator<E> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        Iterator<E> result;
        if (iterator instanceof ReverseIterator) {
            final ReverseIterator<E> reverseIterator = Cast.to(iterator);

            // return the Stack.iterator() and make it read only
            result = Iterators.readOnly(reverseIterator.stack.iterator());
        } else {
            final Stack<E> stack = Stacks.jdk();
            while (iterator.hasNext()) {
                stack.push(iterator.next());
            }
            result = new ReverseIterator<>(stack);
        }
        return result;
    }

    /**
     * Before copying performs a check just in case the given {@link Iterator} is a {@link
     * ReverseIterator}. If it is then the iterator is unwrapped.
     */
    static <E> Iterator<E> with(final Iterator<E> iterator) {
        Objects.requireNonNull(iterator, "iterator");

        Iterator<E> result;
        if (iterator instanceof ReverseIterator) {
            final ReverseIterator<E> reverseIterator = Cast.to(iterator);

            // return the Stack.iterator() and make it read only
            result = Iterators.readOnly(reverseIterator.stack.iterator());
        } else {
            final Stack<E> stack = Stacks.jdk();
            while (iterator.hasNext()) {
                stack.push(iterator.next());
            }
            result = new ReverseIterator<E>(stack);
        }
        return result;
    }

Replace Generic With Diamond ReverseIterator<E> with ReverseIterator<> in method package with(iterator Iterator<E>) : Iterator<E> from class walkingkooka.collect.iterator.ReverseIterator


    /**
     * {@see ArrayList}
     */
    public static <T> List<T> array() {
        return new ArrayList<>();
    }

    /**
     * {@see ArrayList}
     */
    public static <T> List<T> array() {
        return new ArrayList<T>();
    }

Replace Generic With Diamond ArrayList<T> with ArrayList<> in method public array() : List<T> from class walkingkooka.collect.list.Lists


    /**
     * {@see CopyOnWriteArrayList}
     */
    public static <T> CopyOnWriteArrayList<T> copyOnWrite() {
        return new CopyOnWriteArrayList<>();
    }

    /**
     * {@see CopyOnWriteArrayList}
     */
    public static <T> CopyOnWriteArrayList<T> copyOnWrite() {
        return new CopyOnWriteArrayList<T>();
    }

Replace Generic With Diamond CopyOnWriteArrayList<T> with CopyOnWriteArrayList<> in method public copyOnWrite() : CopyOnWriteArrayList<T> from class walkingkooka.collect.list.Lists


    /**
     * {@see LinkedList}
     */
    public static <T> List<T> linkedList() {
        return new LinkedList<>();
    }

    /**
     * {@see LinkedList}
     */
    public static <T> List<T> linkedList() {
        return new LinkedList<T>();
    }

Replace Generic With Diamond LinkedList<T> with LinkedList<> in method public linkedList() : List<T> from class walkingkooka.collect.list.Lists


    /**
     * {@see Vector}
     */
    public static <T> Vector<T> vector() {
        return new Vector<>();
    }

    /**
     * {@see Vector}
     */
    public static <T> Vector<T> vector() {
        return new Vector<T>();
    }

Replace Generic With Diamond Vector<T> with Vector<> in method public vector() : Vector<T> from class walkingkooka.collect.list.Lists


    static <K, V> Map<K, V> create() {
        return new FakeMap<>();
    }

    static <K, V> Map<K, V> create() {
        return new FakeMap<K, V>();
    }

Replace Generic With Diamond FakeMap<K,V> with FakeMap<> in method package create() : Map<K,V> from class walkingkooka.collect.map.FakeMap


    /**
     * {@see ConcurrentHashMap}
     */
    static public <K, V> ConcurrentMap<K, V> concurrent() {
        return new ConcurrentHashMap<>();
    }

    /**
     * {@see ConcurrentHashMap}
     */
    static public <K, V> ConcurrentMap<K, V> concurrent() {
        return new ConcurrentHashMap<K, V>();
    }

Replace Generic With Diamond ConcurrentHashMap<K,V> with ConcurrentHashMap<> in method public concurrent() : ConcurrentMap<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see HashMap}
     */
    static public <K, V> Map<K, V> hash() {
        return new HashMap<>();
    }

    /**
     * {@see HashMap}
     */
    static public <K, V> Map<K, V> hash() {
        return new HashMap<K, V>();
    }

Replace Generic With Diamond HashMap<K,V> with HashMap<> in method public hash() : Map<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see IdentityHashMap}
     */
    static public <K, V> Map<K, V> identity() {
        return new IdentityHashMap<>();
    }

    /**
     * {@see IdentityHashMap}
     */
    static public <K, V> Map<K, V> identity() {
        return new IdentityHashMap<K, V>();
    }

Replace Generic With Diamond IdentityHashMap<K,V> with IdentityHashMap<> in method public identity() : Map<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see TreeMap}
     */
    static public <K, V> NavigableMap<K, V> navigable() {
        return new TreeMap<>();
    }

    /**
     * {@see TreeMap}
     */
    static public <K, V> NavigableMap<K, V> navigable() {
        return new TreeMap<K, V>();
    }

Replace Generic With Diamond TreeMap<K,V> with TreeMap<> in method public navigable() : NavigableMap<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see TreeMap}
     */
    static public <K, V> NavigableMap<K, V> navigable(final Comparator<? super K> comparator) {
        return new TreeMap<>(comparator);
    }

    /**
     * {@see TreeMap}
     */
    static public <K, V> NavigableMap<K, V> navigable(final Comparator<? super K> comparator) {
        return new TreeMap<K, V>(comparator);
    }

Replace Generic With Diamond TreeMap<K,V> with TreeMap<> in method public navigable(comparator Comparator<? super K>) : NavigableMap<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see LinkedHashMap}
     */
    static public <K, V> Map<K, V> ordered() {
        return new LinkedHashMap<>();
    }

    /**
     * {@see LinkedHashMap}
     */
    static public <K, V> Map<K, V> ordered() {
        return new LinkedHashMap<K, V>();
    }

Replace Generic With Diamond LinkedHashMap<K,V> with LinkedHashMap<> in method public ordered() : Map<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see TreeMap}
     */
    static public <K, V> SortedMap<K, V> sorted() {
        return new TreeMap<>();
    }

    /**
     * {@see TreeMap}
     */
    static public <K, V> SortedMap<K, V> sorted() {
        return new TreeMap<K, V>();
    }

Replace Generic With Diamond TreeMap<K,V> with TreeMap<> in method public sorted() : SortedMap<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see TreeMap}
     */
    static public <K, V> SortedMap<K, V> sorted(final Comparator<? super K> comparator) {
        return new TreeMap<>(comparator);
    }

    /**
     * {@see TreeMap}
     */
    static public <K, V> SortedMap<K, V> sorted(final Comparator<? super K> comparator) {
        return new TreeMap<K, V>(comparator);
    }

Replace Generic With Diamond TreeMap<K,V> with TreeMap<> in method public sorted(comparator Comparator<? super K>) : SortedMap<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see WeakHashMap}
     */
    static public <K, V> Map<K, V> weak() {
        return new WeakHashMap<>();
    }

    /**
     * {@see WeakHashMap}
     */
    static public <K, V> Map<K, V> weak() {
        return new WeakHashMap<K, V>();
    }

Replace Generic With Diamond WeakHashMap<K,V> with WeakHashMap<> in method public weak() : Map<K,V> from class walkingkooka.collect.map.Maps


    /**
     * {@see HashSet}
     */
    public static <E> Set<E> hash() {
        return new HashSet<>();
    }

    /**
     * {@see HashSet}
     */
    public static <E> Set<E> hash() {
        return new HashSet<E>();
    }

Replace Generic With Diamond HashSet<E> with HashSet<> in method public hash() : Set<E> from class walkingkooka.collect.set.Sets


    /**
     * {@see TreeSet}
     */
    public static <E> NavigableSet<E> navigable() {
        return new TreeSet<>();
    }

    /**
     * {@see TreeSet}
     */
    public static <E> NavigableSet<E> navigable() {
        return new TreeSet<E>();
    }

Replace Generic With Diamond TreeSet<E> with TreeSet<> in method public navigable() : NavigableSet<E> from class walkingkooka.collect.set.Sets


    /**
     * {@see LinkedHashSet}
     */
    public static <E> Set<E> ordered() {
        return new LinkedHashSet<>();
    }

    /**
     * {@see LinkedHashSet}
     */
    public static <E> Set<E> ordered() {
        return new LinkedHashSet<E>();
    }

Replace Generic With Diamond LinkedHashSet<E> with LinkedHashSet<> in method public ordered() : Set<E> from class walkingkooka.collect.set.Sets


    /**
     * {@see TreeSet}
     */
    public static <E> SortedSet<E> sorted() {
        return new TreeSet<>();
    }

    /**
     * {@see TreeSet}
     */
    public static <E> SortedSet<E> sorted() {
        return new TreeSet<E>();
    }

Replace Generic With Diamond TreeSet<E> with TreeSet<> in method public sorted() : SortedSet<E> from class walkingkooka.collect.set.Sets


    /**
     * {@see TreeSet}
     */
    public static <E> SortedSet<E> sorted(final Comparator<? super E> comparator) {
        return new TreeSet<>(comparator);
    }

    /**
     * {@see TreeSet}
     */
    public static <E> SortedSet<E> sorted(final Comparator<? super E> comparator) {
        return new TreeSet<E>(comparator);
    }

Replace Generic With Diamond TreeSet<E> with TreeSet<> in method public sorted(comparator Comparator<? super E>) : SortedSet<E> from class walkingkooka.collect.set.Sets


    /**
     * Creates an empty {@link ArrayListStack}.
     */
    static <T> ArrayListStack<T> create() {
        return new ArrayListStack<>();
    }

    /**
     * Creates an empty {@link ArrayListStack}.
     */
    static <T> ArrayListStack<T> create() {
        return new ArrayListStack<T>();
    }

Replace Generic With Diamond ArrayListStack<T> with ArrayListStack<> in method package create() : ArrayListStack<T> from class walkingkooka.collect.stack.ArrayListStack


    /**
     * Creates a new {@link ArrayStack} with an array. The last it set to the end of the array
     */
    static <T> ArrayStack<T> with(final Object[] items) {
        return new ArrayStack<>(items, items.length);
    }

    /**
     * Creates a new {@link ArrayStack} with an array. The last it set to the end of the array
     */
    static <T> ArrayStack<T> with(final Object[] items) {
        return new ArrayStack<T>(items, items.length);
    }

Replace Generic With Diamond ArrayStack<T> with ArrayStack<> in method package with(items Object[]) : ArrayStack<T> from class walkingkooka.collect.stack.ArrayStack


    /**
     * If the array contains of element return an {@link EmptyArrayStack} otherwise create a new
     * {@link ArrayStack} sharing the array
     */
    @Override
    public Stack<T> pop() {
        Stack<T> stack;
        final int newLast = this.last - 1;
        if (0 == newLast) {
            stack = EmptyArrayStack.instance();
        } else {
            // share array but decrement last
            stack = new ArrayStack<>(this.array, newLast);
        }

        return stack;
    }

    /**
     * If the array contains of element return an {@link EmptyArrayStack} otherwise create a new
     * {@link ArrayStack} sharing the array
     */
    @Override
    public Stack<T> pop() {
        Stack<T> stack;
        final int newLast = this.last - 1;
        if (0 == newLast) {
            stack = EmptyArrayStack.instance();
        } else {
            // share array but decrement last
            stack = new ArrayStack<T>(this.array, newLast);
        }

        return stack;
    }

Replace Generic With Diamond ArrayStack<T> with ArrayStack<> in method public pop() : Stack<T> from class walkingkooka.collect.stack.ArrayStack


    /**
     * Copies the old array into a new of appends the item and returns a new {@link ArrayStack}.
     */
    @Override
    public ArrayStack<T> push(final T item) {
        final int last = this.last;
        final int newLast = last + 1;

        // copy the old array into the first slots
        final Object[] newArray = new Object[newLast];
        System.arraycopy(this.array, 0, newArray, 0, last);

        // save the new item in the last slot
        newArray[last] = item;

        return new ArrayStack<>(newArray, newLast);
    }

    /**
     * Copies the old array into a new of appends the item and returns a new {@link ArrayStack}.
     */
    @Override
    public ArrayStack<T> push(final T item) {
        final int last = this.last;
        final int newLast = last + 1;

        // copy the old array into the first slots
        final Object[] newArray = new Object[newLast];
        System.arraycopy(this.array, 0, newArray, 0, last);

        // save the new item in the last slot
        newArray[last] = item;

        return new ArrayStack<T>(newArray, newLast);
    }

Replace Generic With Diamond ArrayStack<T> with ArrayStack<> in method public push(item T) : ArrayStack<T> from class walkingkooka.collect.stack.ArrayStack


    /**
     * If the {@link Iterator} is empty this will be returned otherwise the items are added and a
     * new {@link ArrayStack} is created.
     */
    @Override
    public ArrayStack<T> pushAll(final Iterator<T> items) {
        Objects.requireNonNull(items, "items");

        ArrayStack<T> stack = this;
        if (items.hasNext()) {
            // iterator is not empty
            final Collection<T> pushing = Lists.array();
            do {
                pushing.add(items.next());
            } while (items.hasNext());

            final int last = this.last;
            final int pushed = pushing.size();
            final int newLast = last + pushed;

            // copy the old array into the first slots
            final Object[] newArray = new Object[newLast];
            System.arraycopy(this.array, 0, newArray, 0, last);

            // append the iterator items onto the $newArray
            int i = last;
            for (final T item : pushing) {
                newArray[i] = item;
                i++;
            }

            stack = new ArrayStack<>(newArray, newLast);
        }

        return stack;
    }

    /**
     * If the {@link Iterator} is empty this will be returned otherwise the items are added and a
     * new {@link ArrayStack} is created.
     */
    @Override
    public ArrayStack<T> pushAll(final Iterator<T> items) {
        Objects.requireNonNull(items, "items");

        ArrayStack<T> stack = this;
        if (items.hasNext()) {
            // iterator is not empty
            final Collection<T> pushing = Lists.array();
            do {
                pushing.add(items.next());
            } while (items.hasNext());

            final int last = this.last;
            final int pushed = pushing.size();
            final int newLast = last + pushed;

            // copy the old array into the first slots
            final Object[] newArray = new Object[newLast];
            System.arraycopy(this.array, 0, newArray, 0, last);

            // append the iterator items onto the $newArray
            int i = last;
            for (final T item : pushing) {
                newArray[i] = item;
                i++;
            }

            stack = new ArrayStack<T>(newArray, newLast);
        }

        return stack;
    }

Replace Generic With Diamond ArrayStack<T> with ArrayStack<> in method public pushAll(items Iterator<T>) : ArrayStack<T> from class walkingkooka.collect.stack.ArrayStack


    static <E> ArrayStackIterator<E> with(final ArrayStack<E> stack) {
        return new ArrayStackIterator<>(stack);
    }

    static <E> ArrayStackIterator<E> with(final ArrayStack<E> stack) {
        return new ArrayStackIterator<E>(stack);
    }

Replace Generic With Diamond ArrayStackIterator<E> with ArrayStackIterator<> in method package with(stack ArrayStack<E>) : ArrayStackIterator<E> from class walkingkooka.collect.stack.ArrayStackIterator


    static <T> FakeStack<T> create() {
        return new FakeStack<>();
    }

    static <T> FakeStack<T> create() {
        return new FakeStack<T>();
    }

Replace Generic With Diamond FakeStack<T> with FakeStack<> in method package create() : FakeStack<T> from class walkingkooka.collect.stack.FakeStack


    /**
     * Factory that creates an empty {@link JdkStackStack}
     */
    static <T> JdkStackStack<T> create() {
        return new JdkStackStack<>(new java.util.Stack<>());
    }

    /**
     * Factory that creates an empty {@link JdkStackStack}
     */
    static <T> JdkStackStack<T> create() {
        return new JdkStackStack<T>(new java.util.Stack<T>());
    }

Replace Generic With Diamond JdkStackStack<T> with JdkStackStack<> in method package create() : JdkStackStack<T> from class walkingkooka.collect.stack.JdkStackStack


    /**
     * Wraps another {@link Stack} making it unreadable.
     */
    static <T> ReadOnlyStack<T> wrap(final Stack<T> stack) {
        Objects.requireNonNull(stack, "stack");

        return stack instanceof ReadOnlyStack ?
                Cast.to(stack) :
                new ReadOnlyStack<>(stack);
    }

    /**
     * Wraps another {@link Stack} making it unreadable.
     */
    static <T> ReadOnlyStack<T> wrap(final Stack<T> stack) {
        Objects.requireNonNull(stack, "stack");

        return stack instanceof ReadOnlyStack ?
                Cast.to(stack) :
                new ReadOnlyStack<T>(stack);
    }

Replace Generic With Diamond ReadOnlyStack<T> with ReadOnlyStack<> in method package wrap(stack Stack<T>) : ReadOnlyStack<T> from class walkingkooka.collect.stack.ReadOnlyStack


    /**
     * Wraps another {@link Stack} making it unreadable.
     */
    static <T> UnreadableStack<T> wrap(final Stack<T> stack) {
        Objects.requireNonNull(stack, "stack");

        return stack instanceof UnreadableStack ?
                Cast.to(stack) :
                new UnreadableStack<>(stack);
    }

    /**
     * Wraps another {@link Stack} making it unreadable.
     */
    static <T> UnreadableStack<T> wrap(final Stack<T> stack) {
        Objects.requireNonNull(stack, "stack");

        return stack instanceof UnreadableStack ?
                Cast.to(stack) :
                new UnreadableStack<T>(stack);
    }

Replace Generic With Diamond UnreadableStack<T> with UnreadableStack<> in method package wrap(stack Stack<T>) : UnreadableStack<T> from class walkingkooka.collect.stack.UnreadableStack


    static <T> FakeComparator<T> create() {
        return new FakeComparator<>();
    }

    static <T> FakeComparator<T> create() {
        return new FakeComparator<T>();
    }

Replace Generic With Diamond FakeComparator<T> with FakeComparator<> in method package create() : FakeComparator<T> from class walkingkooka.compare.FakeComparator


    /**
     * Creates a {@link NormalizingCharSequenceComparator}
     */
    static <S extends CharSequence> NormalizingCharSequenceComparator<S> with(
            final CharPredicate predicate) {
        Objects.requireNonNull(predicate, "predicate");

        return new NormalizingCharSequenceComparator<>(predicate);
    }

    /**
     * Creates a {@link NormalizingCharSequenceComparator}
     */
    static <S extends CharSequence> NormalizingCharSequenceComparator<S> with(
            final CharPredicate predicate) {
        Objects.requireNonNull(predicate, "predicate");

        return new NormalizingCharSequenceComparator<S>(predicate);
    }

Replace Generic With Diamond NormalizingCharSequenceComparator<S> with NormalizingCharSequenceComparator<> in method package with(predicate CharPredicate) : NormalizingCharSequenceComparator<S> from class walkingkooka.compare.NormalizingCharSequenceComparator


    /**
     * A {@link Range} that holds a single value.
     */
    public static <C extends Comparable<C>> Range<C> singleton(final C value) {
        return new Range<>(RangeBound.inclusive(value), RangeBound.inclusive(value));
    }

    /**
     * A {@link Range} that holds a single value.
     */
    public static <C extends Comparable<C>> Range<C> singleton(final C value) {
        return new Range<C>(RangeBound.inclusive(value), RangeBound.inclusive(value));
    }

Replace Generic With Diamond Range<C> with Range<> in method public singleton(value C) : Range<C> from class walkingkooka.compare.Range


    /**
     * A {@link Range} that matches all values less than but not including the given value.
     */
    public static <C extends Comparable<C>> Range<C> lessThan(final C value) {
        return new Range<>(RangeBound.all(), RangeBound.exclusive(value));
    }

    /**
     * A {@link Range} that matches all values less than but not including the given value.
     */
    public static <C extends Comparable<C>> Range<C> lessThan(final C value) {
        return new Range<C>(RangeBound.all(), RangeBound.exclusive(value));
    }

Replace Generic With Diamond Range<C> with Range<> in method public lessThan(value C) : Range<C> from class walkingkooka.compare.Range


    /**
     * A {@link Range} that matches all values less than and including the given value.
     */
    public static <C extends Comparable<C>> Range<C> lessThanEquals(final C value) {
        return new Range<>(RangeBound.all(), RangeBound.inclusive(value));
    }

    /**
     * A {@link Range} that matches all values less than and including the given value.
     */
    public static <C extends Comparable<C>> Range<C> lessThanEquals(final C value) {
        return new Range<C>(RangeBound.all(), RangeBound.inclusive(value));
    }

Replace Generic With Diamond Range<C> with Range<> in method public lessThanEquals(value C) : Range<C> from class walkingkooka.compare.Range


    /**
     * A {@link Range} that matches all values greater than but not including the given value.
     */
    public static <C extends Comparable<C>> Range<C> greaterThan(final C value) {
        return new Range<>(RangeBound.exclusive(value), RangeBound.all());
    }

    /**
     * A {@link Range} that matches all values greater than but not including the given value.
     */
    public static <C extends Comparable<C>> Range<C> greaterThan(final C value) {
        return new Range<C>(RangeBound.exclusive(value), RangeBound.all());
    }

Replace Generic With Diamond Range<C> with Range<> in method public greaterThan(value C) : Range<C> from class walkingkooka.compare.Range


    /**
     * A {@link Range} that matches all values greater than and including the given value.
     */
    public static <C extends Comparable<C>> Range<C> greaterThanEquals(final C value) {
        return new Range<>(RangeBound.inclusive(value), RangeBound.all());
    }

    /**
     * A {@link Range} that matches all values greater than and including the given value.
     */
    public static <C extends Comparable<C>> Range<C> greaterThanEquals(final C value) {
        return new Range<C>(RangeBound.inclusive(value), RangeBound.all());
    }

Replace Generic With Diamond Range<C> with Range<> in method public greaterThanEquals(value C) : Range<C> from class walkingkooka.compare.Range


    /**
     * Creates a new {@link Range} after verifying the lower is less than the  upper bounds.
     */
    private Range<C> replace(final RangeBound<C> lower, final Range<C> other) {
        if (lower.isExclusive()) {
            throw new IllegalArgumentException("Invalid range bounds " + this + " < " + other);
        }

        return new Range<>(lower, lower);
    }

    /**
     * Creates a new {@link Range} after verifying the lower is less than the  upper bounds.
     */
    private Range<C> replace(final RangeBound<C> lower, final Range<C> other) {
        if (lower.isExclusive()) {
            throw new IllegalArgumentException("Invalid range bounds " + this + " < " + other);
        }

        return new Range<C>(lower, lower);
    }

Replace Generic With Diamond Range<C> with Range<> in method private replace(lower RangeBound<C>, other Range<C>) : Range<C> from class walkingkooka.compare.Range


    private Range<C> replace0(final RangeBound<C> lower, final RangeBound<C> upper) {
        if (lower.equals(upper) && lower.isExclusive()) {
            throw new IllegalArgumentException("Invalid range bounds " + upper + " < " + lower);
        }

        if (lower.min(upper) != lower) {
            throw new IllegalArgumentException("Invalid range bounds " + upper + " < " + lower);
        }

        if (upper.max(lower) != upper) {
            throw new IllegalArgumentException("Invalid range bounds " + lower + " > " + upper);
        }

        return new Range<>(lower, upper);
    }

    private Range<C> replace0(final RangeBound<C> lower, final RangeBound<C> upper) {
        if (lower.equals(upper) && lower.isExclusive()) {
            throw new IllegalArgumentException("Invalid range bounds " + upper + " < " + lower);
        }

        if (lower.min(upper) != lower) {
            throw new IllegalArgumentException("Invalid range bounds " + upper + " < " + lower);
        }

        if (upper.max(lower) != upper) {
            throw new IllegalArgumentException("Invalid range bounds " + lower + " > " + upper);
        }

        return new Range<C>(lower, upper);
    }

Replace Generic With Diamond Range<C> with Range<> in method private replace0(lower RangeBound<C>, upper RangeBound<C>) : Range<C> from class walkingkooka.compare.Range


    /**
     * Creates a {@link RangeBoundExclusive}.
     */
    static <C extends Comparable<C>> RangeBoundExclusive<C> with(final C value) {
        checkValue(value);
        return new RangeBoundExclusive<>(value);
    }

    /**
     * Creates a {@link RangeBoundExclusive}.
     */
    static <C extends Comparable<C>> RangeBoundExclusive<C> with(final C value) {
        checkValue(value);
        return new RangeBoundExclusive<C>(value);
    }

Replace Generic With Diamond RangeBoundExclusive<C> with RangeBoundExclusive<> in method package with(value C) : RangeBoundExclusive<C> from class walkingkooka.compare.RangeBoundExclusive


    /**
     * Creates a {@link RangeBoundInclusive}.
     */
    static <C extends Comparable<C>> RangeBoundInclusive<C> with(final C value) {
        checkValue(value);
        return new RangeBoundInclusive<>(value);
    }

    /**
     * Creates a {@link RangeBoundInclusive}.
     */
    static <C extends Comparable<C>> RangeBoundInclusive<C> with(final C value) {
        checkValue(value);
        return new RangeBoundInclusive<C>(value);
    }

Replace Generic With Diamond RangeBoundInclusive<C> with RangeBoundInclusive<> in method package with(value C) : RangeBoundInclusive<C> from class walkingkooka.compare.RangeBoundInclusive


    /**
     * Factory that creates a new {@link ComparableComparisonRelationPredicate}
     */
    static <C extends Comparable<C>> ComparableComparisonRelationPredicate<C> with(final ComparisonRelation relation,
                                                                                final C right) {
        Objects.requireNonNull(relation, "relation");
        Objects.requireNonNull(right, "right");

        return new ComparableComparisonRelationPredicate<>(relation, right);
    }

    /**
     * Factory that creates a new {@link ComparableComparisonRelationPredicate}
     */
    static <C extends Comparable<C>> ComparableComparisonRelationPredicate<C> with(final ComparisonRelation relation,
                                                                                final C right) {
        Objects.requireNonNull(relation, "relation");
        Objects.requireNonNull(right, "right");

        return new ComparableComparisonRelationPredicate<C>(relation, right);
    }

Replace Generic With Diamond ComparableComparisonRelationPredicate<C> with ComparableComparisonRelationPredicate<> in method package with(relation ComparisonRelation, right C) : ComparableComparisonRelationPredicate<C> from class walkingkooka.predicate.ComparableComparisonRelationPredicate


    static <T> FakePredicate<T> create() {
        return new FakePredicate<>();
    }

    static <T> FakePredicate<T> create() {
        return new FakePredicate<T>();
    }

Replace Generic With Diamond FakePredicate<T> with FakePredicate<> in method package create() : FakePredicate<T> from class walkingkooka.predicate.FakePredicate


    static <T> Predicate<T> wrap(final Predicate<T> predicate) {
        Objects.requireNonNull(predicate, "predicate");

        return predicate instanceof Notable ? not(predicate) : new NotPredicate<>(predicate);
    }

    static <T> Predicate<T> wrap(final Predicate<T> predicate) {
        Objects.requireNonNull(predicate, "predicate");

        return predicate instanceof Notable ? not(predicate) : new NotPredicate<T>(predicate);
    }

Replace Generic With Diamond NotPredicate<T> with NotPredicate<> in method package wrap(predicate Predicate<T>) : Predicate<T> from class walkingkooka.predicate.NotPredicate


    /**
     * Creates a {@link ObjectEqualityPredicate}
     */
    static <T, U extends T> ObjectEqualityPredicate<T> with(final U value) {
        Objects.requireNonNull(value, "value");

        return new ObjectEqualityPredicate<>(value);
    }

    /**
     * Creates a {@link ObjectEqualityPredicate}
     */
    static <T, U extends T> ObjectEqualityPredicate<T> with(final U value) {
        Objects.requireNonNull(value, "value");

        return new ObjectEqualityPredicate<T>(value);
    }

Replace Generic With Diamond ObjectEqualityPredicate<T> with ObjectEqualityPredicate<> in method package with(value U) : ObjectEqualityPredicate<T> from class walkingkooka.predicate.ObjectEqualityPredicate


    /**
     * Package private to limit sub classing.
     */
    static <T> PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<T> with(final Comparator<? super T> comparator,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        check(comparator);

        return new PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<>(comparator, closeables);
    }

    /**
     * Package private to limit sub classing.
     */
    static <T> PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<T> with(final Comparator<? super T> comparator,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        check(comparator);

        return new PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<T>(comparator, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<> in method package with(comparator Comparator<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminal2MaxPushableStreamConsumer


    /**
     * Package private to limit sub classing.
     */
    static <T> PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<T> with(final Comparator<? super T> comparator,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        check(comparator);

        return new PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<>(comparator, closeables);
    }

    /**
     * Package private to limit sub classing.
     */
    static <T> PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<T> with(final Comparator<? super T> comparator,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        check(comparator);

        return new PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<T>(comparator, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<> in method package with(comparator Comparator<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminal2MinPushableStreamConsumer


    static <T> PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<>(predicate, closeables);
    }

    static <T> PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<T>(predicate, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<> in method package with(predicate Predicate<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminal3AllMatchPushableStreamConsumer


    static <T> PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<>(predicate, closeables);
    }

    static <T> PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<T>(predicate, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<> in method package with(predicate Predicate<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminal3AnyMatchPushableStreamConsumer


    static <T> PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<>(predicate, closeables);
    }

    static <T> PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<T> with(final Predicate<? super T> predicate,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(predicate, "predicate");

        return new PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<T>(predicate, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<> in method package with(predicate Predicate<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminal3NoneMatchPushableStreamConsumer


    static <T, A, R> PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<T, A, R> with(final Collector<? super T, A, R> collector,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(collector, "collector");

        return new PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<>(collector, closeables);
    }

    static <T, A, R> PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<T, A, R> with(final Collector<? super T, A, R> collector,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        Objects.requireNonNull(collector, "collector");

        return new PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<T, A, R>(collector, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<T,A,R> with PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<> in method package with(collector Collector<? super T,A,R>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer<T,A,R> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminalCollectorPushableStreamConsumer


    static <T> PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<T> with(final Consumer<? super T> action,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        return new PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<>(action, closeables);
    }

    static <T> PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<T> with(final Consumer<? super T> action,
                                                                                final PushableStreamConsumerCloseableCollection closeables) {
        return new PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<T>(action, closeables);
    }

Replace Generic With Diamond PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<T> with PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<> in method package with(action Consumer<? super T>, closeables PushableStreamConsumerCloseableCollection) : PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer<T> from class walkingkooka.stream.push.PushableStreamConsumerStreamTerminalForEachOrderedPushableStreamConsumer


    private static Set<Method> overridableMethods(final Class<?> type) {
        final Set<Class<?>> alreadyVisited = new HashSet<>();
        final Set<Method> methods = new TreeSet<>(new Comparator<>() {

            @Override
            public int compare(final Method method1, final Method method2) {
                int value;

                do {
                    value = method1.getName().compareTo(method2.getName());
                    if (0 != value) {
                        break;
                    }

                    final Class<?>[] parameterTypes1 = method1.getParameterTypes();
                    final Class<?>[] parameterTypes2 = method2.getParameterTypes();
                    value = parameterTypes1.length - parameterTypes2.length;
                    if (0 != value) {
                        break;
                    }
                    // HACK Need a better way to determine if a method overrides another generic method.
                    // for (int i = 0; i < parameterTypes1.length; i++) {
                    // value = parameterTypes1[i].getName().compareTo(parameterTypes2[i].getName());
                    // if (0 != value) {
                    // break;
                    // }
                    // }
                } while (false);

                return value;
            }
        });
        processImplementedInterfaces(type, alreadyVisited, methods);
        processClassAndImplementedInterfaces(type.getSuperclass(), alreadyVisited, methods);
        return methods;
    }

    private static Set<Method> overridableMethods(final Class<?> type) {
        final Set<Class<?>> alreadyVisited = new HashSet<Class<?>>();
        final Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() {

            @Override
            public int compare(final Method method1, final Method method2) {
                int value;

                do {
                    value = method1.getName().compareTo(method2.getName());
                    if (0 != value) {
                        break;
                    }

                    final Class<?>[] parameterTypes1 = method1.getParameterTypes();
                    final Class<?>[] parameterTypes2 = method2.getParameterTypes();
                    value = parameterTypes1.length - parameterTypes2.length;
                    if (0 != value) {
                        break;
                    }
                    // HACK Need a better way to determine if a method overrides another generic method.
                    // for (int i = 0; i < parameterTypes1.length; i++) {
                    // value = parameterTypes1[i].getName().compareTo(parameterTypes2[i].getName());
                    // if (0 != value) {
                    // break;
                    // }
                    // }
                } while (false);

                return value;
            }
        });
        processImplementedInterfaces(type, alreadyVisited, methods);
        processClassAndImplementedInterfaces(type.getSuperclass(), alreadyVisited, methods);
        return methods;
    }

Replace Generic With Diamond TreeSet<Method> with TreeSet<> in method private overridableMethods(type Class<?>) : Set<Method> from class walkingkooka.test.ClassMethodTesting


    /**
     * Creates a {@link CaseSensitivityCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityCharSequencePredicate<C> with(final C chars,
                                                                                final CaseSensitivity sensitivity) {
        Objects.requireNonNull(chars, "chars");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityCharSequencePredicate<>(chars, sensitivity);
    }

    /**
     * Creates a {@link CaseSensitivityCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityCharSequencePredicate<C> with(final C chars,
                                                                                final CaseSensitivity sensitivity) {
        Objects.requireNonNull(chars, "chars");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityCharSequencePredicate<C>(chars, sensitivity);
    }

Replace Generic With Diamond CaseSensitivityCharSequencePredicate<C> with CaseSensitivityCharSequencePredicate<> in method package with(chars C, sensitivity CaseSensitivity) : CaseSensitivityCharSequencePredicate<C> from class walkingkooka.text.CaseSensitivityCharSequencePredicate


    /**
     * Creates a {@link CaseSensitivityContainsCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityContainsCharSequencePredicate<C> with(
            final C contains, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(contains, "contains");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityContainsCharSequencePredicate<>(contains, sensitivity);
    }

    /**
     * Creates a {@link CaseSensitivityContainsCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityContainsCharSequencePredicate<C> with(
            final C contains, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(contains, "contains");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityContainsCharSequencePredicate<C>(contains, sensitivity);
    }

Replace Generic With Diamond CaseSensitivityContainsCharSequencePredicate<C> with CaseSensitivityContainsCharSequencePredicate<> in method package with(contains C, sensitivity CaseSensitivity) : CaseSensitivityContainsCharSequencePredicate<C> from class walkingkooka.text.CaseSensitivityContainsCharSequencePredicate


    /**
     * Creates a {@link CaseSensitivityEndsWithCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityEndsWithCharSequencePredicate<C> with(
            final C startsWith, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(startsWith, "startsWith");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityEndsWithCharSequencePredicate<>(startsWith, sensitivity);
    }

    /**
     * Creates a {@link CaseSensitivityEndsWithCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityEndsWithCharSequencePredicate<C> with(
            final C startsWith, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(startsWith, "startsWith");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityEndsWithCharSequencePredicate<C>(startsWith, sensitivity);
    }

Replace Generic With Diamond CaseSensitivityEndsWithCharSequencePredicate<C> with CaseSensitivityEndsWithCharSequencePredicate<> in method package with(startsWith C, sensitivity CaseSensitivity) : CaseSensitivityEndsWithCharSequencePredicate<C> from class walkingkooka.text.CaseSensitivityEndsWithCharSequencePredicate


    /**
     * Creates a {@link CaseSensitivityStartsWithCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityStartsWithCharSequencePredicate<C> with(
            final C startsWith, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(startsWith, "startsWith");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityStartsWithCharSequencePredicate<>(startsWith, sensitivity);
    }

    /**
     * Creates a {@link CaseSensitivityStartsWithCharSequencePredicate}
     */
    static <C extends CharSequence> CaseSensitivityStartsWithCharSequencePredicate<C> with(
            final C startsWith, final CaseSensitivity sensitivity) {
        CharSequences.failIfNullOrEmpty(startsWith, "startsWith");
        Objects.requireNonNull(sensitivity, "sensitivity");

        return new CaseSensitivityStartsWithCharSequencePredicate<C>(startsWith, sensitivity);
    }

Replace Generic With Diamond CaseSensitivityStartsWithCharSequencePredicate<C> with CaseSensitivityStartsWithCharSequencePredicate<> in method package with(startsWith C, sensitivity CaseSensitivity) : CaseSensitivityStartsWithCharSequencePredicate<C> from class walkingkooka.text.CaseSensitivityStartsWithCharSequencePredicate


    /**
     * The actual factory method that accepts the copy of parsers that have been processed and possibly simplified.
     */
    private static <C extends ParserContext> Parser<C> with0(final List<Parser<C>> parsers) {
        Parser<C> parser;

        switch (parsers.size()) {
            case 0:
                throw new IllegalArgumentException("At least one parser must be provided");
            case 1:
                parser = parsers.get(0).cast();
                break;
            default:
                parser = new AlternativesParser<>(parsers);
                break;
        }

        return parser;
    }

    /**
     * The actual factory method that accepts the copy of parsers that have been processed and possibly simplified.
     */
    private static <C extends ParserContext> Parser<C> with0(final List<Parser<C>> parsers) {
        Parser<C> parser;

        switch (parsers.size()) {
            case 0:
                throw new IllegalArgumentException("At least one parser must be provided");
            case 1:
                parser = parsers.get(0).cast();
                break;
            default:
                parser = new AlternativesParser<C>(parsers);
                break;
        }

        return parser;
    }

Replace Generic With Diamond AlternativesParser<C> with AlternativesParser<> in method private with0(parsers List<Parser<C>>) : Parser<C> from class walkingkooka.text.cursor.parser.AlternativesParser


    static <T extends ParserToken, C extends ParserContext> AndNotParser<C> with(final Parser<C> left, final Parser<C> right) {
        Objects.requireNonNull(left, "left");
        Objects.requireNonNull(right, "right");

        return new AndNotParser<>(left, right);
    }

    static <T extends ParserToken, C extends ParserContext> AndNotParser<C> with(final Parser<C> left, final Parser<C> right) {
        Objects.requireNonNull(left, "left");
        Objects.requireNonNull(right, "right");

        return new AndNotParser<C>(left, right);
    }

Replace Generic With Diamond AndNotParser<C> with AndNotParser<> in method package with(left Parser<C>, right Parser<C>) : AndNotParser<C> from class walkingkooka.text.cursor.parser.AndNotParser


    static <C extends ParserContext> RepeatedParser<C> with(final Parser<C> parser) {
        Objects.requireNonNull(parser, "parser");

        return parser instanceof RepeatedParser ?
                Cast.to(parser) :
                new RepeatedParser<>(parser);
    }

    static <C extends ParserContext> RepeatedParser<C> with(final Parser<C> parser) {
        Objects.requireNonNull(parser, "parser");

        return parser instanceof RepeatedParser ?
                Cast.to(parser) :
                new RepeatedParser<C>(parser);
    }

Replace Generic With Diamond RepeatedParser<C> with RepeatedParser<> in method package with(parser Parser<C>) : RepeatedParser<C> from class walkingkooka.text.cursor.parser.RepeatedParser


    static <C extends ParserContext> EbnfParserCombinatorProxyParser<C> with(final EbnfIdentifierParserToken identifier) {
        return new EbnfParserCombinatorProxyParser<>(identifier);
    }

    static <C extends ParserContext> EbnfParserCombinatorProxyParser<C> with(final EbnfIdentifierParserToken identifier) {
        return new EbnfParserCombinatorProxyParser<C>(identifier);
    }

Replace Generic With Diamond EbnfParserCombinatorProxyParser<C> with EbnfParserCombinatorProxyParser<> in method package with(identifier EbnfIdentifierParserToken) : EbnfParserCombinatorProxyParser<C> from class walkingkooka.text.cursor.parser.ebnf.combinator.EbnfParserCombinatorProxyParser


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a descending to a absolute, as it already is a absolute search start...
        return selector instanceof AbsoluteNodeSelector ?
                this :
                selector instanceof DescendantNodeSelector ?
                        selector :
                        new AbsoluteNodeSelector<>(selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a descending to a absolute, as it already is a absolute search start...
        return selector instanceof AbsoluteNodeSelector ?
                this :
                selector instanceof DescendantNodeSelector ?
                        selector :
                        new AbsoluteNodeSelector<N, NAME, ANAME, AVALUE>(selector);
    }

Replace Generic With Diamond AbsoluteNodeSelector<N,NAME,ANAME,AVALUE> with AbsoluteNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.AbsoluteNodeSelector


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a ancestor to another...
        return selector instanceof AncestorNodeSelector ?
                this :
                new AncestorNodeSelector<>(selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a ancestor to another...
        return selector instanceof AncestorNodeSelector ?
                this :
                new AncestorNodeSelector<N, NAME, ANAME, AVALUE>(selector);
    }

Replace Generic With Diamond AncestorNodeSelector<N,NAME,ANAME,AVALUE> with AncestorNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.AncestorNodeSelector


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a ancestor to another...
        return selector instanceof AncestorOrSelfNodeSelector ?
                this :
                new AncestorOrSelfNodeSelector<>(selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a ancestor to another...
        return selector instanceof AncestorOrSelfNodeSelector ?
                this :
                new AncestorOrSelfNodeSelector<N, NAME, ANAME, AVALUE>(selector);
    }

Replace Generic With Diamond AncestorOrSelfNodeSelector<N,NAME,ANAME,AVALUE> with AncestorOrSelfNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.AncestorOrSelfNodeSelector


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        return new ChildrenNodeSelector<>(selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        return new ChildrenNodeSelector<N, NAME, ANAME, AVALUE>(selector);
    }

Replace Generic With Diamond ChildrenNodeSelector<N,NAME,ANAME,AVALUE> with ChildrenNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.ChildrenNodeSelector


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a descending to another...
        return selector instanceof DescendantNodeSelector ?
                this :
                new DescendantNodeSelector<>(selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        // no point appending a descending to another...
        return selector instanceof DescendantNodeSelector ?
                this :
                new DescendantNodeSelector<N, NAME, ANAME, AVALUE>(selector);
    }

Replace Generic With Diamond DescendantNodeSelector<N,NAME,ANAME,AVALUE> with DescendantNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.DescendantNodeSelector


    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        return new ExpressionNodeSelector<>(this.expressionNode, selector);
    }

    @Override
    NodeSelector<N, NAME, ANAME, AVALUE> append1(final NodeSelector<N, NAME, ANAME, AVALUE> selector) {
        return new ExpressionNodeSelector<N, NAME, ANAME, AVALUE>(this.expressionNode, selector);
    }

Replace Generic With Diamond ExpressionNodeSelector<N,NAME,ANAME,AVALUE> with ExpressionNodeSelector<> in method package append1(selector NodeSelector<N,NAME,ANAME,AVALUE>) : NodeSelector<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.ExpressionNodeSelector


    /**
     * {@see FakeNodeSelectorContext}
     */
    public static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE> NodeSelectorContext<N, NAME, ANAME, AVALUE> fake() {
        return new FakeNodeSelectorContext<>();
    }

    /**
     * {@see FakeNodeSelectorContext}
     */
    public static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE> NodeSelectorContext<N, NAME, ANAME, AVALUE> fake() {
        return new FakeNodeSelectorContext<N, NAME, ANAME, AVALUE>();
    }

Replace Generic With Diamond FakeNodeSelectorContext<N,NAME,ANAME,AVALUE> with FakeNodeSelectorContext<> in method public fake() : NodeSelectorContext<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.NodeSelectorContexts


    default NodeSelectorContext<N, NAME, ANAME, AVALUE> nodeSelectorContext(final Consumer<N> potential,
                                                                            final Consumer<N> selected) {
        return new FakeNodeSelectorContext<>() {

            @Override
            public boolean isFinished() {
                return false;
            }

            @Override
            public void setNode(final N node) {
                // nop
            }

            @Override
            public boolean test(final N node) {
                potential.accept(node);
                return true;
            }

            @Override
            public N selected(final N node) {
                selected.accept(node);
                return node;
            }

            @Override
            public String toString() {
                return "selected: " + selected;
            }
        };
    }

    default NodeSelectorContext<N, NAME, ANAME, AVALUE> nodeSelectorContext(final Consumer<N> potential,
                                                                            final Consumer<N> selected) {
        return new FakeNodeSelectorContext<N, NAME, ANAME, AVALUE>() {

            @Override
            public boolean isFinished() {
                return false;
            }

            @Override
            public void setNode(final N node) {
                // nop
            }

            @Override
            public boolean test(final N node) {
                potential.accept(node);
                return true;
            }

            @Override
            public N selected(final N node) {
                selected.accept(node);
                return node;
            }

            @Override
            public String toString() {
                return "selected: " + selected;
            }
        };
    }

Replace Generic With Diamond FakeNodeSelectorContext<N,NAME,ANAME,AVALUE> with FakeNodeSelectorContext<> in method public nodeSelectorContext(potential Consumer<N>, selected Consumer<N>) : NodeSelectorContext<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.NodeSelectorTesting


    default void selectorApplyMapAndCheck(final N node,
                                          final NodeSelector<N, NAME, ANAME, AVALUE> selector,
                                          final Function<N, N> mapper,
                                          final N expected) {
        assertEquals(expected,
                selector.apply(node, new FakeNodeSelectorContext<>() {

                    @Override
                    public boolean isFinished() {
                        return false;
                    }

                    @Override
                    public boolean test(final N node) {
                        return true;
                    }

                    @Override
                    public N selected(final N node) {
                        return mapper.apply(node);
                    }

                    @Override
                    public String toString() {
                        return mapper.toString();
                    }
                }),
                () -> "selector " + selector + " map failed");
    }

    default void selectorApplyMapAndCheck(final N node,
                                          final NodeSelector<N, NAME, ANAME, AVALUE> selector,
                                          final Function<N, N> mapper,
                                          final N expected) {
        assertEquals(expected,
                selector.apply(node, new FakeNodeSelectorContext<N, NAME, ANAME, AVALUE>() {

                    @Override
                    public boolean isFinished() {
                        return false;
                    }

                    @Override
                    public boolean test(final N node) {
                        return true;
                    }

                    @Override
                    public N selected(final N node) {
                        return mapper.apply(node);
                    }

                    @Override
                    public String toString() {
                        return mapper.toString();
                    }
                }),
                () -> "selector " + selector + " map failed");
    }

Replace Generic With Diamond FakeNodeSelectorContext<N,NAME,ANAME,AVALUE> with FakeNodeSelectorContext<> in method public selectorApplyMapAndCheck(node N, selector NodeSelector<N,NAME,ANAME,AVALUE>, mapper Function<N,N>, expected N) : void from class walkingkooka.tree.select.NodeSelectorTesting


    /**
     * Creates a new {@link OpenChecker} which is initially open.
     */
    public static <T extends Throwable> OpenChecker<T> with(final String message,
                                                            final Function<String, T> throwableFactory) {
        Whitespace.failIfNullOrEmptyOrWhitespace(message, "message");
        Objects.requireNonNull(throwableFactory, "throwableFactory");

        return new OpenChecker<>(message, throwableFactory);
    }

    /**
     * Creates a new {@link OpenChecker} which is initially open.
     */
    public static <T extends Throwable> OpenChecker<T> with(final String message,
                                                            final Function<String, T> throwableFactory) {
        Whitespace.failIfNullOrEmptyOrWhitespace(message, "message");
        Objects.requireNonNull(throwableFactory, "throwableFactory");

        return new OpenChecker<T>(message, throwableFactory);
    }

Replace Generic With Diamond OpenChecker<T> with OpenChecker<> in method public with(message String, throwableFactory Function<String,T>) : OpenChecker<T> from class walkingkooka.util.OpenChecker


    /**
     * Factory that creates a new {@link VisitorPrettyPrinter}
     */
    public static <T> VisitorPrettyPrinter<T> with(final IndentingPrinter printer,
                                                   final Indentation indentation,
                                                   final Function<T, String> typeName) {
        Objects.requireNonNull(printer, "printer");
        Objects.requireNonNull(indentation, "indentation");
        Objects.requireNonNull(typeName, "typeName");

        return new VisitorPrettyPrinter<>(printer, indentation, typeName);
    }

    /**
     * Factory that creates a new {@link VisitorPrettyPrinter}
     */
    public static <T> VisitorPrettyPrinter<T> with(final IndentingPrinter printer,
                                                   final Indentation indentation,
                                                   final Function<T, String> typeName) {
        Objects.requireNonNull(printer, "printer");
        Objects.requireNonNull(indentation, "indentation");
        Objects.requireNonNull(typeName, "typeName");

        return new VisitorPrettyPrinter<T>(printer, indentation, typeName);
    }

Replace Generic With Diamond VisitorPrettyPrinter<T> with VisitorPrettyPrinter<> in method public with(printer IndentingPrinter, indentation Indentation, typeName Function<T,String>) : VisitorPrettyPrinter<T> from class walkingkooka.visit.VisitorPrettyPrinter


    @Test
    public void testValueEnumerationNotConsumed() {
        final Enumeration<String> enumeration = new Enumeration<>() {
            @Override
            public boolean hasMoreElements() {
                throw new UnsupportedOperationException();
            }

            @Override
            public String nextElement() {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return "Enumeration123";
            }
        };
        this.buildAndCheck(this.builder()//
                        .value(enumeration),
                enumeration.toString());
    }

    @Test
    public void testValueEnumerationNotConsumed() {
        final Enumeration<String> enumeration = new Enumeration<String>() {
            @Override
            public boolean hasMoreElements() {
                throw new UnsupportedOperationException();
            }

            @Override
            public String nextElement() {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return "Enumeration123";
            }
        };
        this.buildAndCheck(this.builder()//
                        .value(enumeration),
                enumeration.toString());
    }

Replace Generic With Diamond Enumeration<String> with Enumeration<> in method public testValueEnumerationNotConsumed() : void from class walkingkooka.ToStringBuilderTest


                @Override
                public List<String> createCollection() {
                    return new AbstractList<>() {
                        @Override
                        public String get(final int index) {
                            if (0 == index) {
                                return "a1";
                            }
                            if (1 == index) {
                                return "b1";
                            }
                            throw new ArrayIndexOutOfBoundsException("Invalid index: " + index);
                        }

                        @Override
                        public Iterator<String> iterator() {
                            return Iterators.one("a1");
                        }

                        @Override
                        public int size() {
                            return 2;
                        }
                    };
                }

                @Override
                public List<String> createCollection() {
                    return new AbstractList<String>() {
                        @Override
                        public String get(final int index) {
                            if (0 == index) {
                                return "a1";
                            }
                            if (1 == index) {
                                return "b1";
                            }
                            throw new ArrayIndexOutOfBoundsException("Invalid index: " + index);
                        }

                        @Override
                        public Iterator<String> iterator() {
                            return Iterators.one("a1");
                        }

                        @Override
                        public int size() {
                            return 2;
                        }
                    };
                }

Replace Generic With Diamond AbstractList<String> with AbstractList<> in method public createCollection() : List<String> from class walkingkooka.collect.CollectionTesting2Test.testIteratorContainsAndCollectionFails.assertThrows.testIteratorContainsAndCollection.new CollectionTesting2<List<String>,String>


    @Test
    public void testIteratorContainsAndCollectionFails() {
        assertThrows(AssertionFailedError.class, () -> {
            new CollectionTesting2<List<String>, String>() {

                @Override
                public List<String> createCollection() {
                    return new AbstractList<>() {
                        @Override
                        public String get(final int index) {
                            if (0 == index) {
                                return "a1";
                            }
                            if (1 == index) {
                                return "b1";
                            }
                            throw new ArrayIndexOutOfBoundsException("Invalid index: " + index);
                        }

                        @Override
                        public Iterator<String> iterator() {
                            return Iterators.one("a1");
                        }

                        @Override
                        public int size() {
                            return 2;
                        }
                    };
                }

                @Override
                public Class<List<String>> type() {
                    return Cast.to(List.class);
                }
            }.testIteratorContainsAndCollection();
        });
    }

    @Test
    public void testIteratorContainsAndCollectionFails() {
        assertThrows(AssertionFailedError.class, () -> {
            new CollectionTesting2<List<String>, String>() {

                @Override
                public List<String> createCollection() {
                    return new AbstractList<String>() {
                        @Override
                        public String get(final int index) {
                            if (0 == index) {
                                return "a1";
                            }
                            if (1 == index) {
                                return "b1";
                            }
                            throw new ArrayIndexOutOfBoundsException("Invalid index: " + index);
                        }

                        @Override
                        public Iterator<String> iterator() {
                            return Iterators.one("a1");
                        }

                        @Override
                        public int size() {
                            return 2;
                        }
                    };
                }

                @Override
                public Class<List<String>> type() {
                    return Cast.to(List.class);
                }
            }.testIteratorContainsAndCollection();
        });
    }

Replace Generic With Diamond AbstractList<String> with AbstractList<> in method public testIteratorContainsAndCollectionFails() : void from class walkingkooka.collect.CollectionTesting2Test


    @Test
    public void testToString() {
        final Iterator<Object> iterator
                = new ArrayList<>(Lists.of(ELEMENT)).iterator();
        this.toStringAndCheck(ReadOnlyIterator.wrap(iterator), iterator.toString());
    }

    @Test
    public void testToString() {
        final Iterator<Object> iterator
                = new ArrayList<Object>(Lists.of(ELEMENT)).iterator();
        this.toStringAndCheck(ReadOnlyIterator.wrap(iterator), iterator.toString());
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public testToString() : void from class walkingkooka.collect.iterator.ReadOnlyIteratorTest


    private ReadOnlyIterator<Object> iterator(final Object... strings) {
        return ReadOnlyIterator.wrap(new ArrayList<>(Lists.of(strings)).iterator());
    }

    private ReadOnlyIterator<Object> iterator(final Object... strings) {
        return ReadOnlyIterator.wrap(new ArrayList<Object>(Lists.of(strings)).iterator());
    }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method private iterator(strings Object...) : ReadOnlyIterator<Object> from class walkingkooka.collect.iterator.ReadOnlyIteratorTest


    private ReverseIterator<String> iterator(final String... strings) {
        return Cast.to(ReverseIterator.with(new ArrayList<>(Lists.of(strings)).iterator()));
    }

    private ReverseIterator<String> iterator(final String... strings) {
        return Cast.to(ReverseIterator.with(new ArrayList<String>(Lists.of(strings)).iterator()));
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method private iterator(strings String...) : ReverseIterator<String> from class walkingkooka.collect.iterator.ReverseIteratorTest


    @Test
    public void testIterator() {
        final Iterator<Object> iterator = Iterators.fake();
        final Stack<Object> stack = ReadOnlyStack.wrap(//
                new FakeStack<>() {

                    @Override
                    public Iterator<Object> iterator() {
                        return iterator;
                    }
                });
        assertSame(iterator, stack.iterator());
    }

    @Test
    public void testIterator() {
        final Iterator<Object> iterator = Iterators.fake();
        final Stack<Object> stack = ReadOnlyStack.wrap(//
                new FakeStack<Object>() {

                    @Override
                    public Iterator<Object> iterator() {
                        return iterator;
                    }
                });
        assertSame(iterator, stack.iterator());
    }

Replace Generic With Diamond FakeStack<Object> with FakeStack<> in method public testIterator() : void from class walkingkooka.collect.stack.ReadOnlyStackTest


    @Test
    public void testHashCode() {
        final UnreadableStack<Object> stack = UnreadableStack.wrap(new FakeStack<>() {

            @Override
            public int hashCode() {
                return 123;
            }
        });
        assertEquals(123, stack.hashCode());
    }

    @Test
    public void testHashCode() {
        final UnreadableStack<Object> stack = UnreadableStack.wrap(new FakeStack<Object>() {

            @Override
            public int hashCode() {
                return 123;
            }
        });
        assertEquals(123, stack.hashCode());
    }

Replace Generic With Diamond FakeStack<Object> with FakeStack<> in method public testHashCode() : void from class walkingkooka.collect.stack.UnreadableStackTest


    @Test
    public void testInvertsResult() {
        final Object object1 = new Object();
        final Object object2 = new Object();
        final Comparator<Object> comparator = NotComparator.wrap(new Comparator<>() {

            @Override
            public int compare(final Object o1, final Object o2) {
                assertSame(object1, o1);
                assertSame(object2, o2);
                return +2;
            }
        });
        checkEquals(-2, comparator.compare(object1, object2));
    }

    @Test
    public void testInvertsResult() {
        final Object object1 = new Object();
        final Object object2 = new Object();
        final Comparator<Object> comparator = NotComparator.wrap(new Comparator<Object>() {

            @Override
            public int compare(final Object o1, final Object o2) {
                assertSame(object1, o1);
                assertSame(object2, o2);
                return +2;
            }
        });
        checkEquals(-2, comparator.compare(object1, object2));
    }

Replace Generic With Diamond Comparator<Object> with Comparator<> in method public testInvertsResult() : void from class walkingkooka.compare.NotComparatorTest


    @Test
    public void testAcceptGreaterThan() {
        final StringBuilder visited = new StringBuilder();

        final Integer lower = 55;
        final Range<Integer> range = Range.greaterThan(lower);

        range.accept(new FakeRangeVisitor<>() {

            @Override
            protected Visiting startVisit(final Range<Integer> r) {
                assertSame(range, r);
                visited.append("1");
                return Visiting.CONTINUE;
            }

            @Override
            protected Visiting startBetween(final RangeBound<Integer> lowerBound, final RangeBound<Integer> upperBound) {
                check(range, lowerBound, upperBound);
                visited.append("2");
                return Visiting.CONTINUE;
            }

            @Override
            protected void lowerBoundExclusive(final Integer value) {
                assertSame(lower, value, "lowerBoundExclusive");
                visited.append("3");
            }

            @Override
            protected void upperBoundAll() {
                visited.append("4");
            }

            @Override
            protected void endBetween(final RangeBound<Integer> lowerBound, final RangeBound<Integer> upperBound) {
                check(range, lowerBound, upperBound);
                visited.append("5");
            }

            @Override
            protected void endVisit(final Range<Integer> range) {
                visited.append("6");
                super.endVisit(range);
            }
        });

        assertEquals(visited.toString(), "123456");
    }

    @Test
    public void testAcceptGreaterThan() {
        final StringBuilder visited = new StringBuilder();

        final Integer lower = 55;
        final Range<Integer> range = Range.greaterThan(lower);

        range.accept(new FakeRangeVisitor<Integer>() {

            @Override
            protected Visiting startVisit(final Range<Integer> r) {
                assertSame(range, r);
                visited.append("1");
                return Visiting.CONTINUE;
            }

            @Override
            protected Visiting startBetween(final RangeBound<Integer> lowerBound, final RangeBound<Integer> upperBound) {
                check(range, lowerBound, upperBound);
                visited.append("2");
                return Visiting.CONTINUE;
            }

            @Override
            protected void lowerBoundExclusive(final Integer value) {
                assertSame(lower, value, "lowerBoundExclusive");
                visited.append("3");
            }

            @Override
            protected void upperBoundAll() {
                visited.append("4");
            }

            @Override
            protected void endBetween(final RangeBound<Integer> lowerBound, final RangeBound<Integer> upperBound) {
                check(range, lowerBound, upperBound);
                visited.append("5");
            }

            @Override
            protected void endVisit(final Range<Integer> range) {
                visited.append("6");
                super.endVisit(range);
            }
        });

        assertEquals(visited.toString(), "123456");
    }

Replace Generic With Diamond FakeRangeVisitor<Integer> with FakeRangeVisitor<> in method public testAcceptGreaterThan() : void from class walkingkooka.compare.RangeTest


    @Override
    public RangeVisitor<Integer> createVisitor() {
        return new FakeRangeVisitor<>() {

            @Override
            public String toString() {
                return RangeVisitorTest.this.toString();
            }
        };
    }

    @Override
    public RangeVisitor<Integer> createVisitor() {
        return new FakeRangeVisitor<Integer>() {

            @Override
            public String toString() {
                return RangeVisitorTest.this.toString();
            }
        };
    }

Replace Generic With Diamond FakeRangeVisitor<Integer> with FakeRangeVisitor<> in method public createVisitor() : RangeVisitor<Integer> from class walkingkooka.compare.RangeVisitorTest


    final void acceptAndCheck(final long skipOrLimit,
                              final String commaSeperated,
                              final int finishedCollectedSize,
                              final String expected,
                              final int consumedCount) {
        final List<String> collected = Lists.array();

        final P consumer = this.createPushableStreamConsumer(skipOrLimit,
                new PushableStreamConsumer<>() {
                    @Override
                    public boolean isFinished() {
                        return collected.size() >= finishedCollectedSize;
                    }

                    @Override
                    public void accept(final String s) {
                        collected.add(s);
                    }

                    @Override
                    public void close() {

                    }

                    @Override
                    public String toString() {
                        return (this.isFinished() ? "FINISHED" : "") + ", collected: " + collected;
                    }
                });

        final List<String> values = this.commaSeparated(commaSeperated);

        int i = 0;
        while(i < values.size() && false == consumer.isFinished()) {
            consumer.accept(values.get(i));
            i++;
        }

        assertEquals(this.commaSeparated(expected),
                collected,
                () -> "values: " + CharSequences.quoteAndEscape(commaSeperated) + " " + consumer);
        assertEquals(consumedCount, i, () -> "consumed values count, values: " + CharSequences.quoteAndEscape(commaSeperated));
    }

    final void acceptAndCheck(final long skipOrLimit,
                              final String commaSeperated,
                              final int finishedCollectedSize,
                              final String expected,
                              final int consumedCount) {
        final List<String> collected = Lists.array();

        final P consumer = this.createPushableStreamConsumer(skipOrLimit,
                new PushableStreamConsumer<String>() {
                    @Override
                    public boolean isFinished() {
                        return collected.size() >= finishedCollectedSize;
                    }

                    @Override
                    public void accept(final String s) {
                        collected.add(s);
                    }

                    @Override
                    public void close() {

                    }

                    @Override
                    public String toString() {
                        return (this.isFinished() ? "FINISHED" : "") + ", collected: " + collected;
                    }
                });

        final List<String> values = this.commaSeparated(commaSeperated);

        int i = 0;
        while(i < values.size() && false == consumer.isFinished()) {
            consumer.accept(values.get(i));
            i++;
        }

        assertEquals(this.commaSeparated(expected),
                collected,
                () -> "values: " + CharSequences.quoteAndEscape(commaSeperated) + " " + consumer);
        assertEquals(consumedCount, i, () -> "consumed values count, values: " + CharSequences.quoteAndEscape(commaSeperated));
    }

Replace Generic With Diamond PushableStreamConsumer<String> with PushableStreamConsumer<> in method package acceptAndCheck(skipOrLimit long, commaSeperated String, finishedCollectedSize int, expected String, consumedCount int) : void from class walkingkooka.stream.push.PushableStreamConsumerStreamIntermediate1PushableStreamConsumerTestCase


    final NodeSelectorContext<TestNode, StringName, StringName, Object> contextWithToString(final String toString) {
        return new FakeNodeSelectorContext<>() {
            @Override
            public String toString() {
                return toString;
            }
        };
    }

    final NodeSelectorContext<TestNode, StringName, StringName, Object> contextWithToString(final String toString) {
        return new FakeNodeSelectorContext<TestNode, StringName, StringName, Object>() {
            @Override
            public String toString() {
                return toString;
            }
        };
    }

Replace Generic With Diamond FakeNodeSelectorContext<TestNode,StringName,StringName,Object> with FakeNodeSelectorContext<> in method package contextWithToString(toString String) : NodeSelectorContext<TestNode,StringName,StringName,Object> from class walkingkooka.tree.select.NodeSelectorContext2TestCase