From 857c8e6f790c8190eb4bdc69401da42436ce9f58 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sat, 27 Oct 2012 21:00:54 +0200 Subject: [PATCH] [#1887] Remove all deprecated code --- jOOQ/src/main/java/org/jooq/ArrayRecord.java | 4 +- jOOQ/src/main/java/org/jooq/Record.java | 8 +- jOOQ/src/main/java/org/jooq/Store.java | 123 ------------------ .../java/org/jooq/impl/AbstractRecord.java | 25 +++- .../java/org/jooq/impl/AbstractStore.java | 50 ++++--- .../java/org/jooq/impl/ArrayRecordImpl.java | 4 +- 6 files changed, 49 insertions(+), 165 deletions(-) delete mode 100644 jOOQ/src/main/java/org/jooq/Store.java diff --git a/jOOQ/src/main/java/org/jooq/ArrayRecord.java b/jOOQ/src/main/java/org/jooq/ArrayRecord.java index d05bcd5b72..f2ca2cac1a 100644 --- a/jOOQ/src/main/java/org/jooq/ArrayRecord.java +++ b/jOOQ/src/main/java/org/jooq/ArrayRecord.java @@ -46,8 +46,7 @@ import java.util.List; * @param The array element type * @author Lukas Eder */ -@SuppressWarnings("deprecation") -public interface ArrayRecord extends Store, Iterable { +public interface ArrayRecord extends Attachable, Iterable { /** * Get the contained array @@ -77,7 +76,6 @@ public interface ArrayRecord extends Store, Iterable { /** * Get the size of the contained array */ - @Override int size(); /** diff --git a/jOOQ/src/main/java/org/jooq/Record.java b/jOOQ/src/main/java/org/jooq/Record.java index 6a675f526b..b9131444f6 100644 --- a/jOOQ/src/main/java/org/jooq/Record.java +++ b/jOOQ/src/main/java/org/jooq/Record.java @@ -57,8 +57,7 @@ import org.jooq.tools.reflect.Reflect; * @author Lukas Eder * @see SelectQuery#getResult() */ -@SuppressWarnings("deprecation") -public interface Record extends FieldProvider, Store { +public interface Record extends FieldProvider, Attachable { /** * Get a value from this Record, providing a field. @@ -251,7 +250,6 @@ public interface Record extends FieldProvider, Store { * @throws IllegalArgumentException If the argument index is not contained * in the record */ - @Override Object getValue(int index) throws IllegalArgumentException; /** @@ -264,7 +262,6 @@ public interface Record extends FieldProvider, Store { * @throws IllegalArgumentException If the argument index is not contained * in the record */ - @Override Object getValue(int index, Object defaultValue) throws IllegalArgumentException; /** @@ -280,7 +277,6 @@ public interface Record extends FieldProvider, Store { * might have occurred * @see Convert#convert(Object, Class) */ - @Override T getValue(int index, Class type) throws IllegalArgumentException, DataTypeException; /** @@ -298,7 +294,6 @@ public interface Record extends FieldProvider, Store { * might have occurred * @see Convert#convert(Object, Class) */ - @Override T getValue(int index, Class type, T defaultValue) throws IllegalArgumentException, DataTypeException; @@ -359,7 +354,6 @@ public interface Record extends FieldProvider, Store { /** * Get the number of fields of this record. */ - @Override int size(); /** diff --git a/jOOQ/src/main/java/org/jooq/Store.java b/jOOQ/src/main/java/org/jooq/Store.java deleted file mode 100644 index 91159f0cfe..0000000000 --- a/jOOQ/src/main/java/org/jooq/Store.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com - * All rights reserved. - * - * This software is licensed to you under the Apache License, Version 2.0 - * (the "License"); You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name "jOOQ" nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.jooq; - -import org.jooq.exception.DataTypeException; -import org.jooq.tools.Convert; - -/** - * A common base type for {@link Record} and {@link ArrayRecord} providing - * common, index-based functionality for storage objects - *

- * Store implements {@link Attachable}, as some stores need a - * reference to an open JDBC connection to perform some actions on their - * elements. - * - * @param The store's element type - * @author Lukas Eder - * @deprecated - 2.6.0 [#1840] - This type provides no useful abstraction over - * {@link Record} and {@link ArrayRecord} and will be removed in the - * future. Do not reference it directly. - */ -@Deprecated -public interface Store extends Attachable { - - /** - * Get the size of this {@link Store}. - *

- * If this is an {@link ArrayRecord}, then the array size is returned. If - * this is a {@link Record}, then the number of fields is returned. - *

- * It can be said that getValue(size() - 1) will return a - * value, if size > 0 - */ - int size(); - - /** - * Get a value from this Store, providing a field index. - * - * @param index The field's index - * @return The value of a field's index contained in this Store - * @throws IllegalArgumentException If the argument index is not contained - * in the Store - */ - E getValue(int index) throws IllegalArgumentException; - - /** - * Get a value from this Store, providing a field index. - * - * @param index The field's index - * @param defaultValue The default value instead of null - * @return The value of a field's index contained in this Store, or - * defaultValue, if null - * @throws IllegalArgumentException If the argument index is not contained - * in the Store - */ - E getValue(int index, E defaultValue) throws IllegalArgumentException; - - /** - * Get a converted value from this Store, providing a field index. - * - * @param The conversion type parameter - * @param index The field's index - * @param type The conversion type - * @return The value of a field's index contained in this Store - * @throws IllegalArgumentException If the argument index is not contained - * in the Store - * @throws DataTypeException wrapping data type conversion exception that - * might have occurred - * @see Convert#convert(Object, Class) - */ - T getValue(int index, Class type) throws IllegalArgumentException, DataTypeException; - - /** - * Get a converted value from this Store, providing a field index. - * - * @param The conversion type parameter - * @param index The field's index - * @param type The conversion type - * @param defaultValue The default value instead of null - * @return The value of a field's index contained in this Store, or - * defaultValue, if null - * @throws IllegalArgumentException If the argument index is not contained - * in the Store - * @throws DataTypeException wrapping data type conversion exception that - * might have occurred - * @see Convert#convert(Object, Class) - */ - T getValue(int index, Class type, T defaultValue) throws IllegalArgumentException, - DataTypeException; -} diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java index 698d7a524d..2fbf26bc88 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java @@ -73,9 +73,11 @@ import org.jooq.tools.Convert; import org.jooq.tools.reflect.Reflect; /** + * A general base class for all {@link Record} types + * * @author Lukas Eder */ -abstract class AbstractRecord extends AbstractStore implements Record { +abstract class AbstractRecord extends AbstractStore implements Record { /** * Generated UID @@ -188,6 +190,23 @@ abstract class AbstractRecord extends AbstractStore implements Record { return getValue0(index).getValue(); } + @Override + public final Object getValue(int index, Object defaultValue) { + final Object result = getValue(index); + return result == null ? defaultValue : result; + } + + @Override + public final T getValue(int index, Class type) { + return Convert.convert(getValue(index), type); + } + + @Override + public final T getValue(int index, Class type, T defaultValue) { + final T result = getValue(index, type); + return result == null ? defaultValue : result; + } + @Override public final U getValue(int index, Converter converter) { return Convert.convert(getValue(index), converter); @@ -216,8 +235,8 @@ abstract class AbstractRecord extends AbstractStore implements Record { } @Override - public final Z getValue(String fieldName, Class type, Z defaultValue) { - final Z result = getValue(fieldName, type); + public final T getValue(String fieldName, Class type, T defaultValue) { + final T result = getValue(fieldName, type); return result == null ? defaultValue : result; } diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java b/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java index 85641a0c79..83ffcfc962 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java @@ -37,17 +37,21 @@ package org.jooq.impl; import java.util.Arrays; +import org.jooq.ArrayRecord; import org.jooq.Attachable; import org.jooq.AttachableInternal; import org.jooq.Configuration; -import org.jooq.Store; -import org.jooq.tools.Convert; +import org.jooq.Record; /** + * A common base class for {@link Record} and {@link ArrayRecord} + *

+ * This base class takes care of implementing similar {@link Attachable} and + * {@link Object#equals(Object)}, {@link Object#hashCode()} behaviour. + * * @author Lukas Eder */ -@SuppressWarnings("deprecation") -abstract class AbstractStore implements Store, AttachableInternal { +abstract class AbstractStore implements AttachableInternal { /** * Generated UID @@ -68,6 +72,7 @@ abstract class AbstractStore implements Store, AttachableInternal { // The Attachable API // ------------------------------------------------------------------------- + @SuppressWarnings("deprecation") @Override public final void attach(Configuration c) { configuration = c; @@ -89,31 +94,22 @@ abstract class AbstractStore implements Store, AttachableInternal { return new Executor(getConfiguration()); } - // ------------------------------------------------------------------------- - // The Store API - // ------------------------------------------------------------------------- - - @Override - public final T getValue(int index, T defaultValue) { - final T result = getValue(index); - return result == null ? defaultValue : result; - } - - @Override - public final Z getValue(int index, Class type) { - return Convert.convert(getValue(index), type); - } - - @Override - public final Z getValue(int index, Class type, Z defaultValue) { - final Z result = getValue(index, type); - return result == null ? defaultValue : result; - } - // ------------------------------------------------------------------------- // equals and hashCode // ------------------------------------------------------------------------- + /** + * This method coincides with {@link Record#size()} and + * {@link ArrayRecord#size()} + */ + abstract int size(); + + /** + * This method coincides with {@link Record#getValue(int)} and + * ArrayRecordImpl.getValue(int) + */ + abstract Object getValue(int index); + @Override public int hashCode() { int hashCode = 1; @@ -128,8 +124,8 @@ abstract class AbstractStore implements Store, AttachableInternal { @Override public boolean equals(Object obj) { - if (obj instanceof Store) { - final Store that = (Store) obj; + if (obj instanceof AbstractStore) { + final AbstractStore that = (AbstractStore) obj; if (size() == that.size()) { for (int i = 0; i < size(); i++) { diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java b/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java index 078b566844..d8dfc14f4d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java @@ -57,7 +57,7 @@ import org.jooq.tools.Convert; * * @author Lukas Eder */ -public class ArrayRecordImpl extends AbstractStore implements ArrayRecord { +public class ArrayRecordImpl extends AbstractStore implements ArrayRecord { /** * Generated UID @@ -113,7 +113,7 @@ public class ArrayRecordImpl extends AbstractStore implements ArrayRecord< // ------------------------------------------------------------------------- @Override - public final T getValue(int index) throws IllegalArgumentException { + final T getValue(int index) { return get()[index]; }