diff options
author | Paul Duffin <paulduffin@google.com> | 2015-02-27 10:51:44 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2015-05-29 15:36:23 +0100 |
commit | 5cab40b862c21656c2ace19596874eb3ffe1b649 (patch) | |
tree | 8f59555630f63a6e7916e4c1d31f5476a603a7ca /guava-gwt | |
parent | 0c29232f9e0a18dc064d9f2859f7bff889729002 (diff) | |
download | guava-5cab40b862c21656c2ace19596874eb3ffe1b649.tar.gz |
Upgraded Guava to unmodified jdk5-backport-v17.0-post
This simply copies the Guava source for jdk5-backport-v17.0-post
straight from the github repository into this one.
See https://github.com/google/guava.git
Additional commits will be made which will allow this to compile
on Android.
BUG=19672715
Change-Id: If822daced0fc352f01bf9ecac1e994da08358f72
Diffstat (limited to 'guava-gwt')
5 files changed, 7 insertions, 429 deletions
diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java index 931a2df81..07f674e0b 100644 --- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java +++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java @@ -122,11 +122,10 @@ public final class Stopwatch { * Creates (but does not start) a new stopwatch using {@link System#nanoTime} * as its time source. * - * @deprecated Use {@link Stopwatch#createUnstarted()} instead. This - * constructor is scheduled to be removed in Guava release 17.0. + * @deprecated Use {@link Stopwatch#createUnstarted()} instead. */ @Deprecated - public Stopwatch() { + Stopwatch() { this(Ticker.systemTicker()); } @@ -134,11 +133,10 @@ public final class Stopwatch { * Creates (but does not start) a new stopwatch, using the specified time * source. * - * @deprecated Use {@link Stopwatch#createUnstarted(Ticker)} instead. This - * constructor is scheduled to be removed in Guava release 17.0. + * @deprecated Use {@link Stopwatch#createUnstarted(Ticker)} instead. */ @Deprecated - public Stopwatch(Ticker ticker) { + Stopwatch(Ticker ticker) { this.ticker = checkNotNull(ticker, "ticker"); } @@ -252,4 +250,3 @@ public final class Stopwatch { } } } - diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/FluentIterable.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/FluentIterable.java index 7cf2a0a57..42ae48640 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/FluentIterable.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/FluentIterable.java @@ -413,64 +413,6 @@ public abstract class FluentIterable<E> implements Iterable<E> { } /** - * Returns an {@code ImmutableList} containing all of the elements from this - * fluent iterable in proper sequence. - * - * @deprecated Use {@link #toList()} instead. This method is scheduled for removal in Guava 15.0. - */ - @Deprecated - public final ImmutableList<E> toImmutableList() { - return toList(); - } - - /** - * Returns an {@code ImmutableList} containing all of the elements from this - * {@code FluentIterable} in the order specified by {@code comparator}. To produce an - * {@code ImmutableList} sorted by its natural ordering, use - * {@code toSortedImmutableList(Ordering.natural())}. - * - * @param comparator the function by which to sort list elements - * @throws NullPointerException if any element is null - * @since 13.0 - * @deprecated Use {@link #toSortedList(Comparator)} instead. This method is scheduled for removal - * in Guava 15.0. - */ - @Deprecated - public final ImmutableList<E> toSortedImmutableList( - Comparator<? super E> comparator) { - return toSortedList(comparator); - } - - /** - * Returns an {@code ImmutableSet} containing all of the elements from this - * fluent iterable with duplicates removed. - * - * @deprecated Use {@link #toSet()} instead. This method is scheduled for removal in Guava 15.0. - */ - @Deprecated - public final ImmutableSet<E> toImmutableSet() { - return toSet(); - } - - /** - * Returns an {@code ImmutableSortedSet} containing all of the elements from this - * {@code FluentIterable} in the order specified by {@code comparator}, with duplicates - * (determined by {@code comparator.compare(x, y) == 0}) removed. To produce an - * {@code ImmutableSortedSet} sorted by its natural ordering, use - * {@code toImmutableSortedSet(Ordering.natural())}. - * - * @param comparator the function by which to sort set elements - * @throws NullPointerException if any element is null - * @deprecated Use {@link #toSortedSet(Comparator)} instead. This method is scheduled for removal - * in Guava 15.0. - */ - @Deprecated - public final ImmutableSortedSet<E> toImmutableSortedSet( - Comparator<? super E> comparator) { - return toSortedSet(comparator); - } - - /** * Copies all the elements from this fluent iterable to {@code collection}. This is equivalent to * calling {@code Iterables.addAll(collection, this)}. * diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/GenericMapMaker.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/GenericMapMaker.java index 03ba0c03f..6240625fd 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/GenericMapMaker.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/GenericMapMaker.java @@ -37,12 +37,12 @@ import java.util.concurrent.TimeUnit; * "Generic" equivalent; simple use {@code CacheBuilder} naturally. For general migration * instructions, see the <a * href="http://code.google.com/p/guava-libraries/wiki/MapMakerMigration">MapMaker Migration - * Guide</a>. This class is scheduled for removal in Guava 16.0. + * Guide</a>. */ @Beta @Deprecated @GwtCompatible(emulated = true) -public abstract class GenericMapMaker<K0, V0> { +abstract class GenericMapMaker<K0, V0> { // Set by MapMaker, but sits in this class to preserve the type relationship @@ -83,6 +83,6 @@ public abstract class GenericMapMaker<K0, V0> { * See {@link MapMaker#makeComputingMap}. */ @Deprecated - public abstract <K extends K0, V extends V0> ConcurrentMap<K, V> makeComputingMap( + abstract <K extends K0, V extends V0> ConcurrentMap<K, V> makeComputingMap( Function<? super K, ? extends V> computingFunction); } diff --git a/guava-gwt/test-super/com/google/common/collect/super/com/google/common/collect/ConstraintsTest.java b/guava-gwt/test-super/com/google/common/collect/super/com/google/common/collect/ConstraintsTest.java deleted file mode 100644 index 9dda41f82..000000000 --- a/guava-gwt/test-super/com/google/common/collect/super/com/google/common/collect/ConstraintsTest.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (C) 2007 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.common.collect; - -import static java.util.Arrays.asList; -import static org.truth0.Truth.ASSERT; - -import com.google.common.annotations.GwtCompatible; - -import junit.framework.TestCase; - -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Set; -import java.util.SortedSet; - -/** - * Tests for {@code Constraints}. - * - * @author Mike Bostock - * @author Jared Levy - */ -@GwtCompatible(emulated = true) -public class ConstraintsTest extends TestCase { - - private static final String TEST_ELEMENT = "test"; - - private static final class TestElementException - extends IllegalArgumentException { - private static final long serialVersionUID = 0; - } - - private static final Constraint<String> TEST_CONSTRAINT - = new Constraint<String>() { - @Override - public String checkElement(String element) { - if (TEST_ELEMENT.equals(element)) { - throw new TestElementException(); - } - return element; - } - }; - - public void testNotNull() { - Constraint<? super String> constraint = Constraints.notNull(); - assertSame(TEST_ELEMENT, constraint.checkElement(TEST_ELEMENT)); - try { - constraint.checkElement(null); - fail("NullPointerException expected"); - } catch (NullPointerException expected) {} - assertEquals("Not null", constraint.toString()); - } - - public void testConstrainedCollectionLegal() { - Collection<String> collection = Lists.newArrayList("foo", "bar"); - Collection<String> constrained = Constraints.constrainedCollection( - collection, TEST_CONSTRAINT); - collection.add(TEST_ELEMENT); - constrained.add("qux"); - constrained.addAll(asList("cat", "dog")); - /* equals and hashCode aren't defined for Collection */ - ASSERT.that(collection).has() - .exactly("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog").inOrder(); - ASSERT.that(constrained).has() - .exactly("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog").inOrder(); - } - - public void testConstrainedCollectionIllegal() { - Collection<String> collection = Lists.newArrayList("foo", "bar"); - Collection<String> constrained = Constraints.constrainedCollection( - collection, TEST_CONSTRAINT); - try { - constrained.add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - ASSERT.that(constrained).has().exactly("foo", "bar").inOrder(); - ASSERT.that(collection).has().exactly("foo", "bar").inOrder(); - } - - public void testConstrainedSetLegal() { - Set<String> set = Sets.newLinkedHashSet(asList("foo", "bar")); - Set<String> constrained = Constraints.constrainedSet(set, TEST_CONSTRAINT); - set.add(TEST_ELEMENT); - constrained.add("qux"); - constrained.addAll(asList("cat", "dog")); - assertTrue(set.equals(constrained)); - assertTrue(constrained.equals(set)); - assertEquals(set.toString(), constrained.toString()); - assertEquals(set.hashCode(), constrained.hashCode()); - ASSERT.that(set).has().exactly("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog").inOrder(); - ASSERT.that(constrained).has() - .exactly("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog").inOrder(); - } - - public void testConstrainedSetIllegal() { - Set<String> set = Sets.newLinkedHashSet(asList("foo", "bar")); - Set<String> constrained = Constraints.constrainedSet(set, TEST_CONSTRAINT); - try { - constrained.add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - ASSERT.that(constrained).has().exactly("foo", "bar").inOrder(); - ASSERT.that(set).has().exactly("foo", "bar").inOrder(); - } - - public void testConstrainedSortedSetLegal() { - SortedSet<String> sortedSet = Sets.newTreeSet(asList("foo", "bar")); - SortedSet<String> constrained = Constraints.constrainedSortedSet( - sortedSet, TEST_CONSTRAINT); - sortedSet.add(TEST_ELEMENT); - constrained.add("qux"); - constrained.addAll(asList("cat", "dog")); - assertTrue(sortedSet.equals(constrained)); - assertTrue(constrained.equals(sortedSet)); - assertEquals(sortedSet.toString(), constrained.toString()); - assertEquals(sortedSet.hashCode(), constrained.hashCode()); - ASSERT.that(sortedSet).has().exactly("bar", "cat", "dog", "foo", "qux", TEST_ELEMENT).inOrder(); - ASSERT.that(constrained).has() - .exactly("bar", "cat", "dog", "foo", "qux", TEST_ELEMENT).inOrder(); - assertNull(constrained.comparator()); - assertEquals("bar", constrained.first()); - assertEquals(TEST_ELEMENT, constrained.last()); - } - - public void testConstrainedSortedSetIllegal() { - SortedSet<String> sortedSet = Sets.newTreeSet(asList("foo", "bar")); - SortedSet<String> constrained = Constraints.constrainedSortedSet( - sortedSet, TEST_CONSTRAINT); - try { - constrained.add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.subSet("bar", "foo").add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.headSet("bar").add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.tailSet("foo").add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - ASSERT.that(constrained).has().exactly("bar", "foo").inOrder(); - ASSERT.that(sortedSet).has().exactly("bar", "foo").inOrder(); - } - - public void testConstrainedListLegal() { - List<String> list = Lists.newArrayList("foo", "bar"); - List<String> constrained = Constraints.constrainedList( - list, TEST_CONSTRAINT); - list.add(TEST_ELEMENT); - constrained.add("qux"); - constrained.addAll(asList("cat", "dog")); - constrained.add(1, "cow"); - constrained.addAll(4, asList("box", "fan")); - constrained.set(2, "baz"); - assertTrue(list.equals(constrained)); - assertTrue(constrained.equals(list)); - assertEquals(list.toString(), constrained.toString()); - assertEquals(list.hashCode(), constrained.hashCode()); - ASSERT.that(list).has().exactly( - "foo", "cow", "baz", TEST_ELEMENT, "box", "fan", "qux", "cat", "dog").inOrder(); - ASSERT.that(constrained).has().exactly( - "foo", "cow", "baz", TEST_ELEMENT, "box", "fan", "qux", "cat", "dog").inOrder(); - ListIterator<String> iterator = constrained.listIterator(); - iterator.next(); - iterator.set("sun"); - constrained.listIterator(2).add("sky"); - ASSERT.that(list).has().exactly( - "sun", "cow", "sky", "baz", TEST_ELEMENT, "box", "fan", "qux", "cat", "dog").inOrder(); - ASSERT.that(constrained).has().exactly( - "sun", "cow", "sky", "baz", TEST_ELEMENT, "box", "fan", "qux", "cat", "dog").inOrder(); - assertTrue(constrained instanceof RandomAccess); - } - - public void testConstrainedListRandomAccessFalse() { - List<String> list = Lists.newLinkedList(asList("foo", "bar")); - List<String> constrained = Constraints.constrainedList( - list, TEST_CONSTRAINT); - list.add(TEST_ELEMENT); - constrained.add("qux"); - assertFalse(constrained instanceof RandomAccess); - } - - public void testConstrainedListIllegal() { - List<String> list = Lists.newArrayList("foo", "bar"); - List<String> constrained = Constraints.constrainedList( - list, TEST_CONSTRAINT); - try { - constrained.add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.listIterator().add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.listIterator(1).add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.listIterator().set(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.listIterator(1).set(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.subList(0, 1).add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.add(1, TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.set(1, TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(1, asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - ASSERT.that(constrained).has().exactly("foo", "bar").inOrder(); - ASSERT.that(list).has().exactly("foo", "bar").inOrder(); - } - - public void testConstrainedMultisetLegal() { - Multiset<String> multiset = HashMultiset.create(asList("foo", "bar")); - Multiset<String> constrained = Constraints.constrainedMultiset( - multiset, TEST_CONSTRAINT); - multiset.add(TEST_ELEMENT); - constrained.add("qux"); - constrained.addAll(asList("cat", "dog")); - constrained.add("cow", 2); - assertTrue(multiset.equals(constrained)); - assertTrue(constrained.equals(multiset)); - assertEquals(multiset.toString(), constrained.toString()); - assertEquals(multiset.hashCode(), constrained.hashCode()); - ASSERT.that(multiset).has().exactly( - "foo", "bar", TEST_ELEMENT, "qux", "cat", "dog", "cow", "cow"); - ASSERT.that(constrained).has().exactly( - "foo", "bar", TEST_ELEMENT, "qux", "cat", "dog", "cow", "cow"); - assertEquals(1, constrained.count("foo")); - assertEquals(1, constrained.remove("foo", 3)); - assertEquals(2, constrained.setCount("cow", 0)); - ASSERT.that(multiset).has().exactly("bar", TEST_ELEMENT, "qux", "cat", "dog"); - ASSERT.that(constrained).has().exactly("bar", TEST_ELEMENT, "qux", "cat", "dog"); - } - - public void testConstrainedMultisetIllegal() { - Multiset<String> multiset = HashMultiset.create(asList("foo", "bar")); - Multiset<String> constrained = Constraints.constrainedMultiset( - multiset, TEST_CONSTRAINT); - try { - constrained.add(TEST_ELEMENT); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.add(TEST_ELEMENT, 2); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - try { - constrained.addAll(asList("baz", TEST_ELEMENT)); - fail("TestElementException expected"); - } catch (TestElementException expected) {} - ASSERT.that(constrained).has().exactly("foo", "bar"); - ASSERT.that(multiset).has().exactly("foo", "bar"); - } - - public void testNefariousAddAll() { - List<String> list = Lists.newArrayList("foo", "bar"); - List<String> constrained = Constraints.constrainedList( - list, TEST_CONSTRAINT); - Collection<String> onceIterable = onceIterableCollection("baz"); - constrained.addAll(onceIterable); - ASSERT.that(constrained).has().exactly("foo", "bar", "baz").inOrder(); - ASSERT.that(list).has().exactly("foo", "bar", "baz").inOrder(); - } - - /** - * Returns a "nefarious" collection, which permits only one call to - * iterator(). This verifies that the constrained collection uses a defensive - * copy instead of potentially checking the elements in one snapshot and - * adding the elements from another. - * - * @param element the element to be contained in the collection - */ - static <E> Collection<E> onceIterableCollection(final E element) { - return new AbstractCollection<E>() { - boolean iteratorCalled; - @Override public int size() { - /* - * We could make the collection empty, but that seems more likely to - * trigger special cases (so maybe we should test both empty and - * nonempty...). - */ - return 1; - } - @Override public Iterator<E> iterator() { - assertFalse("Expected only one call to iterator()", iteratorCalled); - iteratorCalled = true; - return Collections.singleton(element).iterator(); - } - }; - } -} - diff --git a/guava-gwt/test/com/google/common/collect/ConstraintsTest_gwt.java b/guava-gwt/test/com/google/common/collect/ConstraintsTest_gwt.java index 36300ec2e..6c091b2a2 100644 --- a/guava-gwt/test/com/google/common/collect/ConstraintsTest_gwt.java +++ b/guava-gwt/test/com/google/common/collect/ConstraintsTest_gwt.java @@ -43,16 +43,6 @@ public void testConstrainedListRandomAccessFalse() throws Exception { testCase.testConstrainedListRandomAccessFalse(); } -public void testConstrainedMultisetIllegal() throws Exception { - com.google.common.collect.ConstraintsTest testCase = new com.google.common.collect.ConstraintsTest(); - testCase.testConstrainedMultisetIllegal(); -} - -public void testConstrainedMultisetLegal() throws Exception { - com.google.common.collect.ConstraintsTest testCase = new com.google.common.collect.ConstraintsTest(); - testCase.testConstrainedMultisetLegal(); -} - public void testConstrainedSetIllegal() throws Exception { com.google.common.collect.ConstraintsTest testCase = new com.google.common.collect.ConstraintsTest(); testCase.testConstrainedSetIllegal(); @@ -77,9 +67,4 @@ public void testNefariousAddAll() throws Exception { com.google.common.collect.ConstraintsTest testCase = new com.google.common.collect.ConstraintsTest(); testCase.testNefariousAddAll(); } - -public void testNotNull() throws Exception { - com.google.common.collect.ConstraintsTest testCase = new com.google.common.collect.ConstraintsTest(); - testCase.testNotNull(); -} } |