From fb07b16b78c408973b7cf8e612cc05c5821c3279 Mon Sep 17 00:00:00 2001 From: Brian Corcoran Date: Fri, 18 Dec 2015 10:25:02 -0500 Subject: [PATCH] Remove static imports of `of`/`copyOf` --- .../persistence/jpile/infile/InfileDataBuffer.java | 12 +++++++++--- .../jpile/loader/HierarchicalInfileObjectLoader.java | 5 ++--- .../reflection/PersistenceAnnotationInspector.java | 8 +++----- .../persistence/jpile/AbstractIntTestForJPile.java | 6 +++--- .../PersistenceAnnotationInspectorTest.java | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/opower/persistence/jpile/infile/InfileDataBuffer.java b/src/main/java/com/opower/persistence/jpile/infile/InfileDataBuffer.java index 64d2110..3829f60 100644 --- a/src/main/java/com/opower/persistence/jpile/infile/InfileDataBuffer.java +++ b/src/main/java/com/opower/persistence/jpile/infile/InfileDataBuffer.java @@ -3,6 +3,7 @@ import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; import com.opower.persistence.jpile.reflection.CachedProxy; import com.opower.persistence.jpile.reflection.PersistenceAnnotationInspector; import org.joda.time.format.DateTimeFormat; @@ -25,7 +26,6 @@ import java.util.regex.Pattern; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.ImmutableSet.of; /** * A buffer used to collect data in MySQL's infile format. This buffer also maintains a separate row buffer @@ -62,8 +62,14 @@ public class InfileDataBuffer implements InfileRow { protected static final String MYSQL_NULL_STRING = MYSQL_ESCAPE_CHAR + "N"; // List of bytes that will need escaping as they hold special meaning to MYSQL // See http://dev.mysql.com/doc/refman/5.1/en/load-data.html - protected static final Set BYTES_NEEDING_ESCAPING = - of((byte) '\0', (byte) '\b', (byte) '\n', (byte) '\r', (byte) '\t', (byte) MYSQL_ESCAPE_CHAR, (byte) 26); + protected static final Set BYTES_NEEDING_ESCAPING = ImmutableSet.of( + (byte) '\0', + (byte) '\b', + (byte) '\n', + (byte) '\r', + (byte) '\t', + (byte) MYSQL_ESCAPE_CHAR, + (byte) 26); private static final String TEMPORAL_TYPE_EXCEPTION = "The Temporal.value should be TemporalType.DATE, TemporalType.TIME, or TemporalType.TIMESTAMP on method [%s]"; // This Pattern matches on all of the BYTES_NEEDING_ESCAPING diff --git a/src/main/java/com/opower/persistence/jpile/loader/HierarchicalInfileObjectLoader.java b/src/main/java/com/opower/persistence/jpile/loader/HierarchicalInfileObjectLoader.java index 3d63c1c..1df7dbe 100644 --- a/src/main/java/com/opower/persistence/jpile/loader/HierarchicalInfileObjectLoader.java +++ b/src/main/java/com/opower/persistence/jpile/loader/HierarchicalInfileObjectLoader.java @@ -2,6 +2,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.opower.persistence.jpile.infile.InfileDataBuffer; import com.opower.persistence.jpile.reflection.CachedProxy; @@ -28,8 +29,6 @@ import java.util.Set; import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.ImmutableList.copyOf; -import static com.google.common.collect.ImmutableList.of; import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Maps.newLinkedHashMap; @@ -80,7 +79,7 @@ public class HierarchicalInfileObjectLoader implements Flushable, Closeable { * @param moreObjects optional more objects */ public void persist(Object firstObject, Object... moreObjects) { - persist(concat(of(firstObject), copyOf(moreObjects))); + persist(concat(ImmutableList.of(firstObject), ImmutableList.copyOf(moreObjects))); } /** diff --git a/src/main/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspector.java b/src/main/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspector.java index 48224df..5fcfafc 100644 --- a/src/main/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspector.java +++ b/src/main/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspector.java @@ -17,8 +17,6 @@ import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.ReflectionUtils; -import static com.google.common.collect.ImmutableList.copyOf; -import static com.google.common.collect.ImmutableList.of; import static com.google.common.collect.Lists.newArrayList; /** @@ -136,10 +134,10 @@ public List findSecondaryTables(Class aClass) { SecondaryTable secondaryTable = findAnnotation(aClass, SecondaryTable.class); SecondaryTables secondaryTables = findAnnotation(aClass, SecondaryTables.class); if (secondaryTables != null) { - annotations = copyOf(secondaryTables.value()); + annotations = ImmutableList.copyOf(secondaryTables.value()); } else if (secondaryTable != null) { - annotations = of(secondaryTable); + annotations = ImmutableList.of(secondaryTable); } return annotations; } @@ -310,7 +308,7 @@ public boolean apply(Method m) { * @return the list of methods */ public List methodsAnnotatedWith(Class aClass, Predicate predicate) { - return newArrayList(Iterables.filter(copyOf(ReflectionUtils.getAllDeclaredMethods(aClass)), predicate)); + return newArrayList(Iterables.filter(ImmutableList.copyOf(ReflectionUtils.getAllDeclaredMethods(aClass)), predicate)); } /** diff --git a/src/test/java/com/opower/persistence/jpile/AbstractIntTestForJPile.java b/src/test/java/com/opower/persistence/jpile/AbstractIntTestForJPile.java index ad594fc..e07334d 100644 --- a/src/test/java/com/opower/persistence/jpile/AbstractIntTestForJPile.java +++ b/src/test/java/com/opower/persistence/jpile/AbstractIntTestForJPile.java @@ -1,6 +1,7 @@ package com.opower.persistence.jpile; import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableList; import com.opower.persistence.jpile.loader.HierarchicalInfileObjectLoader; import org.junit.After; import org.junit.AfterClass; @@ -18,8 +19,6 @@ import java.sql.DriverManager; import java.util.List; -import static com.google.common.collect.ImmutableList.of; - /** * Abstract test case for all int tests. Loads MySQL drivers and creates a new MySQL {@link Connection} * @@ -29,7 +28,8 @@ @ContextConfiguration public abstract class AbstractIntTestForJPile { private static final String JDBC_URL = "jdbc:mysql://localhost/jpile?useUnicode=true&characterEncoding=utf-8"; - private static final List TABLES = of("customer", "product", "contact", "contact_phone", "binary_data", "supplier"); + private static final List TABLES = + ImmutableList.of("customer", "product", "contact", "contact_phone", "binary_data", "supplier"); private static final String DB_USER = "root"; private static final String DB_PASSWORD = ""; diff --git a/src/test/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspectorTest.java b/src/test/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspectorTest.java index 3f323b1..8530cb1 100644 --- a/src/test/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspectorTest.java +++ b/src/test/java/com/opower/persistence/jpile/reflection/PersistenceAnnotationInspectorTest.java @@ -10,12 +10,12 @@ import javax.persistence.Table; import javax.persistence.Temporal; +import com.google.common.collect.ImmutableList; import com.opower.persistence.jpile.sample.Contact; import com.opower.persistence.jpile.sample.Customer; import com.opower.persistence.jpile.sample.Product; import org.junit.Test; -import static com.google.common.collect.ImmutableList.copyOf; import static junit.framework.Assert.assertNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -157,7 +157,7 @@ public void testHasAnnotation() { @Test public void testFindSecondaryTableAnnotations() throws Exception { assertEquals( - copyOf(Contact.class.getAnnotation(SecondaryTables.class).value()), + ImmutableList.copyOf(Contact.class.getAnnotation(SecondaryTables.class).value()), annotationInspector.findSecondaryTables(Contact.class) ); }