[#1887] Remove all deprecated code

This commit is contained in:
Lukas Eder 2012-10-27 21:00:54 +02:00
parent 3ae9425540
commit 857c8e6f79
6 changed files with 49 additions and 165 deletions

View File

@ -46,8 +46,7 @@ import java.util.List;
* @param <E> The array element type
* @author Lukas Eder
*/
@SuppressWarnings("deprecation")
public interface ArrayRecord<E> extends Store<E>, Iterable<E> {
public interface ArrayRecord<E> extends Attachable, Iterable<E> {
/**
* Get the contained array
@ -77,7 +76,6 @@ public interface ArrayRecord<E> extends Store<E>, Iterable<E> {
/**
* Get the size of the contained array
*/
@Override
int size();
/**

View File

@ -57,8 +57,7 @@ import org.jooq.tools.reflect.Reflect;
* @author Lukas Eder
* @see SelectQuery#getResult()
*/
@SuppressWarnings("deprecation")
public interface Record extends FieldProvider, Store<Object> {
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<Object> {
* @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<Object> {
* @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<Object> {
* might have occurred
* @see Convert#convert(Object, Class)
*/
@Override
<T> T getValue(int index, Class<? extends T> type) throws IllegalArgumentException, DataTypeException;
/**
@ -298,7 +294,6 @@ public interface Record extends FieldProvider, Store<Object> {
* might have occurred
* @see Convert#convert(Object, Class)
*/
@Override
<T> T getValue(int index, Class<? extends T> type, T defaultValue) throws IllegalArgumentException,
DataTypeException;
@ -359,7 +354,6 @@ public interface Record extends FieldProvider, Store<Object> {
/**
* Get the number of fields of this record.
*/
@Override
int size();
/**

View File

@ -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
* <p>
* <code>Store</code> implements {@link Attachable}, as some stores need a
* reference to an open JDBC connection to perform some actions on their
* elements.
*
* @param <E> 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<E> extends Attachable {
/**
* Get the size of this {@link Store}.
* <p>
* 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.
* <p>
* It can be said that <code>getValue(size() - 1)</code> will return a
* value, if <code>size &gt; 0</code>
*/
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 <code>null</code>
* @return The value of a field's index contained in this Store, or
* defaultValue, if <code>null</code>
* @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 <T> 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> T getValue(int index, Class<? extends T> type) throws IllegalArgumentException, DataTypeException;
/**
* Get a converted value from this Store, providing a field index.
*
* @param <T> The conversion type parameter
* @param index The field's index
* @param type The conversion type
* @param defaultValue The default value instead of <code>null</code>
* @return The value of a field's index contained in this Store, or
* defaultValue, if <code>null</code>
* @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> T getValue(int index, Class<? extends T> type, T defaultValue) throws IllegalArgumentException,
DataTypeException;
}

View File

@ -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<Object> implements Record {
abstract class AbstractRecord extends AbstractStore implements Record {
/**
* Generated UID
@ -188,6 +190,23 @@ abstract class AbstractRecord extends AbstractStore<Object> 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> T getValue(int index, Class<? extends T> type) {
return Convert.convert(getValue(index), type);
}
@Override
public final <T> T getValue(int index, Class<? extends T> type, T defaultValue) {
final T result = getValue(index, type);
return result == null ? defaultValue : result;
}
@Override
public final <U> U getValue(int index, Converter<?, U> converter) {
return Convert.convert(getValue(index), converter);
@ -216,8 +235,8 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
}
@Override
public final <Z> Z getValue(String fieldName, Class<? extends Z> type, Z defaultValue) {
final Z result = getValue(fieldName, type);
public final <T> T getValue(String fieldName, Class<? extends T> type, T defaultValue) {
final T result = getValue(fieldName, type);
return result == null ? defaultValue : result;
}

View File

@ -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}
* <p>
* 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<T> implements Store<T>, AttachableInternal {
abstract class AbstractStore implements AttachableInternal {
/**
* Generated UID
@ -68,6 +72,7 @@ abstract class AbstractStore<T> implements Store<T>, AttachableInternal {
// The Attachable API
// -------------------------------------------------------------------------
@SuppressWarnings("deprecation")
@Override
public final void attach(Configuration c) {
configuration = c;
@ -89,31 +94,22 @@ abstract class AbstractStore<T> implements Store<T>, 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> Z getValue(int index, Class<? extends Z> type) {
return Convert.convert(getValue(index), type);
}
@Override
public final <Z> Z getValue(int index, Class<? extends Z> 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
* <code>ArrayRecordImpl.getValue(int)</code>
*/
abstract Object getValue(int index);
@Override
public int hashCode() {
int hashCode = 1;
@ -128,8 +124,8 @@ abstract class AbstractStore<T> implements Store<T>, 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++) {

View File

@ -57,7 +57,7 @@ import org.jooq.tools.Convert;
*
* @author Lukas Eder
*/
public class ArrayRecordImpl<T> extends AbstractStore<T> implements ArrayRecord<T> {
public class ArrayRecordImpl<T> extends AbstractStore implements ArrayRecord<T> {
/**
* Generated UID
@ -113,7 +113,7 @@ public class ArrayRecordImpl<T> extends AbstractStore<T> implements ArrayRecord<
// -------------------------------------------------------------------------
@Override
public final T getValue(int index) throws IllegalArgumentException {
final T getValue(int index) {
return get()[index];
}