Convert control statement bodies to block.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1429895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2013-01-07 16:55:07 +00:00
parent 49501d2f3c
commit 784f4752fc
16 changed files with 352 additions and 119 deletions

View File

@ -131,11 +131,17 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
switch (size) {
// drop through
case 3:
if (key3 == null) return value3;
if (key3 == null) {
return value3;
}
case 2:
if (key2 == null) return value2;
if (key2 == null) {
return value2;
}
case 1:
if (key1 == null) return value1;
if (key1 == null) {
return value1;
}
}
} else {
if (size > 0) {
@ -143,11 +149,17 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
switch (size) {
// drop through
case 3:
if (hash3 == hashCode && key.equals(key3)) return value3;
if (hash3 == hashCode && key.equals(key3)) {
return value3;
}
case 2:
if (hash2 == hashCode && key.equals(key2)) return value2;
if (hash2 == hashCode && key.equals(key2)) {
return value2;
}
case 1:
if (hash1 == hashCode && key.equals(key1)) return value1;
if (hash1 == hashCode && key.equals(key1)) {
return value1;
}
}
}
}
@ -189,22 +201,34 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
if (key == null) {
switch (size) { // drop through
case 3:
if (key3 == null) return true;
if (key3 == null) {
return true;
}
case 2:
if (key2 == null) return true;
if (key2 == null) {
return true;
}
case 1:
if (key1 == null) return true;
if (key1 == null) {
return true;
}
}
} else {
if (size > 0) {
int hashCode = key.hashCode();
switch (size) { // drop through
case 3:
if (hash3 == hashCode && key.equals(key3)) return true;
if (hash3 == hashCode && key.equals(key3)) {
return true;
}
case 2:
if (hash2 == hashCode && key.equals(key2)) return true;
if (hash2 == hashCode && key.equals(key2)) {
return true;
}
case 1:
if (hash1 == hashCode && key.equals(key1)) return true;
if (hash1 == hashCode && key.equals(key1)) {
return true;
}
}
}
}
@ -224,20 +248,32 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
if (value == null) { // drop through
switch (size) {
case 3:
if (value3 == null) return true;
if (value3 == null) {
return true;
}
case 2:
if (value2 == null) return true;
if (value2 == null) {
return true;
}
case 1:
if (value1 == null) return true;
if (value1 == null) {
return true;
}
}
} else {
switch (size) { // drop through
case 3:
if (value.equals(value3)) return true;
if (value.equals(value3)) {
return true;
}
case 2:
if (value.equals(value2)) return true;
if (value.equals(value2)) {
return true;
}
case 1:
if (value.equals(value1)) return true;
if (value.equals(value1)) {
return true;
}
}
}
return false;

View File

@ -71,7 +71,9 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
*/
@SuppressWarnings("unchecked")
public void testLinkedListAddFirst() {
if (!isAddSupported()) return;
if (!isAddSupported()) {
return;
}
T o = (T) "hello";
resetEmpty();
@ -90,7 +92,9 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
*/
@SuppressWarnings("unchecked")
public void testLinkedListAddLast() {
if (!isAddSupported()) return;
if (!isAddSupported()) {
return;
}
T o = (T) "hello";
resetEmpty();
@ -152,7 +156,9 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
* Tests {@link LinkedList#removeFirst()}.
*/
public void testLinkedListRemoveFirst() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
try {
@ -176,7 +182,9 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
* Tests {@link LinkedList#removeLast()}.
*/
public void testLinkedListRemoveLast() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
try {

View File

@ -324,8 +324,12 @@ class BulkTestSuiteMaker {
Class<? extends BulkTest> c = bulk.getClass();
Method[] all = c.getMethods();
for (Method element : all) {
if (isTest(element)) addTest(bulk, element);
if (isBulk(element)) addBulk(bulk, element);
if (isTest(element)) {
addTest(bulk, element);
}
if (isBulk(element)) {
addBulk(bulk, element);
}
}
}
@ -341,7 +345,9 @@ class BulkTestSuiteMaker {
BulkTest bulk2 = (BulkTest)bulk.clone();
bulk2.setName(m.getName());
bulk2.verboseName = prefix + "." + m.getName();
if (ignored.contains(bulk2.verboseName)) return;
if (ignored.contains(bulk2.verboseName)) {
return;
}
result.addTest(bulk2);
}
@ -356,12 +362,16 @@ class BulkTestSuiteMaker {
*/
void addBulk(BulkTest bulk, Method m) {
String verboseName = prefix + "." + m.getName();
if (ignored.contains(verboseName)) return;
if (ignored.contains(verboseName)) {
return;
}
BulkTest bulk2;
try {
bulk2 = (BulkTest)m.invoke(bulk, (Object[]) null);
if (bulk2 == null) return;
if (bulk2 == null) {
return;
}
} catch (InvocationTargetException ex) {
ex.getTargetException().printStackTrace();
throw new Error(); // FIXME;
@ -432,7 +442,9 @@ class BulkTestSuiteMaker {
private static <T extends BulkTest> BulkTest makeFirstTestCase(Class<T> c) {
Method[] all = c.getMethods();
for (Method element : all) {
if (isTest(element)) return makeTestCase(c, element);
if (isTest(element)) {
return makeTestCase(c, element);
}
}
throw new IllegalArgumentException(c.getName() + " must provide "
+ " at least one test method.");
@ -442,12 +454,22 @@ class BulkTestSuiteMaker {
* Returns true if the given method is a simple test method.
*/
private static boolean isTest(Method m) {
if (!m.getName().startsWith("test")) return false;
if (m.getReturnType() != Void.TYPE) return false;
if (m.getParameterTypes().length != 0) return false;
if (!m.getName().startsWith("test")) {
return false;
}
if (m.getReturnType() != Void.TYPE) {
return false;
}
if (m.getParameterTypes().length != 0) {
return false;
}
int mods = m.getModifiers();
if (Modifier.isStatic(mods)) return false;
if (Modifier.isAbstract(mods)) return false;
if (Modifier.isStatic(mods)) {
return false;
}
if (Modifier.isAbstract(mods)) {
return false;
}
return true;
}
@ -455,12 +477,22 @@ class BulkTestSuiteMaker {
* Returns true if the given method is a bulk test method.
*/
private static boolean isBulk(Method m) {
if (!m.getName().startsWith("bulkTest")) return false;
if (m.getReturnType() != BulkTest.class) return false;
if (m.getParameterTypes().length != 0) return false;
if (!m.getName().startsWith("bulkTest")) {
return false;
}
if (m.getReturnType() != BulkTest.class) {
return false;
}
if (m.getParameterTypes().length != 0) {
return false;
}
int mods = m.getModifiers();
if (Modifier.isStatic(mods)) return false;
if (Modifier.isAbstract(mods)) return false;
if (Modifier.isStatic(mods)) {
return false;
}
if (Modifier.isAbstract(mods)) {
return false;
}
return true;
}

View File

@ -454,7 +454,9 @@ public abstract class AbstractBagTest<T> extends AbstractObjectTest {
//-----------------------------------------------------------------------
public void testEmptyBagSerialization() throws IOException, ClassNotFoundException {
Bag<T> bag = makeObject();
if (!(bag instanceof Serializable && isTestSerialization())) return;
if (!(bag instanceof Serializable && isTestSerialization())) {
return;
}
byte[] objekt = writeExternalFormToBytes((Serializable) bag);
Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);
@ -472,7 +474,9 @@ public abstract class AbstractBagTest<T> extends AbstractObjectTest {
bag.add((T) "B");
bag.add((T) "C");
int size = bag.size();
if (!(bag instanceof Serializable && isTestSerialization())) return;
if (!(bag instanceof Serializable && isTestSerialization())) {
return;
}
byte[] objekt = writeExternalFormToBytes((Serializable) bag);
Bag<?> bag2 = (Bag<?>) readExternalFormFromBytes(objekt);

View File

@ -80,7 +80,9 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest<
//-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testBidiPut() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
BidiMap<K, V> map = makeObject();
BidiMap<V, K> inverse = map.inverseBidiMap();
@ -179,7 +181,9 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest<
//-----------------------------------------------------------------------
public void testBidiModifyEntrySet() {
if (isSetValueSupported() == false) return;
if (isSetValueSupported() == false) {
return;
}
modifyEntrySet(makeFullMap());
modifyEntrySet(makeFullMap().inverseBidiMap());
@ -282,7 +286,9 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest<
//-----------------------------------------------------------------------
public void testBidiRemoveByKeySet() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
removeByKeySet(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]);
removeByKeySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);
@ -304,7 +310,9 @@ public abstract class AbstractBidiMapTest<K, V> extends AbstractIterableMapTest<
//-----------------------------------------------------------------------
public void testBidiRemoveByEntrySet() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
removeByEntrySet(makeFullMap(), getSampleKeys()[0], getSampleValues()[0]);
removeByEntrySet(makeFullMap().inverseBidiMap(), getSampleValues()[0], getSampleKeys()[0]);

View File

@ -129,7 +129,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiClearByHeadMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -174,7 +176,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveByHeadMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -216,7 +220,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveByHeadMapEntrySet() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -297,7 +303,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiClearByTailMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -344,7 +352,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveByTailMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -387,7 +397,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveByTailMapEntrySet() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -475,7 +487,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiClearBySubMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -530,7 +544,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveBySubMap() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();
@ -574,7 +590,9 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
//-----------------------------------------------------------------------
public void testBidiRemoveBySubMapEntrySet() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
// extra test as other tests get complex
SortedBidiMap<K, V> sm = makeFullMap();

View File

@ -329,8 +329,9 @@ public class PriorityBufferTest<E> extends AbstractCollectionTest<E> {
StringBuilder buffer = new StringBuilder();
for (int offset = 1; count < h.size() + 1; offset *= 2) {
for (int i = offset; i < offset * 2; i++) {
if (i < h.elements.length && h.elements[i] != null)
if (i < h.elements.length && h.elements[i] != null) {
buffer.append(h.elements[i] + " ");
}
count++;
}
buffer.append('\n');

View File

@ -497,7 +497,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests {@link Collection#add(Object)}.
*/
public void testCollectionAdd() {
if (!isAddSupported()) return;
if (!isAddSupported()) {
return;
}
E[] elements = getFullElements();
for (E element : elements) {
@ -515,7 +517,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
boolean r = getCollection().add(element);
getConfirmed().add(element);
verify();
if (r) size++;
if (r) {
size++;
}
assertEquals("Collection size should grow after add", size, getCollection().size());
assertTrue("Collection should contain added element", getCollection().contains(element));
}
@ -525,7 +529,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests {@link Collection#addAll(Collection)}.
*/
public void testCollectionAddAll() {
if (!isAddSupported()) return;
if (!isAddSupported()) {
return;
}
resetEmpty();
E[] elements = getFullElements();
@ -567,7 +573,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* raise <code>UnsupportedOperationException.
*/
public void testUnsupportedAdd() {
if (isAddSupported()) return;
if (isAddSupported()) {
return;
}
resetEmpty();
try {
@ -616,7 +624,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Test {@link Collection#clear()}.
*/
public void testCollectionClear() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
getCollection().clear(); // just to make sure it doesn't raise anything
@ -776,7 +786,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
*/
@SuppressWarnings("unchecked")
public void testCollectionIteratorRemove() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
try {
@ -844,7 +856,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests {@link Collection#remove(Object)}.
*/
public void testCollectionRemove() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
E[] elements = getFullElements();
@ -888,7 +902,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests {@link Collection#removeAll(Collection)}.
*/
public void testCollectionRemoveAll() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
assertTrue("Empty collection removeAll should return false for empty input",
@ -935,7 +951,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests {@link Collection#retainAll(Collection)}.
*/
public void testCollectionRetainAll() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetEmpty();
List<E> elements = Arrays.asList(getFullElements());
@ -1029,8 +1047,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
// find a match in the confirmed array
for (int j = 0; j < array.length; j++) {
// skip already matched
if (matched[j])
if (matched[j]) {
continue;
}
if (array[i] == confirmedArray[j]
|| (array[i] != null && array[i].equals(confirmedArray[j]))) {
matched[j] = true;
@ -1088,7 +1107,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
for (Object element : array) {
classes.add((element == null) ? null : element.getClass());
}
if (classes.size() > 1) return;
if (classes.size() > 1) {
return;
}
Class<?> cl = classes.iterator().next();
if (Map.Entry.class.isAssignableFrom(cl)) { // check needed for protective cases like Predicated/Unmod map entrySet
@ -1120,7 +1141,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* operations raise an UnsupportedOperationException.
*/
public void testUnsupportedRemove() {
if (isRemoveSupported()) return;
if (isRemoveSupported()) {
return;
}
resetEmpty();
try {
@ -1172,7 +1195,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
* Tests that the collection's iterator is fail-fast.
*/
public void testCollectionIteratorFailFast() {
if (!isFailFastSupported()) return;
if (!isFailFastSupported()) {
return;
}
if (isAddSupported()) {
resetFull();
@ -1201,7 +1226,9 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
verify();
}
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetFull();
try {

View File

@ -115,7 +115,9 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
@SuppressWarnings("unchecked")
public void testRemoveNode() {
resetEmpty();
if (isAddSupported() == false || isRemoveSupported() == false) return;
if (isAddSupported() == false || isRemoveSupported() == false) {
return;
}
AbstractLinkedList<E> list = getCollection();
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));

View File

@ -572,7 +572,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* full list.
*/
public void testListSetByIndexBoundsChecking2() {
if (!isSetSupported()) return;
if (!isSetSupported()) {
return;
}
List<E> list = makeFullCollection();
E element = getOtherElements()[0];
@ -613,7 +615,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Test {@link List#set(int,Object)}.
*/
public void testListSetByIndex() {
if (!isSetSupported()) return;
if (!isSetSupported()) {
return;
}
resetFull();
E[] elements = getFullElements();
@ -633,7 +637,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* raises <Code>UnsupportedOperationException.
*/
public void testUnsupportedSet() {
if (isSetSupported()) return;
if (isSetSupported()) {
return;
}
resetFull();
try {
@ -652,7 +658,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* empty list.
*/
public void testListRemoveByIndexBoundsChecking() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
List<E> list = makeObject();
@ -697,7 +705,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* full list.
*/
public void testListRemoveByIndexBoundsChecking2() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
List<E> list = makeFullCollection();
@ -737,7 +747,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Tests {@link List#remove(int)}.
*/
public void testListRemoveByIndex() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
int max = getFullElements().length;
for (int i = 0; i < max; i++) {
@ -786,9 +798,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Tests remove on list iterator is correct.
*/
public void testListListIteratorPreviousRemoveNext() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
resetFull();
if (getCollection().size() < 4) return;
if (getCollection().size() < 4) {
return;
}
ListIterator<E> it = getCollection().listIterator();
E zero = it.next();
E one = it.next();
@ -814,9 +830,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Tests remove on list iterator is correct.
*/
public void testListListIteratorPreviousRemovePrevious() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
resetFull();
if (getCollection().size() < 4) return;
if (getCollection().size() < 4) {
return;
}
ListIterator<E> it = getCollection().listIterator();
E zero = it.next();
E one = it.next();
@ -842,9 +862,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Tests remove on list iterator is correct.
*/
public void testListListIteratorNextRemoveNext() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
resetFull();
if (getCollection().size() < 4) return;
if (getCollection().size() < 4) {
return;
}
ListIterator<E> it = getCollection().listIterator();
E zero = it.next();
E one = it.next();
@ -867,9 +891,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* Tests remove on list iterator is correct.
*/
public void testListListIteratorNextRemovePrevious() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
resetFull();
if (getCollection().size() < 4) return;
if (getCollection().size() < 4) {
return;
}
ListIterator<E> it = getCollection().listIterator();
E zero = it.next();
E one = it.next();
@ -964,7 +992,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* iterator.
*/
public void testListIteratorAdd() {
if (!isAddSupported()) return;
if (!isAddSupported()) {
return;
}
resetEmpty();
List<E> list1 = getCollection();
@ -997,7 +1027,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* iterator.
*/
public void testListIteratorSet() {
if (!isSetSupported()) return;
if (!isSetSupported()) {
return;
}
E[] elements = getFullElements();
@ -1016,7 +1048,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
@SuppressWarnings("unchecked")
public void testEmptyListSerialization() throws IOException, ClassNotFoundException {
List<E> list = makeObject();
if (!(list instanceof Serializable && isTestSerialization())) return;
if (!(list instanceof Serializable && isTestSerialization())) {
return;
}
byte[] objekt = writeExternalFormToBytes((Serializable) list);
List<E> list2 = (List<E>) readExternalFormFromBytes(objekt);
@ -1029,7 +1063,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
public void testFullListSerialization() throws IOException, ClassNotFoundException {
List<E> list = makeFullCollection();
int size = getFullElements().length;
if (!(list instanceof Serializable && isTestSerialization())) return;
if (!(list instanceof Serializable && isTestSerialization())) {
return;
}
byte[] objekt = writeExternalFormToBytes((Serializable) list);
List<E> list2 = (List<E>) readExternalFormFromBytes(objekt);
@ -1113,7 +1149,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* modified when the sublist is.
*/
public BulkTest bulkTestSubList() {
if (getFullElements().length - 6 < 10) return null;
if (getFullElements().length - 6 < 10) {
return null;
}
return new BulkTestSubList<E>(this);
}
@ -1196,8 +1234,12 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* if elements are added to the original list.
*/
public void testListSubListFailFastOnAdd() {
if (!isFailFastSupported()) return;
if (!isAddSupported()) return;
if (!isFailFastSupported()) {
return;
}
if (!isAddSupported()) {
return;
}
resetFull();
int size = getCollection().size();
@ -1226,8 +1268,12 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* if elements are removed from the original list.
*/
public void testListSubListFailFastOnRemove() {
if (!isFailFastSupported()) return;
if (!isRemoveSupported()) return;
if (!isFailFastSupported()) {
return;
}
if (!isRemoveSupported()) {
return;
}
resetFull();
int size = getCollection().size();
@ -1280,7 +1326,9 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
* @param m the method to invoke
*/
protected void failFastMethod(List<E> list, Method m) {
if (m.getName().equals("equals")) return;
if (m.getName().equals("equals")) {
return;
}
E element = getOtherElements()[0];
Collection<E> c = Collections.singleton(element);
@ -1288,10 +1336,15 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
Class<?>[] types = m.getParameterTypes();
Object[] params = new Object[types.length];
for (int i = 0; i < params.length; i++) {
if (types[i] == Integer.TYPE) params[i] = new Integer(0);
else if (types[i] == Collection.class) params[i] = c;
else if (types[i] == Object.class) params[i] = element;
else if (types[i] == Object[].class) params[i] = new Object[0];
if (types[i] == Integer.TYPE) {
params[i] = new Integer(0);
} else if (types[i] == Collection.class) {
params[i] = c;
} else if (types[i] == Object.class) {
params[i] = element;
} else if (types[i] == Object[].class) {
params[i] = new Object[0];
}
}
try {

View File

@ -55,7 +55,9 @@ public class NodeCachingLinkedListTest<E> extends AbstractLinkedListTest<E> {
//-----------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void testShrinkCache() {
if (isRemoveSupported() == false || isAddSupported() == false) return;
if (isRemoveSupported() == false || isAddSupported() == false) {
return;
}
resetEmpty();
NodeCachingLinkedList<E> list = getCollection();

View File

@ -59,8 +59,12 @@ public abstract class AbstractIterableMapTest<K, V> extends AbstractMapTest<K, V
//-----------------------------------------------------------------------
public void testFailFastEntrySet() {
if (isRemoveSupported() == false) return;
if (isFailFastExpected() == false) return;
if (isRemoveSupported() == false) {
return;
}
if (isFailFastExpected() == false) {
return;
}
resetFull();
Iterator<Map.Entry<K, V>> it = getMap().entrySet().iterator();
Map.Entry<K, V> val = it.next();
@ -81,8 +85,12 @@ public abstract class AbstractIterableMapTest<K, V> extends AbstractMapTest<K, V
}
public void testFailFastKeySet() {
if (isRemoveSupported() == false) return;
if (isFailFastExpected() == false) return;
if (isRemoveSupported() == false) {
return;
}
if (isFailFastExpected() == false) {
return;
}
resetFull();
Iterator<K> it = getMap().keySet().iterator();
K val = it.next();
@ -103,8 +111,12 @@ public abstract class AbstractIterableMapTest<K, V> extends AbstractMapTest<K, V
}
public void testFailFastValues() {
if (isRemoveSupported() == false) return;
if (isFailFastExpected() == false) return;
if (isRemoveSupported() == false) {
return;
}
if (isFailFastExpected() == false) {
return;
}
resetFull();
Iterator<V> it = getMap().values().iterator();
it.next();

View File

@ -1028,7 +1028,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
* the underlying map for clear().
*/
public void testValuesClearChangesMap() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
// clear values, reflected in map
resetFull();
@ -1054,7 +1056,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
* the underlying map for clear().
*/
public void testKeySetClearChangesMap() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
// clear values, reflected in map
resetFull();
@ -1080,7 +1084,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
* the underlying map for clear().
*/
public void testEntrySetClearChangesMap() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
// clear values, reflected in map
resetFull();
@ -1129,7 +1135,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
}
public void testEntrySetRemove1() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetFull();
int size = getMap().size();
Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
@ -1142,7 +1150,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
}
public void testEntrySetRemove2() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetFull();
int size = getMap().size();
Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
@ -1157,7 +1167,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
@SuppressWarnings("unchecked")
public void testEntrySetRemove3() {
if (!isRemoveSupported()) return;
if (!isRemoveSupported()) {
return;
}
resetFull();
int size = getMap().size();
Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
@ -1684,7 +1696,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
}
public void testMapEntrySetRemoveNonMapEntry() {
if (isRemoveSupported() == false) return;
if (isRemoveSupported() == false) {
return;
}
resetFull();
assertEquals(false, getCollection().remove(null));
assertEquals(false, getCollection().remove(new Object()));

View File

@ -238,7 +238,9 @@ public abstract class AbstractSortedMapTest<K, V> extends AbstractMapTest<K, V>
return ((SortedMap<K, V>) main.makeFullMap()).headMap(toKey);
}
public void testHeadMapOutOfRange() {
if (isPutAddSupported() == false) return;
if (isPutAddSupported() == false) {
return;
}
resetEmpty();
try {
getMap().put(toKey, subSortedValues.get(0));
@ -291,7 +293,9 @@ public abstract class AbstractSortedMapTest<K, V> extends AbstractMapTest<K, V>
return ((SortedMap<K, V>) main.makeFullMap()).tailMap(fromKey);
}
public void testTailMapOutOfRange() {
if (isPutAddSupported() == false) return;
if (isPutAddSupported() == false) {
return;
}
resetEmpty();
try {
getMap().put(invalidKey, subSortedValues.get(0));
@ -351,7 +355,9 @@ public abstract class AbstractSortedMapTest<K, V> extends AbstractMapTest<K, V>
return ((SortedMap<K, V>) main.makeFullMap()).subMap(fromKey, toKey);
}
public void testSubMapOutOfRange() {
if (isPutAddSupported() == false) return;
if (isPutAddSupported() == false) {
return;
}
resetEmpty();
try {
getMap().put(toKey, subSortedValues.get(0));

View File

@ -70,7 +70,9 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
//-----------------------------------------------------------------------
public void testLRU() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
K[] keys = getSampleKeys();
V[] values = getSampleValues();
Iterator<K> kit;
@ -150,7 +152,9 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
//-----------------------------------------------------------------------
public void testAccessOrder() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
K[] keys = getSampleKeys();
V[] values = getSampleValues();
Iterator<K> kit = null;
@ -364,7 +368,9 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
@SuppressWarnings("unchecked")
public void testInternalState_Buckets() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
SingleHashCode one = new SingleHashCode("1");
SingleHashCode two = new SingleHashCode("2");
SingleHashCode three = new SingleHashCode("3");
@ -452,7 +458,9 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
@SuppressWarnings("unchecked")
public void testInternalState_getEntry_int() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
SingleHashCode one = new SingleHashCode("1");
SingleHashCode two = new SingleHashCode("2");
SingleHashCode three = new SingleHashCode("3");

View File

@ -82,7 +82,9 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
//-----------------------------------------------------------------------
public void testInsertionOrder() {
if (isPutAddSupported() == false || isPutChangeSupported() == false) return;
if (isPutAddSupported() == false || isPutChangeSupported() == false) {
return;
}
K[] keys = getSampleKeys();
V[] values = getSampleValues();
Iterator<K> keyIter;