Skip to content

Commit

Permalink
Remove static imports of of/copyOf
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Corcoran committed Dec 21, 2015
1 parent 76ac6e1 commit fb07b16
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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<Byte> BYTES_NEEDING_ESCAPING =
of((byte) '\0', (byte) '\b', (byte) '\n', (byte) '\r', (byte) '\t', (byte) MYSQL_ESCAPE_CHAR, (byte) 26);
protected static final Set<Byte> 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
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)));
}

/**
Expand Down
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -136,10 +134,10 @@ public List<SecondaryTable> 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;
}
Expand Down Expand Up @@ -310,7 +308,7 @@ public boolean apply(Method m) {
* @return the list of methods
*/
public List<Method> methodsAnnotatedWith(Class<?> aClass, Predicate<Method> predicate) {
return newArrayList(Iterables.filter(copyOf(ReflectionUtils.getAllDeclaredMethods(aClass)), predicate));
return newArrayList(Iterables.filter(ImmutableList.copyOf(ReflectionUtils.getAllDeclaredMethods(aClass)), predicate));
}

/**
Expand Down
@@ -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;
Expand All @@ -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}
*
Expand All @@ -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<String> TABLES = of("customer", "product", "contact", "contact_phone", "binary_data", "supplier");
private static final List<String> TABLES =
ImmutableList.of("customer", "product", "contact", "contact_phone", "binary_data", "supplier");
private static final String DB_USER = "root";
private static final String DB_PASSWORD = "";

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
);
}
Expand Down

0 comments on commit fb07b16

Please sign in to comment.