From 8e4cafc9fe0c95a1ccd93c909c453c2c3b1a24c2 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 14 Nov 2012 21:24:30 +0100 Subject: [PATCH 02/25] Fix Java compile warnings. --- .../test/net/lemnik/eodsql/mock/MockQueryFactoryTest.java | 6 +++--- eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/User.java | 1 + .../addon/eod-mock/test/net/lemnik/eodsql/mock/UserQueryMock.java | 8 ++++---- eodsql/src/net/lemnik/eodsql/ArrayDataSetCache.java | 1 - eodsql/src/net/lemnik/eodsql/QueryFactoryChain.java | 2 +- eodsql/src/net/lemnik/eodsql/QuickQueryUtil.java | 1 + eodsql/src/net/lemnik/eodsql/ServiceUtil.java | 2 +- .../src/net/lemnik/eodsql/impl/AbstractMethodImplementation.java | 2 -- eodsql/src/net/lemnik/eodsql/impl/DefaultQueryFactory.java | 3 --- eodsql/src/net/lemnik/eodsql/spi/util/DataIteratorWrapper.java | 1 - eodsql/src/net/lemnik/eodsql/spi/util/DataSetWrapper.java | 1 - .../net/lemnik/eodsql/spi/util/TypeMapperDataObjectBinding.java | 1 - eodsql/test/net/lemnik/eodsql/AutoGeneratedKeysTest.java | 1 - eodsql/test/net/lemnik/eodsql/Birthday.java | 1 + eodsql/test/net/lemnik/eodsql/QueryTest.java | 1 + eodsql/test/net/lemnik/eodsql/SelectPrimitiveTest.java | 4 +--- eodsql/test/net/lemnik/eodsql/TransactionTest.java | 3 ++- 17 files changed, 16 insertions(+), 23 deletions(-) diff --git a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/MockQueryFactoryTest.java b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/MockQueryFactoryTest.java index d598e93..47e9881 100644 --- a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/MockQueryFactoryTest.java +++ b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/MockQueryFactoryTest.java @@ -4,7 +4,7 @@ package net.lemnik.eodsql.mock; -import java.util.Date; +import java.util.GregorianCalendar; import junit.framework.TestCase; import net.lemnik.eodsql.DataSet; @@ -19,7 +19,7 @@ public class MockQueryFactoryTest extends TestCase { public void testInsert() { final UserQuery query = QueryTool.getQuery(UserQuery.class); - final User id = query.insert(new User("mug@food.com", "Lester Mug", new Date(61, 12, 12))); + final User id = query.insert(new User("mug@food.com", "Lester Mug", new GregorianCalendar(1961, 12, 12).getTime())); assertNotNull(id); assertNotNull(id.getId()); @@ -35,7 +35,7 @@ public class MockQueryFactoryTest extends TestCase { assertNotNull(jeff); assertEquals(Long.valueOf(1), jeff.getId()); assertEquals("Jeff Site", jeff.getUsername()); - assertEquals(new Date(76, 8, 23), jeff.getBirthDate()); + assertEquals(new GregorianCalendar(1976, 8, 23).getTime(), jeff.getBirthDate()); } public void testSelectDataSet() { diff --git a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/User.java b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/User.java index 583422a..2034e87 100644 --- a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/User.java +++ b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/User.java @@ -27,6 +27,7 @@ public class User { @ResultColumn("birth_date") private Date birthDate; + @SuppressWarnings("unused") private User() { } diff --git a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/UserQueryMock.java b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/UserQueryMock.java index 3a54449..c1ed96a 100644 --- a/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/UserQueryMock.java +++ b/eodsql/addon/eod-mock/test/net/lemnik/eodsql/mock/UserQueryMock.java @@ -4,9 +4,9 @@ package net.lemnik.eodsql.mock; +import java.util.GregorianCalendar; import java.util.List; import java.util.ArrayList; -import java.util.Date; import net.lemnik.eodsql.DataSet; @@ -23,9 +23,9 @@ public class UserQueryMock extends AbstractMockQuery implements UserQuery { private final List users = new ArrayList(); public UserQueryMock() { - insert(new User("joe.bloggs@nowhere.com", "Joe Bloggs", new Date(83, 3, 6))); - insert(new User("jeff@jeffswebsite.com", "Jeff Site", new Date(76, 8, 23))); - insert(new User("logan@murkmurk.com", "Logan Sleep", new Date(90, 4, 1))); + insert(new User("joe.bloggs@nowhere.com", "Joe Bloggs", new GregorianCalendar(1983, 3, 6).getTime())); + insert(new User("jeff@jeffswebsite.com", "Jeff Site", new GregorianCalendar(1976, 8, 23).getTime())); + insert(new User("logan@murkmurk.com", "Logan Sleep", new GregorianCalendar(1990, 4, 1).getTime())); } public User selectByEmail(final String email) { diff --git a/eodsql/src/net/lemnik/eodsql/ArrayDataSetCache.java b/eodsql/src/net/lemnik/eodsql/ArrayDataSetCache.java index 7245da1..f440215 100644 --- a/eodsql/src/net/lemnik/eodsql/ArrayDataSetCache.java +++ b/eodsql/src/net/lemnik/eodsql/ArrayDataSetCache.java @@ -89,7 +89,6 @@ public class ArrayDataSetCache implements DataSetCache { * * @see IndexedWeakReference */ - @SuppressWarnings("unchecked") private void removeOldEntries() { IndexedWeakReference ref = null; diff --git a/eodsql/src/net/lemnik/eodsql/QueryFactoryChain.java b/eodsql/src/net/lemnik/eodsql/QueryFactoryChain.java index b2f54af..63e99a1 100644 --- a/eodsql/src/net/lemnik/eodsql/QueryFactoryChain.java +++ b/eodsql/src/net/lemnik/eodsql/QueryFactoryChain.java @@ -161,7 +161,7 @@ class QueryFactoryChain { * instead of a {@code DataSource}. * * @param the generic type of query to create - * @param context the {@code Connection} to back the created query with + * @param connection the {@code Connection} to back the created query with * @param query the class type instance of the query to implement * @param loader the {@code ClassLoader} to use to create the query type * @return an instance of the requested query, backed by the given diff --git a/eodsql/src/net/lemnik/eodsql/QuickQueryUtil.java b/eodsql/src/net/lemnik/eodsql/QuickQueryUtil.java index 1a7c57b..e9c347f 100644 --- a/eodsql/src/net/lemnik/eodsql/QuickQueryUtil.java +++ b/eodsql/src/net/lemnik/eodsql/QuickQueryUtil.java @@ -86,6 +86,7 @@ class QuickQueryUtil { return NoDataObjectBinding.class; } + @SuppressWarnings("unchecked") public Class[] parameterBindings() { return new Class[0]; diff --git a/eodsql/src/net/lemnik/eodsql/ServiceUtil.java b/eodsql/src/net/lemnik/eodsql/ServiceUtil.java index 474537f..075f2a8 100644 --- a/eodsql/src/net/lemnik/eodsql/ServiceUtil.java +++ b/eodsql/src/net/lemnik/eodsql/ServiceUtil.java @@ -23,7 +23,7 @@ class ServiceUtil { } /** - * This is the replacement of the {@link ServiceLoader#load(Class)} + * This is the replacement of the {@link java.util.ServiceLoader#load(Class)} * method. It will first attempt to invoke the {@code ServiceLoader.load} * method with reflection, if this fails this method will return * an empty {@code Iterable} object. diff --git a/eodsql/src/net/lemnik/eodsql/impl/AbstractMethodImplementation.java b/eodsql/src/net/lemnik/eodsql/impl/AbstractMethodImplementation.java index 26339e5..89b1388 100644 --- a/eodsql/src/net/lemnik/eodsql/impl/AbstractMethodImplementation.java +++ b/eodsql/src/net/lemnik/eodsql/impl/AbstractMethodImplementation.java @@ -2,8 +2,6 @@ package net.lemnik.eodsql.impl; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - import java.sql.Connection; import java.sql.SQLException; import java.sql.PreparedStatement; diff --git a/eodsql/src/net/lemnik/eodsql/impl/DefaultQueryFactory.java b/eodsql/src/net/lemnik/eodsql/impl/DefaultQueryFactory.java index a27e39b..600aa69 100644 --- a/eodsql/src/net/lemnik/eodsql/impl/DefaultQueryFactory.java +++ b/eodsql/src/net/lemnik/eodsql/impl/DefaultQueryFactory.java @@ -76,9 +76,6 @@ public class DefaultQueryFactory implements QueryFactory { return true; } - /** - * {@inheritDoc} - */ private T construct( final BaseQueryImpl.ConnectionSource connection, final Class query, diff --git a/eodsql/src/net/lemnik/eodsql/spi/util/DataIteratorWrapper.java b/eodsql/src/net/lemnik/eodsql/spi/util/DataIteratorWrapper.java index ee3f0df..bdec678 100644 --- a/eodsql/src/net/lemnik/eodsql/spi/util/DataIteratorWrapper.java +++ b/eodsql/src/net/lemnik/eodsql/spi/util/DataIteratorWrapper.java @@ -99,7 +99,6 @@ public class DataIteratorWrapper extends ResultSetWrapper> { } if(isRubberstamping(parameters)) { - @SuppressWarnings("unchecked") final DataObjectBinding binding = DataObjectBinding. getDataObjectBinding( clazz, diff --git a/eodsql/src/net/lemnik/eodsql/spi/util/DataSetWrapper.java b/eodsql/src/net/lemnik/eodsql/spi/util/DataSetWrapper.java index 1c21833..48b6f3f 100644 --- a/eodsql/src/net/lemnik/eodsql/spi/util/DataSetWrapper.java +++ b/eodsql/src/net/lemnik/eodsql/spi/util/DataSetWrapper.java @@ -244,7 +244,6 @@ public class DataSetWrapper extends ResultSetWrapper { throw new InvalidQueryException( "A disconnected DataSet may not be updatable."); } - @SuppressWarnings("unchecked") final DataObjectBinding binding = DataObjectBinding.getDataObjectBinding( clazz, diff --git a/eodsql/src/net/lemnik/eodsql/spi/util/TypeMapperDataObjectBinding.java b/eodsql/src/net/lemnik/eodsql/spi/util/TypeMapperDataObjectBinding.java index e085a22..c78d3d8 100644 --- a/eodsql/src/net/lemnik/eodsql/spi/util/TypeMapperDataObjectBinding.java +++ b/eodsql/src/net/lemnik/eodsql/spi/util/TypeMapperDataObjectBinding.java @@ -13,7 +13,6 @@ import net.lemnik.eodsql.EoDException; class TypeMapperDataObjectBinding extends DataObjectBinding { private TypeMapper mapper; - @SuppressWarnings("unchecked") TypeMapperDataObjectBinding( final TypeMapper mapper, final Class type) { diff --git a/eodsql/test/net/lemnik/eodsql/AutoGeneratedKeysTest.java b/eodsql/test/net/lemnik/eodsql/AutoGeneratedKeysTest.java index c5b12d5..c5cc666 100644 --- a/eodsql/test/net/lemnik/eodsql/AutoGeneratedKeysTest.java +++ b/eodsql/test/net/lemnik/eodsql/AutoGeneratedKeysTest.java @@ -8,7 +8,6 @@ import java.util.UUID; * @author jason */ public class AutoGeneratedKeysTest extends EoDTestCase { - private static boolean tableCreated = false; AutoGeneratedKeysQuery query = null; diff --git a/eodsql/test/net/lemnik/eodsql/Birthday.java b/eodsql/test/net/lemnik/eodsql/Birthday.java index 32a1e6a..7a18380 100644 --- a/eodsql/test/net/lemnik/eodsql/Birthday.java +++ b/eodsql/test/net/lemnik/eodsql/Birthday.java @@ -12,6 +12,7 @@ public class Birthday implements Comparable { private String who; + @SuppressWarnings("unused") private Birthday() { } diff --git a/eodsql/test/net/lemnik/eodsql/QueryTest.java b/eodsql/test/net/lemnik/eodsql/QueryTest.java index 5c2db82..61bd2b1 100644 --- a/eodsql/test/net/lemnik/eodsql/QueryTest.java +++ b/eodsql/test/net/lemnik/eodsql/QueryTest.java @@ -17,6 +17,7 @@ import net.lemnik.eodsql.spi.util.Query; */ public class QueryTest extends TestCase { + @SuppressWarnings("unused") private void myTestMethod(KeyObject object) { // here for Query.validate } diff --git a/eodsql/test/net/lemnik/eodsql/SelectPrimitiveTest.java b/eodsql/test/net/lemnik/eodsql/SelectPrimitiveTest.java index adb7425..38f456b 100644 --- a/eodsql/test/net/lemnik/eodsql/SelectPrimitiveTest.java +++ b/eodsql/test/net/lemnik/eodsql/SelectPrimitiveTest.java @@ -8,8 +8,6 @@ import java.util.Random; */ public class SelectPrimitiveTest extends EoDTestCase { - private static boolean tableCreated = false; - private Data[] allData; private int maxInt = Integer.MIN_VALUE; @@ -84,7 +82,7 @@ public class SelectPrimitiveTest extends EoDTestCase { doubleValues += allData[i].doubleValue; } - avgDouble = doubleValues / (double)allData.length; + avgDouble = doubleValues / allData.length; } private static class Data { diff --git a/eodsql/test/net/lemnik/eodsql/TransactionTest.java b/eodsql/test/net/lemnik/eodsql/TransactionTest.java index 12b596a..c98cefc 100644 --- a/eodsql/test/net/lemnik/eodsql/TransactionTest.java +++ b/eodsql/test/net/lemnik/eodsql/TransactionTest.java @@ -17,7 +17,6 @@ import java.util.UUID; * @author jason */ public class TransactionTest extends EoDTestCase { - private static boolean tableCreated = false; TransactionTestQuery query = null; @@ -25,12 +24,14 @@ public class TransactionTest extends EoDTestCase { super(testName); } + @Override protected Connection getConnection() throws ClassNotFoundException, SQLException, IOException { Connection c = super.getConnection(); c.setAutoCommit(false); return c; } + @Override protected void setUp() throws Exception { query = QueryTool.getQuery(getConnection(), TransactionTestQuery.class); -- 1.8.0