Merge pull request #851 from FOCONIS/fix/javawarnings

FIX some java warnings / rawtypes
This commit is contained in:
Rob Bygrave
2016-11-05 09:23:07 +13:00
committed by GitHub
40 changed files with 72 additions and 66 deletions
@@ -752,7 +752,7 @@ public interface EbeanServer {
*
* @see Query#findIds()
*/
<A> List<A> findIds(Query<?> query, Transaction transaction);
<A, T> List<A> findIds(Query<T> query, Transaction transaction);
/**
* Return a QueryIterator for the query.
@@ -1024,7 +1024,7 @@ public interface EbeanServer {
*
* @see Query#findSingleAttributeList()
*/
<A> List<A> findSingleAttributeList(Query<?> query, Transaction transaction);
<A, T> List<A> findSingleAttributeList(Query<T> query, Transaction transaction);
/**
* Execute the query returning at most one entity bean or null (if no matching
@@ -9,6 +9,7 @@ import java.util.concurrent.Future;
* It extends the java.util.concurrent.Future.
* </p>
*
* @param <T> the BeanType
* @author rbygrave
*/
public interface FutureRowCount<T> extends Future<Integer> {
@@ -7,6 +7,8 @@ import javax.persistence.PersistenceException;
*/
public class PersistenceIOException extends PersistenceException {
private static final long serialVersionUID = -7630050437148176148L;
public PersistenceIOException(String msg, Exception cause) {
super(msg, cause);
}
@@ -265,7 +265,6 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
return map.put(key, value);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void putAll(Map<? extends K, ? extends E> puts) {
checkReadOnly();
init();
@@ -2311,7 +2311,6 @@ public class ServerConfig {
* @param key properties key
* @param instance existing instance
*/
@SuppressWarnings("unchecked")
protected <T> T createInstance(PropertiesWrapper properties, Class<T> pluginType, String key, T instance) {
if (instance != null) {
@@ -2327,6 +2326,7 @@ public class ServerConfig {
* @param pluginType the type of plugin
* @param classname the implementation class as per properties
*/
@SuppressWarnings("unchecked")
protected <T> T createInstance(Class<T> pluginType, String classname) {
return classname == null ? null : (T) classLoadConfig.newInstance(classname);
}
@@ -135,9 +135,9 @@ public class DbIdentity {
return supportsSequence ? IdType.SEQUENCE : idType;
case IDENTITY:
return supportsIdentity ? IdType.IDENTITY : idType;
default:
return idType;
}
// use the default
return idType;
}
}
@@ -2,7 +2,6 @@ package com.avaje.ebean.config.dbplatform;
import com.avaje.ebean.config.ServerConfig;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
@@ -16,8 +16,8 @@ import java.io.InputStream;
*/
public class MigrationXmlReader {
private static final MigrationXmlReader INSTANCE = new MigrationXmlReader();
private MigrationXmlReader() {}
/**
* Read and return a Migration from an xml document at the given resource path.
*/
@@ -28,7 +28,7 @@ public class MigrationXmlReader {
throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]");
}
return INSTANCE.read(is);
return read(is);
}
/**
@@ -1,7 +1,6 @@
package com.avaje.ebean.event;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
/**
* Fired after a bean is constructed, but not yet loaded from database.
@@ -13,5 +13,5 @@ public interface ExtraTypeFactory {
/**
* Provide extra types to Ebean.
*/
List<? extends ScalarType> createTypes(ServerConfig config, Object objectMapper);
List<? extends ScalarType<?>> createTypes(ServerConfig config, Object objectMapper);
}
@@ -8,6 +8,8 @@ package com.avaje.ebean.text.json;
*/
public class JsonIOException extends RuntimeException {
private static final long serialVersionUID = 3062982368161342209L;
/**
* Construct with an underlying cause.
*/
@@ -145,7 +145,7 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL
* the query has finished (if executing in a background thread).
* </p>
*/
<A> List<A> findIdsWithCopy(Query<?> query, Transaction t);
<A, T> List<A> findIdsWithCopy(Query<T> query, Transaction t);
/**
* Execute the findRowCount query but without copying the query.
@@ -63,7 +63,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
this.queryTuner = new BaseQueryTuner(config, server, profileManager);
this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown();
this.skipProfileReportingOnShutdown = config.isSkipProfileReportingOnShutdown();
this.defaultGarbageCollectionWait = (long) config.getGarbageCollectionWait();
this.defaultGarbageCollectionWait = config.getGarbageCollectionWait();
}
/**
@@ -13,6 +13,8 @@ import java.io.Serializable;
*/
public class TunedQueryInfo implements Serializable {
private static final long serialVersionUID = 8661702592481810396L;
private final Origin origin;
private final OrmQueryDetail tunedDetail;
@@ -17,7 +17,7 @@ public class CacheChangeSet {
private final List<CacheChange> entries = new ArrayList<CacheChange>();
private final Set<BeanDescriptor> queryCaches = new HashSet<BeanDescriptor>();
private final Set<BeanDescriptor<?>> queryCaches = new HashSet<>();
private final Map<ManyKey, ManyChange> manyChangeMap = new HashMap<ManyKey, ManyChange>();
@@ -41,7 +41,7 @@ public class CacheChangeSet {
* Return the set of table changes to process invalidation for entities based on views.
*/
public Set<String> apply() {
for (BeanDescriptor entry : queryCaches) {
for (BeanDescriptor<?> entry : queryCaches) {
entry.queryCacheClear();
}
for (CacheChange entry : entries) {
@@ -57,7 +57,6 @@ public class CachedBeanData implements Externalizable {
}
@Override
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
version = in.readLong();
whenCreated = in.readLong();
@@ -140,7 +140,7 @@ public class DefaultBeanLoader {
}
}
SpiQuery<?> query = (SpiQuery<?>) server.createQuery(parentDesc.getBeanType());
SpiQuery<?> query = server.createQuery(parentDesc.getBeanType());
if (refresh) {
// populate a new collection
@@ -205,7 +205,7 @@ public class DefaultBeanLoader {
return;
}
SpiQuery<?> query = (SpiQuery<?>) server.createQuery(loadRequest.getBeanType());
SpiQuery<?> query = server.createQuery(loadRequest.getBeanType());
loadRequest.configureQuery(query, idList);
List<?> list = executeQuery(loadRequest, query);
@@ -273,6 +273,10 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
public int getLazyLoadBatchSize() {
return lazyLoadBatchSize;
}
public int getQueryBatchSize() {
return queryBatchSize;
}
public ServerConfig getServerConfig() {
return serverConfig;
@@ -1124,7 +1128,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try {
request.initTransIfRequired();
return (Set<T>) request.findSet();
return request.findSet();
} finally {
request.endTransIfRequired();
@@ -1143,7 +1147,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try {
request.initTransIfRequired();
return (Map<K, T>) request.findMap();
return request.findMap();
} finally {
request.endTransIfRequired();
@@ -1152,9 +1156,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
@SuppressWarnings("unchecked")
public <A> List<A> findSingleAttributeList(Query<?> query, Transaction t) {
public <A, T> List<A> findSingleAttributeList(Query<T> query, Transaction t) {
SpiOrmQueryRequest request = createQueryRequest(Type.ATTRIBUTE, query, t);
SpiOrmQueryRequest<T> request = createQueryRequest(Type.ATTRIBUTE, query, t);
Object result = request.getFromQueryCache();
if (result != null) {
return (List<A>) result;
@@ -1190,12 +1194,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
public <A> List<A> findIds(Query<?> query, Transaction t) {
public <A, T> List<A> findIds(Query<T> query, Transaction t) {
return findIdsWithCopy(((SpiQuery<?>) query).copy(), t);
return findIdsWithCopy(((SpiQuery<T>) query).copy(), t);
}
public <A> List<A> findIdsWithCopy(Query<?> query, Transaction t) {
public <A, T> List<A> findIdsWithCopy(Query<T> query, Transaction t) {
SpiOrmQueryRequest<?> request = createQueryRequest(Type.ID_LIST, query, t);
try {
@@ -71,7 +71,7 @@ public class DiffHelp {
iterator.remove();
} else if (beanProperty instanceof BeanPropertyAssocOne) {
BeanPropertyAssocOne assoc = (BeanPropertyAssocOne)beanProperty;
BeanPropertyAssocOne<?> assoc = (BeanPropertyAssocOne<?>)beanProperty;
if (!assoc.isEmbedded()) {
// flatten for assoc one beans
if (flattened == null) {
@@ -90,7 +90,7 @@ public class DiffHelp {
return values;
}
private static void flattenToId(Map<String, ValuePair> flattened, Map.Entry<String, ValuePair> entry, BeanProperty beanProperty, BeanPropertyAssocOne assoc) {
private static void flattenToId(Map<String, ValuePair> flattened, Map.Entry<String, ValuePair> entry, BeanProperty beanProperty, BeanPropertyAssocOne<?> assoc) {
BeanDescriptor<?> oneDesc = assoc.getTargetDescriptor();
@@ -968,6 +968,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
}
}
default:
break;
}
}
@@ -12,11 +12,11 @@ import java.sql.SQLException;
*/
abstract class AssocOneHelp {
protected final BeanPropertyAssocOne property;
protected final BeanPropertyAssocOne<?> property;
protected final BeanDescriptor target;
protected final BeanDescriptor<?> target;
AssocOneHelp(BeanPropertyAssocOne property) {
AssocOneHelp(BeanPropertyAssocOne<?> property) {
this.property = property;
this.target = property.targetDescriptor;
}
@@ -9,7 +9,7 @@ import java.sql.SQLException;
*/
final class AssocOneHelpEmbedded extends AssocOneHelp {
public AssocOneHelpEmbedded(BeanPropertyAssocOne property) {
public AssocOneHelpEmbedded(BeanPropertyAssocOne<?> property) {
super(property);
}
@@ -7,7 +7,7 @@ import com.avaje.ebeaninternal.server.query.SqlJoinType;
*/
class AssocOneHelpRefExported extends AssocOneHelp {
public AssocOneHelpRefExported(BeanPropertyAssocOne property) {
public AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
super(property);
}
@@ -13,7 +13,7 @@ class AssocOneHelpRefInherit extends AssocOneHelp {
private final InheritInfo inherit;
AssocOneHelpRefInherit(BeanPropertyAssocOne property) {
AssocOneHelpRefInherit(BeanPropertyAssocOne<?> property) {
super(property);
this.inherit = property.targetInheritInfo;
}
@@ -5,7 +5,7 @@ package com.avaje.ebeaninternal.server.deploy;
*/
class AssocOneHelpRefSimple extends AssocOneHelp {
AssocOneHelpRefSimple(BeanPropertyAssocOne property) {
AssocOneHelpRefSimple(BeanPropertyAssocOne<?> property) {
super(property);
}
@@ -69,6 +69,7 @@ public final class BeanDescriptorDraftHelp<T> {
* This will recursive transfer values to all @DraftableElement properties.
* </p>
*/
@SuppressWarnings("unchecked")
public T publish(T draftBean, T liveBean) {
if (liveBean == null) {
@@ -645,6 +645,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
/**
* Return the bean deploy info for the given class.
*/
@SuppressWarnings("unchecked")
public <T> DeployBeanInfo<T> getDeploy(Class<T> cls) {
return (DeployBeanInfo<T>) deployInfoMap.get(cls);
}
@@ -92,16 +92,14 @@ public final class BeanMapHelp<T> implements BeanCollectionHelp<T> {
}
@Override
@SuppressWarnings("unchecked")
public BeanCollection<T> createEmptyNoParent() {
return new BeanMap();
return new BeanMap<>();
}
@Override
@SuppressWarnings("unchecked")
public BeanCollection<T> createEmpty(EntityBean ownerBean) {
BeanMap beanMap = new BeanMap(loader, ownerBean, propertyName);
BeanMap<?,T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
if (many != null) {
beanMap.setModifyListening(many.getModifyListenMode());
}
@@ -1032,6 +1032,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
}
}
@SuppressWarnings("unchecked")
private Map<Object,T> liveBeansAsMap(BeanCollection<?> liveVal) {
liveVal.size();
@@ -125,10 +125,8 @@ public class BeanPropertyCompound extends BeanProperty {
* Read the data from the resultSet effectively ignoring it and returning
* null.
*/
@SuppressWarnings("unchecked")
@Override
public Object read(DbReadContext ctx) throws SQLException {
return compoundType.read(ctx.getDataReader());
}
@@ -23,12 +23,10 @@ public class BeanPropertyCompoundScalar extends BeanProperty {
/**
* Return one of the scalar values from a compound type.
*/
@SuppressWarnings("unchecked")
public Object getValueObject(Object compoundValue) {
return ctProperty.getValue(compoundValue);
}
@SuppressWarnings("unchecked")
@Override
public Object getValue(EntityBean valueObject) {
return ctProperty.getValue(valueObject);
@@ -39,7 +37,6 @@ public class BeanPropertyCompoundScalar extends BeanProperty {
setValueInCompound(bean, value, false);
}
@SuppressWarnings("unchecked")
public void setValueInCompound(EntityBean bean, Object value, boolean intercept) {
Object compoundValue = ctProperty.setValue(bean, value);
@@ -70,9 +70,8 @@ public final class BeanSetHelp<T> implements BeanCollectionHelp<T> {
}
@Override
@SuppressWarnings("unchecked")
public BeanCollection<T> createEmptyNoParent() {
return new BeanSet();
return new BeanSet<>();
}
@Override
@@ -244,6 +244,7 @@ public final class IdBinderEmbedded implements IdBinder {
/**
* Convert back from a Map to embedded bean.
*/
@SuppressWarnings("unchecked")
public Object convertIdFromJson(Object value) {
Map<String,Object> map = (Map<String, Object>)value;
@@ -291,7 +291,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
String propName = SplitName.add(prefix, beanProperty.getName());
if (beanProperty.isScalar()) {
if (value instanceof String) {
list.add(new LikeExpression(propName, (String) value, caseInsensitive, likeType));
list.add(new LikeExpression(propName, value, caseInsensitive, likeType));
} else {
// exclude the zero values typically to weed out
// primitive int and long that initialise to 0
@@ -301,8 +301,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
}
} else if ((beanProperty instanceof BeanPropertyAssocOne) && (value instanceof EntityBean)) {
BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) beanProperty;
BeanDescriptor targetDescriptor = assocOne.getTargetDescriptor();
BeanPropertyAssocOne<?> assocOne = (BeanPropertyAssocOne<?>) beanProperty;
BeanDescriptor<?> targetDescriptor = assocOne.getTargetDescriptor();
addExpressions(list, targetDescriptor, (EntityBean) value, propName);
}
}
@@ -35,7 +35,7 @@ class NamedParamHelp {
Object value = value(sourceValue);
if (value instanceof Collection) {
values.addAll((Collection)value);
values.addAll((Collection<?>)value);
} else {
values.add(value);
}
@@ -8,9 +8,9 @@ import java.util.List;
class EqlAdapterHelper {
private final EqlAdapter owner;
private final EqlAdapter<?> owner;
public EqlAdapterHelper(EqlAdapter owner) {
public EqlAdapterHelper(EqlAdapter<?> owner) {
this.owner = owner;
}
@@ -49,7 +49,6 @@ class EqlAdapterHelper {
peekExprList().between(path, bind(value1), bind(value2));
}
@SuppressWarnings("unchecked")
protected void addIn(String path, List<Object> inValues) {
peekExprList().in(path, inValues);
}
@@ -117,7 +116,7 @@ class EqlAdapterHelper {
return getBindValue(valueType, value);
}
private ExpressionList peekExprList() {
private ExpressionList<?> peekExprList() {
return owner.peekExprList();
}
@@ -15,27 +15,27 @@ interface ArrayElementConverter<T> {
/**
* The UUID converter implementation.
*/
ArrayElementConverter UUID = new UuidConverter();
ArrayElementConverter<UUID> UUID = new UuidConverter();
/**
* The String converter implementation.
*/
ArrayElementConverter STRING = new StringConverter();
ArrayElementConverter<String> STRING = new StringConverter();
/**
* The Long converter implementation.
*/
ArrayElementConverter LONG = new LongConverter();
ArrayElementConverter<Long> LONG = new LongConverter();
/**
* The Integer converter implementation.
*/
ArrayElementConverter INTEGER = new IntegerConverter();
ArrayElementConverter<Integer> INTEGER = new IntegerConverter();
/**
* The Double converter implementation.
*/
ArrayElementConverter DOUBLE = new DoubleConverter();
ArrayElementConverter<Double> DOUBLE = new DoubleConverter();
class LongConverter implements ArrayElementConverter<Long> {
@@ -87,6 +87,7 @@ interface ArrayElementConverter<T> {
class NoopConverter<T> implements ArrayElementConverter<T> {
@SuppressWarnings("unchecked")
@Override
public T toElement(Object rawValue) {
return (T) rawValue;
@@ -25,16 +25,15 @@ public class BeanCollectionFactory {
/**
* Create a BeanCollection for the given parameters.
*/
@SuppressWarnings("unchecked")
public static BeanCollection<?> create(SpiQuery.Type manyType) {
switch (manyType) {
case MAP:
return new BeanMap(new LinkedHashMap(defaultMapInitialCapacity));
return new BeanMap<>(new LinkedHashMap<>(defaultMapInitialCapacity));
case LIST:
return new BeanList(new ArrayList(defaultListInitialCapacity));
return new BeanList<>(new ArrayList<>(defaultListInitialCapacity));
case SET:
return new BeanSet(new LinkedHashSet(defaultSetInitialCapacity));
return new BeanSet<>(new LinkedHashSet<>(defaultSetInitialCapacity));
default:
throw new RuntimeException("Invalid Arg " + manyType);
@@ -5,6 +5,8 @@ package com.avaje.ebeanservice.docstore.api;
*/
public class DocumentNotFoundException extends RuntimeException {
private static final long serialVersionUID = 2066138180892685276L;
/**
* Construct with a message.
*/
@@ -186,7 +186,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
}
@Override
public <A> List<A> findIdsWithCopy(Query<?> query, Transaction t) {
public <A, T> List<A> findIdsWithCopy(Query<T> query, Transaction t) {
return null;
}
@@ -461,7 +461,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
}
@Override
public <A> List<A> findIds(Query<?> query, Transaction transaction) {
public <A, T> List<A> findIds(Query<T> query, Transaction transaction) {
return null;
}
@@ -516,7 +516,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
}
@Override
public <A> List<A> findSingleAttributeList(Query<?> query, Transaction transaction) {
public <A, T> List<A> findSingleAttributeList(Query<T> query, Transaction transaction) {
return null;
}