Permalink
Browse files

Generics

  • Loading branch information...
1 parent b01c8a8 commit 38c89eb3422af16b141957d4c15505ceea857cf3 @philwebb committed Mar 1, 2012
View
6 spring-binding/src/main/java/org/springframework/binding/convert/converters/Converter.java
@@ -31,14 +31,14 @@
* convert specific subclasses as well.
* @return the source type
*/
- public Class getSourceClass();
+ public Class<?> getSourceClass();
/**
* The target class this converter can convert to. May be an interface or abstract type to allow this converter to
* convert specific subclasses as well.
* @return the target type
*/
- public Class getTargetClass();
+ public Class<?> getTargetClass();
/**
* Convert the provided source object argument to an instance of the specified target class.
@@ -48,6 +48,6 @@
* @return the converted object, which must be an instance of the <code>targetClass</code>
* @throws Exception an exception occurred performing the conversion
*/
- public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception;
+ public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception;
}
View
12 ...nding/src/main/java/org/springframework/binding/expression/el/MapAdaptableELResolver.java
@@ -15,6 +15,7 @@
*/
package org.springframework.binding.expression.el;
+import java.beans.FeatureDescriptor;
import java.util.Iterator;
import java.util.Map;
@@ -32,18 +33,18 @@
*/
public class MapAdaptableELResolver extends ELResolver {
- public Class getCommonPropertyType(ELContext context, Object base) {
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
if (base instanceof MapAdaptable) {
return Object.class;
}
return null;
}
- public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
return null;
}
- public Class getType(ELContext context, Object base, Object property) throws NullPointerException,
+ public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException,
PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException("The ELContext is null.");
@@ -102,8 +103,9 @@ public void setValue(ELContext context, Object base, Object property, Object val
}
}
- private Map adapt(Object base) {
- MapAdaptable adaptable = (MapAdaptable) base;
+ @SuppressWarnings("unchecked")
+ private Map<Object, Object> adapt(Object base) {
+ MapAdaptable<Object, Object> adaptable = (MapAdaptable<Object, Object>) base;
return adaptable.asMap();
}
View
24 spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpression.java
@@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import ognl.NoSuchPropertyException;
import ognl.Ognl;
@@ -46,9 +47,9 @@
private Object expression;
- private Map variableExpressions;
+ private Map<String, Expression> variableExpressions;
- private Class expectedResultType;
+ private Class<?> expectedResultType;
private String expressionString;
@@ -57,7 +58,7 @@
/**
* Creates a new OGNL expression.
*/
- public OgnlExpression(Object expression, Map variableExpressions, Class expectedResultType,
+ public OgnlExpression(Object expression, Map<String, Expression> variableExpressions, Class<?> expectedResultType,
String expressionString, ConversionService conversionService) {
this.expression = expression;
this.variableExpressions = variableExpressions;
@@ -78,6 +79,7 @@ public int hashCode() {
return expressionString.hashCode();
}
+ @SuppressWarnings("rawtypes")
public Object getValue(Object context) throws EvaluationException {
try {
Map evaluationContext = Ognl.addDefaultContext(context, getVariables(context));
@@ -96,6 +98,7 @@ public Object getValue(Object context) throws EvaluationException {
}
}
+ @SuppressWarnings("rawtypes")
public void setValue(Object context, Object value) {
try {
Map evaluationContext = Ognl.addDefaultContext(context, getVariables(context));
@@ -114,7 +117,7 @@ public void setValue(Object context, Object value) {
}
}
- public Class getValueType(Object context) {
+ public Class<?> getValueType(Object context) {
try {
// OGNL has no native way to get this information
return new BeanWrapperImpl(context).getPropertyType(expressionString);
@@ -148,6 +151,7 @@ private Throwable causeFor(OgnlException e) {
}
}
+ @SuppressWarnings("rawtypes")
private TypeConverter createTypeConverter() {
return new TypeConverter() {
public Object convertValue(Map context, Object target, Member member, String propertyName, Object value,
@@ -161,14 +165,14 @@ public Object convertValue(Map context, Object target, Member member, String pro
};
}
- private Map getVariables(Object context) {
+ private Map<String, Object> getVariables(Object context) {
if (variableExpressions == null) {
- return Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
- Map variables = new HashMap(variableExpressions.size(), 1);
- for (Iterator it = variableExpressions.entrySet().iterator(); it.hasNext();) {
- Map.Entry var = (Map.Entry) it.next();
- Expression valueExpression = (Expression) var.getValue();
+ Map<String, Object> variables = new HashMap<String, Object>(variableExpressions.size(), 1);
+ for (Iterator<Map.Entry<String, Expression>> it = variableExpressions.entrySet().iterator(); it.hasNext();) {
+ Entry<String, Expression> var = it.next();
+ Expression valueExpression = var.getValue();
variables.put(var.getKey(), valueExpression.getValue(context));
}
return variables;
View
8 ...nding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpressionParser.java
@@ -57,15 +57,15 @@ public void setConversionService(ConversionService conversionService) {
* @param clazz the class that contains properties needing access
* @param propertyAccessor the property access strategy
*/
- public void addPropertyAccessor(Class clazz, PropertyAccessor propertyAccessor) {
+ public void addPropertyAccessor(Class<?> clazz, PropertyAccessor propertyAccessor) {
OgnlRuntime.setPropertyAccessor(clazz, propertyAccessor);
}
protected Expression doParseExpression(String expressionString, ParserContext context) throws ParserException {
try {
- return new OgnlExpression(Ognl.parseExpression(expressionString), parseVariableExpressions(context
- .getExpressionVariables()), context.getExpectedEvaluationResultType(), expressionString,
- conversionService);
+ return new OgnlExpression(Ognl.parseExpression(expressionString),
+ parseVariableExpressions(context.getExpressionVariables()),
+ context.getExpectedEvaluationResultType(), expressionString, conversionService);
} catch (OgnlException e) {
throw new ParserException(expressionString, e);
}
View
3 .../main/java/org/springframework/binding/expression/support/CollectionAddingExpression.java
@@ -46,6 +46,7 @@ public Object getValue(Object context) throws EvaluationException {
return collectionExpression.getValue(context);
}
+ @SuppressWarnings("unchecked")
public void setValue(Object context, Object value) throws EvaluationException {
Object result = getValue(context);
if (result == null) {
@@ -57,7 +58,7 @@ public void setValue(Object context, Object value) throws EvaluationException {
Assert.isInstanceOf(Collection.class, result, "Not a collection: ");
if (value != null) {
// add the value to the collection
- ((Collection) result).add(value);
+ ((Collection<Object>) result).add(value);
}
}
View
24 spring-faces/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Fri May 14 17:56:46 BST 2010
+#Sat Jan 28 13:20:21 PST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -19,18 +19,22 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
@@ -42,42 +46,58 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
View
10 spring-faces/src/main/java/org/springframework/faces/model/converter/DataModelConverter.java
@@ -32,20 +32,20 @@
*/
public class DataModelConverter implements Converter {
- public Class getSourceClass() {
+ public Class<?> getSourceClass() {
return List.class;
}
- public Class getTargetClass() {
+ public Class<?> getTargetClass() {
return DataModel.class;
}
- public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception {
+ public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
if (targetClass.equals(DataModel.class)) {
targetClass = OneSelectionTrackingListDataModel.class;
}
- Constructor emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {});
- DataModel model = (DataModel) emptyConstructor.newInstance(new Object[] {});
+ Constructor<?> emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {});
+ DataModel<?> model = (DataModel<?>) emptyConstructor.newInstance(new Object[] {});
model.setWrappedData(source);
return model;
}
View
7 spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java
@@ -25,7 +25,6 @@
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
import javax.faces.event.PhaseId;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.lifecycle.LifecycleFactory;
@@ -97,12 +96,6 @@ private void populateRequestMap(FacesContext facesContext, Map<String, Object> m
}
}
- private FacesContext createFacesContext(HttpServletRequest request, HttpServletResponse response) {
- FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- return facesContextFactory.getFacesContext(getServletContext(), request, response, facesLifecycle);
- }
-
private Lifecycle createFacesLifecycle() {
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
View
1 spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java
@@ -24,7 +24,6 @@
* component with enhanced client-side behavior.
*
* @author Jeremy Grelle
- *
*/
public abstract class DojoWidget extends SpringJavascriptElementDecoration {
View
1 spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java
@@ -31,7 +31,6 @@
* type conversion.
*
* @author Jeremy Grelle
- *
*/
public class ProgressiveUICommand extends UICommand {
View
1 spring-faces/src/main/java/org/springframework/faces/ui/ResourceRenderer.java
@@ -33,7 +33,6 @@
* </p>
*
* @author Jeremy Grelle
- *
*/
public class ResourceRenderer extends Renderer {
View
5 spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java
@@ -17,6 +17,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -205,4 +206,8 @@ private static boolean alreadyRendered(FacesContext facesContext, String scriptP
return renderedResources != null && renderedResources.contains(scriptPath);
}
+ private <T extends Collection<E>, E> T getStringCollectionFromRequestMap(FacesContext facesContext, String key,
+ Class<T> collectionClass, Class<E> elementClass) {
+ return (T) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY);
+ }
}
View
8 ...aces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java
@@ -48,9 +48,9 @@
/**
* Mappings between {@link FacesMessage} and {@link Severity}.
*/
- private static final Map FACESSEVERITY_TO_SPRINGSEVERITY;
+ private static final Map<FacesMessage.Severity, Severity> FACESSEVERITY_TO_SPRINGSEVERITY;
static {
- FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap();
+ FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap<FacesMessage.Severity, Severity>();
FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_INFO, Severity.INFO);
FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_WARN, Severity.WARNING);
FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_ERROR, Severity.ERROR);
@@ -336,7 +336,7 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO
String detail = (String) ois.readObject();
int severityOrdinal = ois.readInt();
FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO;
- for (Iterator iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
+ for (Iterator<?> iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) {
FacesMessage.Severity value = (FacesMessage.Severity) iterator.next();
if (value.getOrdinal() == severityOrdinal) {
severity = value;
@@ -381,7 +381,7 @@ public String getText() {
public Severity getSeverity() {
Severity severity = null;
if (facesMessage.getSeverity() != null) {
- severity = (Severity) FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity());
+ severity = FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity());
}
return (severity == null ? Severity.INFO : severity);
}
View
2 spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java
@@ -62,7 +62,7 @@ public static Lifecycle newInstance() {
public void execute(FacesContext context) throws FacesException {
logger.debug("Executing view post back lifecycle");
for (int p = PhaseId.APPLY_REQUEST_VALUES.getOrdinal(); p <= PhaseId.INVOKE_APPLICATION.getOrdinal(); p++) {
- PhaseId phaseId = (PhaseId) PhaseId.VALUES.get(p);
+ PhaseId phaseId = PhaseId.VALUES.get(p);
if (!skipPhase(context, phaseId)) {
if (isAtLeastJsf20()) {
context.setCurrentPhaseId(phaseId);

0 comments on commit 38c89eb

Please sign in to comment.