Polish
Remove: - auto-boxing - unnecessary array creation - public keyword on interface methods - unnecessary throws clauses Use lambda expressions
This commit is contained in:
@@ -32,6 +32,6 @@ public interface MapAdaptable<K, V> {
|
||||
* calculated) be cached as appropriate.
|
||||
* @return the object's contents as a map
|
||||
*/
|
||||
public Map<K, V> asMap();
|
||||
Map<K, V> asMap();
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,5 @@ public interface SharedMap<K, V> extends Map<K, V> {
|
||||
*
|
||||
* @return the mutex
|
||||
*/
|
||||
public Object getMutex();
|
||||
}
|
||||
Object getMutex();
|
||||
}
|
||||
|
||||
@@ -28,18 +28,18 @@ public interface ConversionExecutor {
|
||||
* Returns the source class of conversions performed by this executor.
|
||||
* @return the source class
|
||||
*/
|
||||
public Class<?> getSourceClass();
|
||||
Class<?> getSourceClass();
|
||||
|
||||
/**
|
||||
* Returns the target class of conversions performed by this executor.
|
||||
* @return the target class
|
||||
*/
|
||||
public Class<?> getTargetClass();
|
||||
Class<?> getTargetClass();
|
||||
|
||||
/**
|
||||
* Execute the conversion for the provided source object.
|
||||
* @param source the source object to convert
|
||||
*/
|
||||
public Object execute(Object source) throws ConversionExecutionException;
|
||||
Object execute(Object source) throws ConversionExecutionException;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface ConversionService {
|
||||
* @return the converted object, an instance of the <code>targetClass</code>
|
||||
* @throws ConversionException if an exception occurred during the conversion process
|
||||
*/
|
||||
public Object executeConversion(Object source, Class<?> targetClass) throws ConversionException;
|
||||
Object executeConversion(Object source, Class<?> targetClass) throws ConversionException;
|
||||
|
||||
/**
|
||||
* Execute a conversion using the custom converter with the provided id.
|
||||
@@ -43,7 +43,7 @@ public interface ConversionService {
|
||||
* @return the converted object, an instance of the <code>targetClass</code>
|
||||
* @throws ConversionException if an exception occurred during the conversion process
|
||||
*/
|
||||
public Object executeConversion(String converterId, Object source, Class<?> targetClass);
|
||||
Object executeConversion(String converterId, Object source, Class<?> targetClass);
|
||||
|
||||
/**
|
||||
* Return the default conversion executor capable of converting source objects of the specified
|
||||
@@ -55,7 +55,7 @@ public interface ConversionService {
|
||||
* @return the executor that can execute instance type conversion, never null
|
||||
* @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found
|
||||
*/
|
||||
public ConversionExecutor getConversionExecutor(Class<?> sourceClass, Class<?> targetClass)
|
||||
ConversionExecutor getConversionExecutor(Class<?> sourceClass, Class<?> targetClass)
|
||||
throws ConversionExecutorNotFoundException;
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ public interface ConversionService {
|
||||
* @return the executor that can execute instance type conversion, never null
|
||||
* @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found
|
||||
*/
|
||||
public ConversionExecutor getConversionExecutor(String id, Class<?> sourceClass, Class<?> targetClass)
|
||||
ConversionExecutor getConversionExecutor(String id, Class<?> sourceClass, Class<?> targetClass)
|
||||
throws ConversionExecutorNotFoundException;
|
||||
|
||||
/**
|
||||
@@ -77,13 +77,13 @@ public interface ConversionService {
|
||||
* @param alias the class alias
|
||||
* @return the class, or <code>null</code> if no alias exists
|
||||
*/
|
||||
public Class<?> getClassForAlias(String alias);
|
||||
Class<?> getClassForAlias(String alias);
|
||||
|
||||
/**
|
||||
* Return the underlying Spring ConversionService.
|
||||
*
|
||||
* @return the conversion service
|
||||
*/
|
||||
public org.springframework.core.convert.ConversionService getDelegateConversionService();
|
||||
org.springframework.core.convert.ConversionService getDelegateConversionService();
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ArrayToArray implements Converter {
|
||||
return Object[].class;
|
||||
}
|
||||
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ArrayToCollection implements TwoWayConverter {
|
||||
return collection;
|
||||
}
|
||||
|
||||
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) throws Exception {
|
||||
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) {
|
||||
if (target == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CollectionToCollection implements Converter {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ public interface Converter {
|
||||
* convert specific subclasses as well.
|
||||
* @return the source type
|
||||
*/
|
||||
public Class<?> getSourceClass();
|
||||
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();
|
||||
Class<?> getTargetClass();
|
||||
|
||||
/**
|
||||
* Convert the provided source object argument to an instance of the specified target class.
|
||||
@@ -48,6 +48,6 @@ public interface Converter {
|
||||
* @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;
|
||||
Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class FormattedStringToNumber extends StringToObject {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
ParsePosition parsePosition = new ParsePosition(0);
|
||||
NumberFormat format = numberFormatFactory.getNumberFormat();
|
||||
Number number = format.parse(string, parsePosition);
|
||||
@@ -102,7 +102,7 @@ public class FormattedStringToNumber extends StringToObject {
|
||||
return convertToNumberClass(number, (Class<? extends Number>) targetClass);
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
Number number = (Number) object;
|
||||
return numberFormatFactory.getNumberFormat().format(number);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class NumberToNumber implements Converter {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
return NumberUtils.convertNumberToTargetClass((Number) source, (Class<? extends Number>) targetClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ObjectToArray implements Converter {
|
||||
return Object[].class;
|
||||
}
|
||||
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ObjectToCollection implements Converter {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ public class PropertyEditorConverter extends StringToObject {
|
||||
this.propertyEditor = propertyEditor;
|
||||
}
|
||||
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
synchronized (propertyEditor) {
|
||||
propertyEditor.setAsText(string);
|
||||
return propertyEditor.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
synchronized (propertyEditor) {
|
||||
propertyEditor.setValue(object);
|
||||
return propertyEditor.getAsText();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SpringConvertingConverterAdapter implements Converter {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
return conversionService.convert(source, targetClass);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class StringToBigDecimal extends StringToObject {
|
||||
return new BigDecimal(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
BigDecimal number = (BigDecimal) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ public class StringToBigInteger extends StringToObject {
|
||||
super(BigInteger.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return new BigInteger(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
BigInteger number = (BigInteger) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class StringToBoolean extends StringToObject {
|
||||
this.falseString = falseString;
|
||||
}
|
||||
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
if (trueString != null && string.equals(trueString)) {
|
||||
return true;
|
||||
} else if (falseString != null && string.equals(falseString)) {
|
||||
@@ -62,7 +62,7 @@ public class StringToBoolean extends StringToObject {
|
||||
}
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
Boolean value = (Boolean) object;
|
||||
if (Boolean.TRUE.equals(value)) {
|
||||
if (trueString != null) {
|
||||
|
||||
@@ -26,11 +26,11 @@ public class StringToByte extends StringToObject {
|
||||
super(Byte.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return Byte.valueOf(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Byte number = (Byte) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ public class StringToCharacter extends StringToObject {
|
||||
super(Character.class);
|
||||
}
|
||||
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
return new Character(string.charAt(0));
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
Character character = (Character) object;
|
||||
return character.toString();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class StringToClass extends StringToObject {
|
||||
return ClassUtils.forName(string, classLoader);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Class<?> clazz = (Class<?>) object;
|
||||
return clazz.getName();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class StringToDate extends StringToObject {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> targetClass) {
|
||||
if (!StringUtils.hasText(string)) {
|
||||
return null;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class StringToDate extends StringToObject {
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(Object target) throws Exception {
|
||||
public String toString(Object target) {
|
||||
Date date = (Date) target;
|
||||
if (date == null) {
|
||||
return "";
|
||||
|
||||
@@ -26,11 +26,11 @@ public class StringToDouble extends StringToObject {
|
||||
super(Double.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return Double.valueOf(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Double number = (Double) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ public class StringToEnum extends StringToObject {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
return Enum.valueOf((Class) targetClass, string);
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ public class StringToFloat extends StringToObject {
|
||||
super(Float.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return Float.valueOf(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Float number = (Float) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ public class StringToInteger extends StringToObject {
|
||||
super(Integer.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return Integer.valueOf(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Integer number = (Integer) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ public class StringToLocale extends StringToObject {
|
||||
super(Locale.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return StringUtils.parseLocaleString(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Locale locale = (Locale) object;
|
||||
return locale.toString();
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ public class StringToLong extends StringToObject {
|
||||
super(Long.class);
|
||||
}
|
||||
|
||||
public Object toObject(String string, Class<?> objectClass) throws Exception {
|
||||
public Object toObject(String string, Class<?> objectClass) {
|
||||
return Long.valueOf(string);
|
||||
}
|
||||
|
||||
public String toString(Object object) throws Exception {
|
||||
public String toString(Object object) {
|
||||
Long number = (Long) object;
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ public interface TwoWayConverter extends Converter {
|
||||
* @return the converted object, which must be an instance of the <code>sourceClass</code>
|
||||
* @throws Exception an exception occurred performing the conversion
|
||||
*/
|
||||
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) throws Exception;
|
||||
Object convertTargetToSourceClass(Object target, Class<?> sourceClass) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class NoOpConverter implements Converter {
|
||||
return targetClass;
|
||||
}
|
||||
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
|
||||
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) {
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ class NoOpConverter implements Converter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) throws Exception,
|
||||
UnsupportedOperationException {
|
||||
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException an exception occurred during expression evaluation
|
||||
*/
|
||||
public Object getValue(Object context) throws EvaluationException;
|
||||
Object getValue(Object context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Set this expression in the provided context to the value provided.
|
||||
@@ -38,7 +38,7 @@ public interface Expression {
|
||||
* @param value the new value to set
|
||||
* @throws EvaluationException an exception occurred during expression evaluation
|
||||
*/
|
||||
public void setValue(Object context, Object value) throws EvaluationException;
|
||||
void setValue(Object context, Object value) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(Object, Object)} method for the given
|
||||
@@ -48,12 +48,12 @@ public interface Expression {
|
||||
* information cannot be determined
|
||||
* @throws EvaluationException an exception occurred during expression evaluation
|
||||
*/
|
||||
public Class<?> getValueType(Object context) throws EvaluationException;
|
||||
Class<?> getValueType(Object context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the original string used to create this expression, unmodified.
|
||||
* @return the original expression string
|
||||
*/
|
||||
public String getExpressionString();
|
||||
String getExpressionString();
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ public interface ExpressionParser {
|
||||
* @return an evaluator for the parsed expression
|
||||
* @throws ParserException an exception occurred during parsing
|
||||
*/
|
||||
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException;
|
||||
Expression parseExpression(String expressionString, ParserContext context) throws ParserException;
|
||||
|
||||
}
|
||||
@@ -26,20 +26,20 @@ public interface ParserContext {
|
||||
* value to install custom variable resolves for that particular type of context.
|
||||
* @return the evaluation context type
|
||||
*/
|
||||
public Class<?> getEvaluationContextType();
|
||||
Class<?> getEvaluationContextType();
|
||||
|
||||
/**
|
||||
* Returns the expected type of object returned from evaluating the parsed expression. An expression parser may use
|
||||
* this value to coerce an raw evaluation result before it is returned.
|
||||
* @return the expected evaluation result type
|
||||
*/
|
||||
public Class<?> getExpectedEvaluationResultType();
|
||||
Class<?> getExpectedEvaluationResultType();
|
||||
|
||||
/**
|
||||
* Returns additional expression variables or aliases that can be referenced during expression evaluation. An
|
||||
* expression parser will register these variables for reference during evaluation.
|
||||
*/
|
||||
public ExpressionVariable[] getExpressionVariables();
|
||||
ExpressionVariable[] getExpressionVariables();
|
||||
|
||||
/**
|
||||
* Whether or not the expression being parsed is a template. A template expression consists of literal text that can
|
||||
@@ -53,6 +53,6 @@ public interface ParserContext {
|
||||
*
|
||||
* @return true if the expression is a template, false otherwise
|
||||
*/
|
||||
public boolean isTemplate();
|
||||
boolean isTemplate();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.springframework.binding.expression.el;
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.ExpressionFactory;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
import javax.el.ValueExpression;
|
||||
|
||||
import org.springframework.binding.convert.ConversionException;
|
||||
@@ -45,22 +43,21 @@ class BindingValueExpression extends ValueExpression {
|
||||
return targetExpression.getExpectedType();
|
||||
}
|
||||
|
||||
public Class<?> getType(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException {
|
||||
public Class<?> getType(ELContext context) throws NullPointerException, ELException {
|
||||
return targetExpression.getType(context);
|
||||
}
|
||||
|
||||
public Object getValue(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException,
|
||||
public Object getValue(ELContext context) throws NullPointerException, ELException,
|
||||
ValueCoercionException {
|
||||
Object value = targetExpression.getValue(context);
|
||||
return convertValueIfNecessary(value, expectedType, context);
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException {
|
||||
public boolean isReadOnly(ELContext context) throws NullPointerException, ELException {
|
||||
return targetExpression.isReadOnly(context);
|
||||
}
|
||||
|
||||
public void setValue(ELContext context, Object value) throws NullPointerException, PropertyNotFoundException,
|
||||
PropertyNotWritableException, ELException, ValueCoercionException {
|
||||
public void setValue(ELContext context, Object value) throws NullPointerException, ELException, ValueCoercionException {
|
||||
value = convertValueIfNecessary(value, targetExpression.getType(context), context);
|
||||
targetExpression.setValue(context, value);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ public interface ELContextFactory {
|
||||
* @param target The base object for the expression evaluation
|
||||
* @return ELContext The configured ELContext instance for evaluating expressions.
|
||||
*/
|
||||
public ELContext getELContext(Object target);
|
||||
ELContext getELContext(Object target);
|
||||
|
||||
}
|
||||
@@ -18,11 +18,9 @@ package org.springframework.binding.expression.el;
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
|
||||
import org.springframework.binding.collection.MapAdaptable;
|
||||
@@ -45,7 +43,7 @@ public class MapAdaptableELResolver extends ELResolver {
|
||||
}
|
||||
|
||||
public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException,
|
||||
PropertyNotFoundException, ELException {
|
||||
ELException {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("The ELContext is null.");
|
||||
}
|
||||
@@ -60,7 +58,7 @@ public class MapAdaptableELResolver extends ELResolver {
|
||||
}
|
||||
|
||||
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
|
||||
PropertyNotFoundException, ELException {
|
||||
ELException {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("The ELContext is null.");
|
||||
}
|
||||
@@ -74,7 +72,7 @@ public class MapAdaptableELResolver extends ELResolver {
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException,
|
||||
PropertyNotFoundException, ELException {
|
||||
ELException {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("The ELContext is null.");
|
||||
}
|
||||
@@ -87,7 +85,7 @@ public class MapAdaptableELResolver extends ELResolver {
|
||||
}
|
||||
|
||||
public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException,
|
||||
PropertyNotFoundException, PropertyNotWritableException, ELException {
|
||||
ELException {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("The ELContext is null.");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ public interface NumberFormatFactory {
|
||||
* display.
|
||||
* @return the number format
|
||||
*/
|
||||
public NumberFormat getNumberFormat();
|
||||
NumberFormat getNumberFormat();
|
||||
|
||||
}
|
||||
@@ -28,5 +28,5 @@ public interface Mapper {
|
||||
* @param target the target
|
||||
* @return results of the mapping transaction
|
||||
*/
|
||||
public MappingResults map(Object source, Object target);
|
||||
MappingResults map(Object source, Object target);
|
||||
}
|
||||
@@ -27,15 +27,15 @@ public interface Mapping {
|
||||
/**
|
||||
* The source of the mapping.
|
||||
*/
|
||||
public Expression getSourceExpression();
|
||||
Expression getSourceExpression();
|
||||
|
||||
/**
|
||||
* The target of the mapping.
|
||||
*/
|
||||
public Expression getTargetExpression();
|
||||
Expression getTargetExpression();
|
||||
|
||||
/**
|
||||
* Whether this is a required mapping.
|
||||
*/
|
||||
public boolean isRequired();
|
||||
boolean isRequired();
|
||||
}
|
||||
@@ -28,33 +28,33 @@ public interface MappingResult extends Serializable {
|
||||
/**
|
||||
* The mapping that executed for which this result pertains to.
|
||||
*/
|
||||
public Mapping getMapping();
|
||||
Mapping getMapping();
|
||||
|
||||
/**
|
||||
* The mapping result code; for example, "success" , "typeMismatch", "propertyNotFound", or "evaluationException".
|
||||
*/
|
||||
public String getCode();
|
||||
String getCode();
|
||||
|
||||
/**
|
||||
* Indicates if this result is an error result.
|
||||
*/
|
||||
public boolean isError();
|
||||
boolean isError();
|
||||
|
||||
/**
|
||||
* Get the cause of the error result
|
||||
* @return the underyling cause, or null if this is not an error or there was no root cause.
|
||||
*/
|
||||
public Throwable getErrorCause();
|
||||
Throwable getErrorCause();
|
||||
|
||||
/**
|
||||
* The original value of the source object that was to be mapped. May be null if this result is an error on the
|
||||
* source object.
|
||||
*/
|
||||
public Object getOriginalValue();
|
||||
Object getOriginalValue();
|
||||
|
||||
/**
|
||||
* The actual value that was mapped to the target object. Null if this result is an error.
|
||||
*/
|
||||
public Object getMappedValue();
|
||||
Object getMappedValue();
|
||||
|
||||
}
|
||||
@@ -28,32 +28,32 @@ public interface MappingResults extends Serializable {
|
||||
/**
|
||||
* The source object that was mapped from.
|
||||
*/
|
||||
public Object getSource();
|
||||
Object getSource();
|
||||
|
||||
/**
|
||||
* The target object that was mapped to.
|
||||
*/
|
||||
public Object getTarget();
|
||||
Object getTarget();
|
||||
|
||||
/**
|
||||
* A list of all the mapping results between the source and target.
|
||||
*/
|
||||
public List<MappingResult> getAllResults();
|
||||
List<MappingResult> getAllResults();
|
||||
|
||||
/**
|
||||
* Whether some results were errors. Returns true if mapping errors occurred.
|
||||
*/
|
||||
public boolean hasErrorResults();
|
||||
boolean hasErrorResults();
|
||||
|
||||
/**
|
||||
* A list of all error results that occurred.
|
||||
*/
|
||||
public List<MappingResult> getErrorResults();
|
||||
List<MappingResult> getErrorResults();
|
||||
|
||||
/**
|
||||
* Get all results that meet the given result criteria.
|
||||
* @param criteria the mapping result criteria
|
||||
*/
|
||||
public List<MappingResult> getResults(MappingResultsCriteria criteria);
|
||||
List<MappingResult> getResults(MappingResultsCriteria criteria);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@ public interface MappingResultsCriteria {
|
||||
* @param result the result
|
||||
* @return true if so, false if not
|
||||
*/
|
||||
public boolean test(MappingResult result);
|
||||
boolean test(MappingResult result);
|
||||
}
|
||||
|
||||
@@ -24,36 +24,36 @@ public interface MessageContext {
|
||||
* Get all messages in this context. The messages returned should be suitable for display as-is.
|
||||
* @return the messages
|
||||
*/
|
||||
public Message[] getAllMessages();
|
||||
Message[] getAllMessages();
|
||||
|
||||
/**
|
||||
* Get all messages in this context for the source provided.
|
||||
* @param source the source associated with messages, or null for global messages
|
||||
* @return the source's messages
|
||||
*/
|
||||
public Message[] getMessagesBySource(Object source);
|
||||
Message[] getMessagesBySource(Object source);
|
||||
|
||||
/**
|
||||
* Get all messages that meet the given result criteria.
|
||||
* @param criteria the message criteria
|
||||
*/
|
||||
public Message[] getMessagesByCriteria(MessageCriteria criteria);
|
||||
Message[] getMessagesByCriteria(MessageCriteria criteria);
|
||||
|
||||
/**
|
||||
* Returns true if there are error messages in this context.
|
||||
* @return error messages
|
||||
*/
|
||||
public boolean hasErrorMessages();
|
||||
boolean hasErrorMessages();
|
||||
|
||||
/**
|
||||
* Add a new message to this context.
|
||||
* @param messageResolver the resolver that will resolve the message to be added
|
||||
*/
|
||||
public void addMessage(MessageResolver messageResolver);
|
||||
void addMessage(MessageResolver messageResolver);
|
||||
|
||||
/**
|
||||
* Clear all messages added to this context.
|
||||
*/
|
||||
public void clearMessages();
|
||||
void clearMessages();
|
||||
|
||||
}
|
||||
|
||||
@@ -157,23 +157,19 @@ public class MessageContextErrors extends AbstractErrors {
|
||||
return expressionParser.parseExpression(field, new FluentParserContext().evaluate(boundObject.getClass()));
|
||||
}
|
||||
|
||||
private static MessageCriteria GLOBAL_ERROR = new MessageCriteria() {
|
||||
public boolean test(Message message) {
|
||||
if (message.getSeverity() == Severity.ERROR && message.getSource() == null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
private static MessageCriteria GLOBAL_ERROR = message -> {
|
||||
if (message.getSeverity() == Severity.ERROR && message.getSource() == null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private static MessageCriteria FIELD_ERROR = new MessageCriteria() {
|
||||
public boolean test(Message message) {
|
||||
if (message.getSeverity() == Severity.ERROR && message.getSource() instanceof String) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
private static MessageCriteria FIELD_ERROR = message -> {
|
||||
if (message.getSeverity() == Severity.ERROR && message.getSource() instanceof String) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -27,5 +27,5 @@ public interface MessageCriteria {
|
||||
* @param message the message
|
||||
* @return true if this criteria is met for the message, false if not
|
||||
*/
|
||||
public boolean test(Message message);
|
||||
boolean test(Message message);
|
||||
}
|
||||
|
||||
@@ -35,5 +35,5 @@ public interface MessageResolver {
|
||||
* @param locale the current locale of this request
|
||||
* @return the resolved message
|
||||
*/
|
||||
public Message resolveMessage(MessageSource messageSource, Locale locale);
|
||||
Message resolveMessage(MessageSource messageSource, Locale locale);
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ public interface StateManageableMessageContext extends MessageContext {
|
||||
* Create a serializable memento, or token representing a snapshot of the internal state of this message context.
|
||||
* @return the messages memento
|
||||
*/
|
||||
public Serializable createMessagesMemento();
|
||||
Serializable createMessagesMemento();
|
||||
|
||||
/**
|
||||
* Set the state of this context from the memento provided. After this call, the messages in this context will match
|
||||
* what is encapsulated inside the memento. Any previous state will be overridden.
|
||||
* @param messagesMemento the messages memento
|
||||
*/
|
||||
public void restoreMessages(Serializable messagesMemento);
|
||||
void restoreMessages(Serializable messagesMemento);
|
||||
|
||||
/**
|
||||
* Configure the message source used to resolve messages added to this context. May be set at any time to change how
|
||||
@@ -47,5 +47,5 @@ public interface StateManageableMessageContext extends MessageContext {
|
||||
* @param messageSource the message source
|
||||
* @see MessageContext#addMessage(MessageResolver)
|
||||
*/
|
||||
public void setMessageSource(MessageSource messageSource);
|
||||
void setMessageSource(MessageSource messageSource);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public class MethodKey implements Serializable {
|
||||
* Map with primitive wrapper type as key and corresponding primitive type as value, for example: Integer.class ->
|
||||
* int.class.
|
||||
*/
|
||||
private static final Map<Class<?>, Class<?>> PRIMITIVE_WRAPPER_TYPE_MAP = new HashMap<Class<?>, Class<?>>(8);
|
||||
private static final Map<Class<?>, Class<?>> PRIMITIVE_WRAPPER_TYPE_MAP = new HashMap<>(8);
|
||||
static {
|
||||
PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class);
|
||||
PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class);
|
||||
|
||||
@@ -31,23 +31,23 @@ public interface ValidationContext {
|
||||
/**
|
||||
* A context for adding failure messages to display to the user directly.
|
||||
*/
|
||||
public MessageContext getMessageContext();
|
||||
MessageContext getMessageContext();
|
||||
|
||||
/**
|
||||
* The current user.
|
||||
*/
|
||||
public Principal getUserPrincipal();
|
||||
Principal getUserPrincipal();
|
||||
|
||||
/**
|
||||
* The current user event that triggered validation.
|
||||
*/
|
||||
public String getUserEvent();
|
||||
String getUserEvent();
|
||||
|
||||
/**
|
||||
* Obtain the value entered by the current user in the UI field bound to the property provided.
|
||||
* @param property the name of a bound property
|
||||
* @return the value the user entered in the field bound to the property
|
||||
*/
|
||||
public Object getUserValue(String property);
|
||||
Object getUserValue(String property);
|
||||
|
||||
}
|
||||
|
||||
@@ -220,16 +220,8 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, List.class);
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
final Principal princy1 = () -> "princy1";
|
||||
final Principal princy2 = () -> "princy2";
|
||||
List<String> p = (List<String>) executor.execute(new Principal[] { princy1, princy2 });
|
||||
assertEquals("princy1", p.get(0));
|
||||
assertEquals("princy2", p.get(1));
|
||||
@@ -262,16 +254,8 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, String[].class);
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
final Principal princy1 = () -> "princy1";
|
||||
final Principal princy2 = () -> "princy2";
|
||||
List<Principal> princyList = new ArrayList<>();
|
||||
princyList.add(princy1);
|
||||
princyList.add(princy2);
|
||||
@@ -303,11 +287,7 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, String[].class);
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy1 = () -> "princy1";
|
||||
String[] p = (String[]) executor.execute(princy1);
|
||||
assertEquals("princy1", p[0]);
|
||||
}
|
||||
@@ -359,11 +339,7 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, List.class);
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy1 = () -> "princy1";
|
||||
List<String> list = (List<String>) executor.execute(princy1);
|
||||
assertEquals("princy1", list.get(0));
|
||||
}
|
||||
@@ -386,16 +362,8 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
service.addConverter("princy", new CustomTwoWayConverter());
|
||||
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class);
|
||||
final Principal princy1 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy1";
|
||||
}
|
||||
};
|
||||
final Principal princy2 = new Principal() {
|
||||
public String getName() {
|
||||
return "princy2";
|
||||
}
|
||||
};
|
||||
final Principal princy1 = () -> "princy1";
|
||||
final Principal princy2 = () -> "princy2";
|
||||
List<Principal> princyList = new ArrayList<>();
|
||||
princyList.add(princy1);
|
||||
princyList.add(princy2);
|
||||
@@ -598,21 +566,17 @@ public class DefaultConversionServiceTests extends TestCase {
|
||||
super(List.class);
|
||||
}
|
||||
|
||||
protected Object toObject(String string, Class<?> targetClass) throws Exception {
|
||||
protected Object toObject(String string, Class<?> targetClass) {
|
||||
List<Principal> principals = new ArrayList<>();
|
||||
StringTokenizer tokenizer = new StringTokenizer(string, ",");
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
final String name = tokenizer.nextToken();
|
||||
principals.add(new Principal() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
});
|
||||
principals.add(() -> name);
|
||||
}
|
||||
return principals;
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
protected String toString(Object object) {
|
||||
throw new UnsupportedOperationException("No implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class StaticConversionExecutorImplTests extends TestCase {
|
||||
|
||||
private StaticConversionExecutor conversionExecutor;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
StringToDate stringToDate = new StringToDate();
|
||||
conversionExecutor = new StaticConversionExecutor(String.class, Date.class, stringToDate);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ELExpressionParserTests extends TestCase {
|
||||
public void testParseSimpleEvalExpressionNoParserContext() {
|
||||
String expressionString = "3 + 4";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
assertEquals(new Long(7), exp.getValue(null));
|
||||
assertEquals(7L, exp.getValue(null));
|
||||
}
|
||||
|
||||
public void testParseNullExpressionString() {
|
||||
@@ -61,7 +61,7 @@ public class ELExpressionParserTests extends TestCase {
|
||||
String expressionString = "3 + 4";
|
||||
Expression exp = parser
|
||||
.parseExpression(expressionString, new FluentParserContext().expectResult(Integer.class));
|
||||
assertEquals(new Integer(7), exp.getValue(null));
|
||||
assertEquals(7, exp.getValue(null));
|
||||
}
|
||||
|
||||
public void testParseBeanEvalExpressionNoParserContext() {
|
||||
@@ -73,7 +73,7 @@ public class ELExpressionParserTests extends TestCase {
|
||||
public void testParseEvalExpressionWithContextTypeCoersion() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(Long.class));
|
||||
assertEquals(new Long(2), exp.getValue(new TestBean()));
|
||||
assertEquals(2L, exp.getValue(new TestBean()));
|
||||
}
|
||||
|
||||
public void testParseEvalExpressionWithContextCustomELVariableResolver() {
|
||||
@@ -119,7 +119,7 @@ public class ELExpressionParserTests extends TestCase {
|
||||
Expression exp = parser.parseExpression("max", new FluentParserContext().variable(new ExpressionVariable("max",
|
||||
"maximum", new FluentParserContext().expectResult(Long.class))));
|
||||
TestBean target = new TestBean();
|
||||
assertEquals(new Long(2), exp.getValue(target));
|
||||
assertEquals(2L, exp.getValue(target));
|
||||
}
|
||||
|
||||
public void testTemplateNestedVariables() {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
|
||||
private SpringELExpressionParser parser = new SpringELExpressionParser(new SpelExpressionParser());
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
parser.addPropertyAccessor(new SpecialPropertyAccessor());
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
public void testParseSimpleEvalExpressionNoEvalContextWithTypeCoersion() {
|
||||
String expressionString = "3 + 4";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(Long.class));
|
||||
assertEquals(new Long(7), exp.getValue(null));
|
||||
assertEquals(7L, exp.getValue(null));
|
||||
}
|
||||
|
||||
public void testParseBeanEvalExpressionNoParserContext() {
|
||||
@@ -95,7 +95,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser
|
||||
.parseExpression(expressionString, new FluentParserContext().expectResult(Integer.class));
|
||||
assertEquals(new Integer(2), exp.getValue(new TestBean()));
|
||||
assertEquals(2, exp.getValue(new TestBean()));
|
||||
}
|
||||
|
||||
public void testParseEvalExpressionWithContextCustomELVariableResolver() {
|
||||
@@ -198,11 +198,10 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
}
|
||||
|
||||
private final class SpecialPropertyAccessor implements PropertyAccessor {
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue)
|
||||
throws AccessException {
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) {
|
||||
}
|
||||
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) {
|
||||
return new TypedValue("Custom resolver resolved this special property!",
|
||||
TypeDescriptor.valueOf(String.class));
|
||||
}
|
||||
@@ -211,11 +210,11 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) {
|
||||
return "specialProperty".equals(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,11 @@ public class DefaultMapperTests extends TestCase {
|
||||
assertEquals(0, results.getErrorResults().size());
|
||||
assertEquals("a", bean2.bar);
|
||||
assertEquals("a", bean2.baz);
|
||||
assertEquals(1, results.getResults(new MappingResultsCriteria() {
|
||||
public boolean test(MappingResult result) {
|
||||
if (result.getMapping().getTargetExpression().getExpressionString().equals("baz")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
assertEquals(1, results.getResults(result -> {
|
||||
if (result.getMapping().getTargetExpression().getExpressionString().equals("baz")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).size());
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MessageBuilderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testBuildCodes() {
|
||||
MessageResolver resolver = builder.error().codes(new String[] { "foo" }).build();
|
||||
MessageResolver resolver = builder.error().codes("foo").build();
|
||||
Message message = resolver.resolveMessage(messageSource, locale);
|
||||
assertEquals("bar", message.getText());
|
||||
assertEquals(Severity.ERROR, message.getSeverity());
|
||||
@@ -85,7 +85,7 @@ public class MessageBuilderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testBuildArgs() {
|
||||
MessageResolver resolver = builder.error().codes(new String[] { "bar" }).args(new Object[] { "baz" }).build();
|
||||
MessageResolver resolver = builder.error().codes("bar").args("baz").build();
|
||||
Message message = resolver.resolveMessage(messageSource, locale);
|
||||
assertEquals("baz", message.getText());
|
||||
assertEquals(Severity.ERROR, message.getSeverity());
|
||||
@@ -113,7 +113,7 @@ public class MessageBuilderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testBuildArgsWithNullCodes() {
|
||||
MessageResolver resolver = builder.error().args(new Object[] { "baz" }).build();
|
||||
MessageResolver resolver = builder.error().args("baz").build();
|
||||
try {
|
||||
resolver.resolveMessage(messageSource, locale);
|
||||
fail("Should have failed");
|
||||
@@ -122,7 +122,7 @@ public class MessageBuilderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testBuildArgsWithNullCodesDefaultText() {
|
||||
MessageResolver resolver = builder.error().args(new Object[] { "baz" }).defaultText("foo").build();
|
||||
MessageResolver resolver = builder.error().args("baz").defaultText("foo").build();
|
||||
Message message = resolver.resolveMessage(messageSource, locale);
|
||||
assertEquals("foo", message.getText());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class MessageBuilderTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testBuildResolvableArgs() {
|
||||
MessageResolver resolver = builder.error().codes(new String[] { "bar" }).resolvableArgs(new Object[] { "baz" })
|
||||
MessageResolver resolver = builder.error().codes("bar").resolvableArgs("baz")
|
||||
.build();
|
||||
Message message = resolver.resolveMessage(messageSource, locale);
|
||||
assertEquals("boop", message.getText());
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.springframework.binding.message;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
|
||||
import org.springframework.context.support.StaticMessageSource;
|
||||
import org.springframework.validation.MessageCodesResolver;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MessageContextErrorsMessageCodesTests extends TestCase {
|
||||
private MessageCodesResolver resolver;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
StaticMessageSource messageSource = new StaticMessageSource();
|
||||
messageSource.addMessage(errorCode, Locale.getDefault(), "doesntmatter");
|
||||
context = new DefaultMessageContext(messageSource);
|
||||
@@ -27,7 +27,7 @@ public class MessageContextErrorsMessageCodesTests extends TestCase {
|
||||
resolver = EasyMock.createMock(MessageCodesResolver.class);
|
||||
}
|
||||
|
||||
public void testRejectUsesObjectName() throws Exception {
|
||||
public void testRejectUsesObjectName() {
|
||||
EasyMock.expect(resolver.resolveMessageCodes(errorCode, objectName)).andReturn(new String[] {});
|
||||
EasyMock.replay(resolver);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MessageContextErrorsMessageCodesTests extends TestCase {
|
||||
EasyMock.verify(resolver);
|
||||
}
|
||||
|
||||
public void testRejectValueUsesObjectName() throws Exception {
|
||||
public void testRejectValueUsesObjectName() {
|
||||
EasyMock.expect(resolver.resolveMessageCodes(errorCode, objectName, "field", null)).andReturn(new String[] {});
|
||||
EasyMock.replay(resolver);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MessageContextErrorsMessageCodesTests extends TestCase {
|
||||
EasyMock.verify(resolver);
|
||||
}
|
||||
|
||||
public void testRejectValueEmptyField() throws Exception {
|
||||
public void testRejectValueEmptyField() {
|
||||
EasyMock.expect(resolver.resolveMessageCodes(errorCode, objectName)).andReturn(new String[] {});
|
||||
EasyMock.replay(resolver);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MessageContextErrorsTests extends TestCase {
|
||||
private MessageContextErrors errors;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
StaticMessageSource messageSource = new StaticMessageSource();
|
||||
messageSource.addMessage("foo", Locale.getDefault(), "bar");
|
||||
messageSource.addMessage("bar", Locale.getDefault(), "{0}");
|
||||
|
||||
@@ -29,7 +29,7 @@ public class MethodInvokerTests extends TestCase {
|
||||
|
||||
private MethodInvoker methodInvoker;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
this.methodInvoker = new MethodInvoker();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,34 +32,34 @@ public class MethodKeyTests extends TestCase {
|
||||
private static final Method LIST_FILENAME_FILTER = safeGetMethod(File.class, "list",
|
||||
new Class[] { FilenameFilter.class });
|
||||
|
||||
public void testGetMethodWithNoArgs() throws Exception {
|
||||
MethodKey key = new MethodKey(File.class, "list", new Class[0]);
|
||||
public void testGetMethodWithNoArgs() {
|
||||
MethodKey key = new MethodKey(File.class, "list");
|
||||
Method m = key.getMethod();
|
||||
assertEquals(LIST_NO_ARGS, m);
|
||||
}
|
||||
|
||||
public void testGetMoreGenericMethod() throws Exception {
|
||||
MethodKey key = new MethodKey(Object.class, "equals", new Class[] { Long.class });
|
||||
public void testGetMoreGenericMethod() {
|
||||
MethodKey key = new MethodKey(Object.class, "equals", Long.class);
|
||||
assertEquals(safeGetMethod(Object.class, "equals", new Class[] { Object.class }), key.getMethod());
|
||||
}
|
||||
|
||||
public void testGetMethodWithSingleArg() throws Exception {
|
||||
MethodKey key = new MethodKey(File.class, "list", new Class[] { FilenameFilter.class });
|
||||
public void testGetMethodWithSingleArg() {
|
||||
MethodKey key = new MethodKey(File.class, "list", FilenameFilter.class);
|
||||
Method m = key.getMethod();
|
||||
assertEquals(LIST_FILENAME_FILTER, m);
|
||||
}
|
||||
|
||||
public void testGetMethodWithSingleNullArgAndValidMatch() throws Exception {
|
||||
public void testGetMethodWithSingleNullArgAndValidMatch() {
|
||||
MethodKey key = new MethodKey(File.class, "list", new Class[] { null });
|
||||
Method m = key.getMethod();
|
||||
assertEquals(LIST_FILENAME_FILTER, m);
|
||||
}
|
||||
|
||||
public void testGetMethodWithSingleNullAndUnclearMatch() throws Exception {
|
||||
public void testGetMethodWithSingleNullAndUnclearMatch() {
|
||||
new MethodKey(File.class, "listFiles", new Class[] { null });
|
||||
}
|
||||
|
||||
private static final Method safeGetMethod(Class<?> type, String name, Class<?>[] argTypes) {
|
||||
private static Method safeGetMethod(Class<?> type, String name, Class<?>[] argTypes) {
|
||||
try {
|
||||
return type.getMethod(name, argTypes);
|
||||
} catch (NoSuchMethodException e) {
|
||||
|
||||
@@ -30,34 +30,34 @@ public interface SelectionAware<T> {
|
||||
* Checks whether the row pointed to by the model's current index is selected.
|
||||
* @return true if the current row data object is selected
|
||||
*/
|
||||
public boolean isCurrentRowSelected();
|
||||
boolean isCurrentRowSelected();
|
||||
|
||||
/**
|
||||
* Sets whether the row pointed to by the model's current index is selected
|
||||
* @param rowSelected true to select the current row
|
||||
*/
|
||||
public void setCurrentRowSelected(boolean rowSelected);
|
||||
void setCurrentRowSelected(boolean rowSelected);
|
||||
|
||||
/**
|
||||
* Sets the list of selected row data objects for the model.
|
||||
* @param selections the list of selected row data objects
|
||||
*/
|
||||
public void setSelections(List<T> selections);
|
||||
void setSelections(List<T> selections);
|
||||
|
||||
/**
|
||||
* Returns the list of selected row data objects for the model.
|
||||
* @return the list of selected row data objects
|
||||
*/
|
||||
public List<T> getSelections();
|
||||
List<T> getSelections();
|
||||
|
||||
/**
|
||||
* Selects all row data objects in the model.
|
||||
*/
|
||||
public void selectAll();
|
||||
void selectAll();
|
||||
|
||||
/**
|
||||
* Selects the given row data object in the model.
|
||||
* @param rowData the row data object to select.
|
||||
*/
|
||||
public void select(T rowData);
|
||||
void select(T rowData);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DataModelConverter implements Converter {
|
||||
if (targetClass.equals(DataModel.class)) {
|
||||
targetClass = OneSelectionTrackingListDataModel.class;
|
||||
}
|
||||
Constructor<?> emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {});
|
||||
Constructor<?> emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass);
|
||||
DataModel<?> model = (DataModel<?>) emptyConstructor.newInstance(new Object[] {});
|
||||
model.setWrappedData(source);
|
||||
return model;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/*
|
||||
* Copyright 2004-2008 the original author or authimport org.springframework.binding.convert.ConversionService;
|
||||
import org.springframework.binding.convert.support.DefaultConversionService;
|
||||
import org.springframework.faces.model.OneSelectionTrackingListDataModel;
|
||||
e.org/licenses/LICENSE-2.0
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -81,7 +81,7 @@ public class FaceletsAuthorizeTagHandler extends TagHandler {
|
||||
}
|
||||
|
||||
if (this.var != null) {
|
||||
faceletContext.setAttribute(this.var.getValue(faceletContext), Boolean.valueOf(isAuthorized));
|
||||
faceletContext.setAttribute(this.var.getValue(faceletContext), isAuthorized);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class JsfAjaxHandler extends AbstractAjaxHandler {
|
||||
} else {
|
||||
String header = request.getHeader("Faces-Request");
|
||||
String param = request.getParameter("javax.faces.partial.ajax");
|
||||
return ("partial/ajax".equals(header) || "true".equals(param)) ? true : false;
|
||||
return "partial/ajax".equals(header) || "true".equals(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,19 +56,19 @@ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) {
|
||||
return (getJsfManagedBean(name) != null);
|
||||
}
|
||||
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) {
|
||||
return new TypedValue(getJsfManagedBean(name));
|
||||
}
|
||||
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) {
|
||||
return (getScopeForBean(name) != null);
|
||||
}
|
||||
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) {
|
||||
MutableAttributeMap<Object> map = getScopeForBean(name);
|
||||
if (map != null) {
|
||||
map.put(name, newValue);
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.application.ResourceHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -38,7 +36,7 @@ import org.springframework.web.context.support.WebApplicationObjectSupport;
|
||||
public class JsfResourceRequestHandler extends WebApplicationObjectSupport implements HttpRequestHandler {
|
||||
|
||||
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
throws IOException {
|
||||
|
||||
FacesContextHelper helper = new FacesContextHelper();
|
||||
try {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class JsfUtils {
|
||||
private static final Map<Class<?>, String> FACTORY_NAMES;
|
||||
|
||||
static {
|
||||
FACTORY_NAMES = new HashMap<Class<?>, String>();
|
||||
FACTORY_NAMES = new HashMap<>();
|
||||
FACTORY_NAMES.put(ApplicationFactory.class, FactoryFinder.APPLICATION_FACTORY);
|
||||
FACTORY_NAMES.put(ExceptionHandlerFactory.class, FactoryFinder.EXCEPTION_HANDLER_FACTORY);
|
||||
FACTORY_NAMES.put(ExternalContextFactory.class, FactoryFinder.EXTERNAL_CONTEXT_FACTORY);
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.springframework.faces.webflow.FacesSpringELExpressionParser;
|
||||
import org.springframework.faces.webflow.JSFMockHelper;
|
||||
import org.springframework.faces.webflow.JsfViewFactoryCreator;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.faces.config.EmptySpringValidator;
|
||||
import org.springframework.faces.config.MyBeanValidationHintResolver;
|
||||
import org.springframework.webflow.engine.builder.BinderConfiguration;
|
||||
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
|
||||
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
|
||||
|
||||
@@ -94,11 +94,11 @@ public class SelectionTrackingActionListenerTests extends TestCase {
|
||||
uiRepeat.getChildren().add(commandButton);
|
||||
this.viewToTest.getChildren().add(uiRepeat);
|
||||
|
||||
Method indexMutator = ReflectionUtils.findMethod(UIRepeat.class, "setIndex", new Class[] { FacesContext.class,
|
||||
int.class });
|
||||
Method indexMutator = ReflectionUtils.findMethod(UIRepeat.class, "setIndex", FacesContext.class,
|
||||
int.class);
|
||||
indexMutator.setAccessible(true);
|
||||
|
||||
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), 1 });
|
||||
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new MockFacesContext(), 1);
|
||||
|
||||
ActionEvent event = new ActionEvent(commandButton);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class SelectionTrackingActionListenerTests extends TestCase {
|
||||
assertSame(this.dataModel.getSelectedRow(), this.dataModel.getRowData());
|
||||
assertTrue(this.delegateListener.processedEvent);
|
||||
|
||||
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new Object[] { new MockFacesContext(), 2 });
|
||||
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new MockFacesContext(), 2);
|
||||
assertFalse(this.dataModel.isCurrentRowSelected());
|
||||
assertTrue(this.dataModel.getSelectedRow() != this.dataModel.getRowData());
|
||||
}
|
||||
|
||||
@@ -23,43 +23,43 @@ import junit.framework.TestCase;
|
||||
*/
|
||||
public class FaceletsAuthorizeTagTests extends TestCase {
|
||||
|
||||
public void testIfAllGrantedWithOneRole() throws Exception {
|
||||
public void testIfAllGrantedWithOneRole() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfAllGranted("ROLE_A");
|
||||
assertEquals("hasRole('ROLE_A')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfAllGrantedWithMultipleRoles() throws Exception {
|
||||
public void testIfAllGrantedWithMultipleRoles() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfAllGranted("ROLE_A, ROLE_B, ROLE_C");
|
||||
assertEquals("hasRole('ROLE_A') and hasRole('ROLE_B') and hasRole('ROLE_C')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfAnyGrantedWithOneRole() throws Exception {
|
||||
public void testIfAnyGrantedWithOneRole() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfAnyGranted("ROLE_A");
|
||||
assertEquals("hasAnyRole('ROLE_A')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfAnyGrantedWithMultipleRole() throws Exception {
|
||||
public void testIfAnyGrantedWithMultipleRole() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfAnyGranted("ROLE_A, ROLE_B, ROLE_C");
|
||||
assertEquals("hasAnyRole('ROLE_A','ROLE_B','ROLE_C')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfNoneGrantedWithOneRole() throws Exception {
|
||||
public void testIfNoneGrantedWithOneRole() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfNotGranted("ROLE_A");
|
||||
assertEquals("!hasAnyRole('ROLE_A')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfNoneGrantedWithMultipleRole() throws Exception {
|
||||
public void testIfNoneGrantedWithMultipleRole() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfNotGranted("ROLE_A, ROLE_B, ROLE_C");
|
||||
assertEquals("!hasAnyRole('ROLE_A','ROLE_B','ROLE_C')", tag.getAccess());
|
||||
}
|
||||
|
||||
public void testIfAllAnyNotGranted() throws Exception {
|
||||
public void testIfAllAnyNotGranted() {
|
||||
FaceletsAuthorizeTag tag = new FaceletsAuthorizeTag();
|
||||
tag.setIfAllGranted("ROLE_A");
|
||||
tag.setIfAnyGranted("ROLE_B");
|
||||
|
||||
@@ -8,15 +8,13 @@ import javax.faces.el.MethodNotFoundException;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
|
||||
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
||||
import org.springframework.webflow.engine.Flow;
|
||||
import org.springframework.webflow.engine.ViewState;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
import org.springframework.webflow.execution.View;
|
||||
import org.springframework.webflow.execution.ViewFactory;
|
||||
|
||||
public class FlowActionListenerTests extends TestCase {
|
||||
|
||||
@@ -85,7 +83,7 @@ public class FlowActionListenerTests extends TestCase {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
public Object invoke(FacesContext context, Object... args) throws EvaluationException, MethodNotFoundException {
|
||||
public Object invoke(FacesContext context, Object... args) throws EvaluationException {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@@ -94,11 +92,8 @@ public class FlowActionListenerTests extends TestCase {
|
||||
private class MockViewState extends ViewState {
|
||||
|
||||
public MockViewState() {
|
||||
super(new Flow("mockFlow"), "mockView", new ViewFactory() {
|
||||
|
||||
public View getView(RequestContext context) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
super(new Flow("mockFlow"), "mockView", context -> {
|
||||
throw new UnsupportedOperationException();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.springframework.faces.webflow;
|
||||
import javax.el.ELContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.myfaces.test.el.MockELContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
||||
@@ -26,29 +26,29 @@ public class FlowELResolverTests extends TestCase {
|
||||
|
||||
private final ELContext elContext = new MockELContext();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
protected void setUp() {
|
||||
RequestContextHolder.setRequestContext(this.requestContext);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
protected void tearDown() {
|
||||
RequestContextHolder.setRequestContext(null);
|
||||
}
|
||||
|
||||
public void testRequestContextResolve() throws Exception {
|
||||
public void testRequestContextResolve() {
|
||||
Object actual = this.resolver.getValue(this.elContext, null, "flowRequestContext");
|
||||
assertTrue(this.elContext.isPropertyResolved());
|
||||
assertNotNull(actual);
|
||||
assertSame(this.requestContext, actual);
|
||||
}
|
||||
|
||||
public void testImplicitFlowResolve() throws Exception {
|
||||
public void testImplicitFlowResolve() {
|
||||
Object actual = this.resolver.getValue(this.elContext, null, "flowScope");
|
||||
assertTrue(this.elContext.isPropertyResolved());
|
||||
assertNotNull(actual);
|
||||
assertSame(this.requestContext.getFlowScope(), actual);
|
||||
}
|
||||
|
||||
public void testFlowResourceResolve() throws Exception {
|
||||
public void testFlowResourceResolve() {
|
||||
ApplicationContext applicationContext = new StaticWebApplicationContext();
|
||||
((Flow) this.requestContext.getActiveFlow()).setApplicationContext(applicationContext);
|
||||
Object actual = this.resolver.getValue(this.elContext, null, "resourceBundle");
|
||||
@@ -57,14 +57,14 @@ public class FlowELResolverTests extends TestCase {
|
||||
assertSame(applicationContext, actual);
|
||||
}
|
||||
|
||||
public void testScopeResolve() throws Exception {
|
||||
public void testScopeResolve() {
|
||||
this.requestContext.getFlowScope().put("test", "test");
|
||||
Object actual = this.resolver.getValue(this.elContext, null, "test");
|
||||
assertTrue(this.elContext.isPropertyResolved());
|
||||
assertEquals("test", actual);
|
||||
}
|
||||
|
||||
public void testMapAdaptableResolve() throws Exception {
|
||||
public void testMapAdaptableResolve() {
|
||||
LocalAttributeMap<String> base = new LocalAttributeMap<>();
|
||||
base.put("test", "test");
|
||||
Object actual = this.resolver.getValue(this.elContext, base, "test");
|
||||
@@ -72,7 +72,7 @@ public class FlowELResolverTests extends TestCase {
|
||||
assertEquals("test", actual);
|
||||
}
|
||||
|
||||
public void testBeanResolveWithRequestContext() throws Exception {
|
||||
public void testBeanResolveWithRequestContext() {
|
||||
StaticWebApplicationContext applicationContext = new StaticWebApplicationContext();
|
||||
((Flow) this.requestContext.getActiveFlow()).setApplicationContext(applicationContext);
|
||||
applicationContext.registerSingleton("test", Bean.class);
|
||||
@@ -82,7 +82,7 @@ public class FlowELResolverTests extends TestCase {
|
||||
assertTrue(actual instanceof Bean);
|
||||
}
|
||||
|
||||
public void testBeanResolveWithoutRequestContext() throws Exception {
|
||||
public void testBeanResolveWithoutRequestContext() {
|
||||
RequestContextHolder.setRequestContext(null);
|
||||
Object actual = this.resolver.getValue(this.elContext, null, "test");
|
||||
assertFalse(this.elContext.isPropertyResolved());
|
||||
|
||||
@@ -54,7 +54,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testAddMessage() {
|
||||
this.messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_INFO, "foo", "bar"));
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetGlobalMessagesOnly() {
|
||||
this.messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_INFO, "foo", "bar"));
|
||||
this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR"));
|
||||
@@ -84,7 +84,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetAllMessages() {
|
||||
this.messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_INFO, "foo", "bar"));
|
||||
this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR"));
|
||||
@@ -102,7 +102,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testAddMessages_MultipleNullIds() {
|
||||
this.messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "foo", "bar"));
|
||||
this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "zoo", "zar"));
|
||||
@@ -116,7 +116,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetMessages() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator<FacesMessage> i = this.facesContext.getMessages();
|
||||
@@ -130,7 +130,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testMutableGetMessages() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("TESTID", new FacesMessage("summary1"));
|
||||
FacesMessage soruceMessage = this.facesContext.getMessages("TESTID").next();
|
||||
@@ -148,7 +148,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetMessagesByClientId_ForComponent() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator<FacesMessage> i = this.facesContext.getMessages("componentId");
|
||||
@@ -165,7 +165,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetMessagesByClientId_ForUserMessage() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
int iterationCount = 0;
|
||||
Iterator<FacesMessage> i = this.facesContext.getMessages("userMessage");
|
||||
@@ -182,7 +182,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testgetMessagesByClientId_InvalidId() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
Iterator<FacesMessage> i = this.facesContext.getMessages("unknown");
|
||||
assertFalse(i.hasNext());
|
||||
@@ -191,7 +191,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetClientIdsWithMessages() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
List<String> expectedOrderedIds = new ArrayList<>();
|
||||
expectedOrderedIds.add(null);
|
||||
@@ -211,7 +211,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testMessagesAreSerializable() throws Exception {
|
||||
DefaultMessageContext messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("TESTID", new FacesMessage("summary1"));
|
||||
FacesMessage sourceMessage = this.facesContext.getMessages("TESTID").next();
|
||||
@@ -232,9 +232,9 @@ public class FlowFacesContextTests extends TestCase {
|
||||
ois.close();
|
||||
|
||||
messageContext.restoreMessages(mementoRead);
|
||||
EasyMock.reset(new Object[] { this.requestContext });
|
||||
EasyMock.reset(this.requestContext);
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
FacesContext newFacesContext = new FlowFacesContext(this.requestContext, this.jsf.facesContext());
|
||||
assertSame(FacesContext.getCurrentInstance(), newFacesContext);
|
||||
@@ -246,7 +246,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testGetMaximumSeverity() {
|
||||
this.messageContext = this.prepopulatedMessageContext;
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
assertEquals(FacesMessage.SEVERITY_FATAL, this.facesContext.getMaximumSeverity());
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class FlowFacesContextTests extends TestCase {
|
||||
public final void testValidationFailed() {
|
||||
this.messageContext = new DefaultMessageContext();
|
||||
EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
|
||||
EasyMock.replay(new Object[] { this.requestContext });
|
||||
EasyMock.replay(this.requestContext);
|
||||
|
||||
this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_ERROR, "foo", "bar"));
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class FlowPartialViewContextTests extends TestCase {
|
||||
RequestContextHolder.setRequestContext(null);
|
||||
}
|
||||
|
||||
public void testReturnFragmentIds() throws Exception {
|
||||
public void testReturnFragmentIds() {
|
||||
String[] fragmentIds = new String[] { "foo", "bar" };
|
||||
|
||||
RequestContext requestContext = new MockRequestContext();
|
||||
@@ -31,7 +31,7 @@ public class FlowPartialViewContextTests extends TestCase {
|
||||
assertEquals(Arrays.asList(fragmentIds), new FlowPartialViewContext(null).getRenderIds());
|
||||
}
|
||||
|
||||
public void testNoFragmentIds() throws Exception {
|
||||
public void testNoFragmentIds() {
|
||||
final List<String> renderIds = Arrays.asList("foo", "bar");
|
||||
FlowPartialViewContext context = new FlowPartialViewContext(new PartialViewContextWrapper() {
|
||||
public Collection<String> getRenderIds() {
|
||||
@@ -51,7 +51,7 @@ public class FlowPartialViewContextTests extends TestCase {
|
||||
assertEquals(renderIds, context.getRenderIds());
|
||||
}
|
||||
|
||||
public void testReturnFragmentIdsMutable() throws Exception {
|
||||
public void testReturnFragmentIdsMutable() {
|
||||
String[] fragmentIds = new String[] { "foo", "bar" };
|
||||
|
||||
RequestContext requestContext = new MockRequestContext();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
@@ -37,11 +39,11 @@ public class FlowResponseStateManagerTests extends TestCase {
|
||||
RequestContextHolder.setRequestContext(null);
|
||||
}
|
||||
|
||||
public void testname() throws Exception {
|
||||
public void testname() {
|
||||
|
||||
}
|
||||
|
||||
public void testWriteFlowSerializedView() throws Exception {
|
||||
public void testWriteFlowSerializedView() throws IOException {
|
||||
EasyMock.expect(this.flowExecutionContext.getKey()).andReturn(new MockFlowExecutionKey("e1s1"));
|
||||
LocalAttributeMap<Object> viewMap = new LocalAttributeMap<>();
|
||||
EasyMock.expect(this.requestContext.getViewScope()).andStubReturn(viewMap);
|
||||
@@ -58,7 +60,7 @@ public class FlowResponseStateManagerTests extends TestCase {
|
||||
EasyMock.verify(this.flowExecutionContext, this.requestContext);
|
||||
}
|
||||
|
||||
public void testGetState() throws Exception {
|
||||
public void testGetState() {
|
||||
Object state = new Object();
|
||||
|
||||
LocalAttributeMap<Object> viewMap = new LocalAttributeMap<>();
|
||||
|
||||
@@ -41,18 +41,18 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase {
|
||||
RequestContextHolder.setRequestContext(null);
|
||||
}
|
||||
|
||||
public void testCanRead() throws Exception {
|
||||
public void testCanRead() {
|
||||
this.jsfMock.externalContext().getRequestMap().put("myJsfBean", new Object());
|
||||
assertTrue(this.accessor.canRead(null, null, "myJsfBean"));
|
||||
}
|
||||
|
||||
public void testRead() throws Exception {
|
||||
public void testRead() {
|
||||
Object jsfBean = new Object();
|
||||
this.jsfMock.externalContext().getRequestMap().put("myJsfBean", jsfBean);
|
||||
assertEquals(jsfBean, this.accessor.read(null, null, "myJsfBean").getValue());
|
||||
}
|
||||
|
||||
public void testCanWrite() throws Exception {
|
||||
public void testCanWrite() {
|
||||
assertFalse(this.accessor.canWrite(null, null, "myJsfBean"));
|
||||
|
||||
MutableAttributeMap<Object> map = this.requestContext.getExternalContext().getRequestMap();
|
||||
@@ -71,7 +71,7 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
public void testWrite() throws Exception {
|
||||
public void testWrite() {
|
||||
Object jsfBean1 = new Object();
|
||||
Object jsfBean2 = new Object();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBeforeListenersCalledInForwardOrder() throws Exception {
|
||||
public void testBeforeListenersCalledInForwardOrder() {
|
||||
List<OrderVerifyingPhaseListener> list = new ArrayList<>();
|
||||
MockLifecycle lifecycle = new MockLifecycle();
|
||||
PhaseListener listener1 = new OrderVerifyingPhaseListener(null, list);
|
||||
@@ -41,7 +41,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
assertEquals(listener3, list.get(2));
|
||||
}
|
||||
|
||||
public void testAfterListenersCalledInReverseOrder() throws Exception {
|
||||
public void testAfterListenersCalledInReverseOrder() {
|
||||
List<OrderVerifyingPhaseListener> list = new ArrayList<>();
|
||||
MockLifecycle lifecycle = new MockLifecycle();
|
||||
PhaseListener listener1 = new OrderVerifyingPhaseListener(list, null);
|
||||
@@ -56,7 +56,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
assertEquals(listener1, list.get(2));
|
||||
}
|
||||
|
||||
public void testGetFactory() throws Exception {
|
||||
public void testGetFactory() {
|
||||
// Not testing all but at least test the mocked factories
|
||||
assertTrue(JsfUtils.findFactory(ApplicationFactory.class) instanceof MockApplicationFactory);
|
||||
assertTrue(JsfUtils.findFactory(FacesContextFactory.class) instanceof MockFacesContextFactory);
|
||||
@@ -64,7 +64,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
assertTrue(JsfUtils.findFactory(RenderKitFactory.class) instanceof MockRenderKitFactory);
|
||||
}
|
||||
|
||||
public void testGetUnknowFactory() throws Exception {
|
||||
public void testGetUnknowFactory() {
|
||||
try {
|
||||
JsfUtils.findFactory(InputStream.class);
|
||||
fail("Did not throw");
|
||||
|
||||
@@ -380,7 +380,7 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
|
||||
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
|
||||
if (event instanceof PostRestoreStateEvent) {
|
||||
assertSame("Component did not match", this, ((PostRestoreStateEvent) event).getComponent());
|
||||
assertSame("Component did not match", this, event.getComponent());
|
||||
this.postRestoreStateEventSeen = true;
|
||||
if (this.throwOnPostRestoreStateEvent) {
|
||||
this.abortProcessingException = new AbortProcessingException();
|
||||
|
||||
@@ -99,7 +99,7 @@ public class JsfViewTests extends TestCase {
|
||||
}
|
||||
|
||||
public final void testSaveState() {
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
this.view.saveState();
|
||||
}
|
||||
|
||||
@@ -108,17 +108,17 @@ public class JsfViewTests extends TestCase {
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
.andStubReturn(null);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
this.view.render();
|
||||
}
|
||||
|
||||
public final void testRenderException() throws IOException {
|
||||
public final void testRenderException() {
|
||||
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
.andStubReturn(null);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
this.jsfMock.application().setViewHandler(new ExceptionalViewHandler());
|
||||
|
||||
@@ -143,7 +143,7 @@ public class JsfViewTests extends TestCase {
|
||||
UIViewRoot existingRoot = new UIViewRoot();
|
||||
existingRoot.setViewId(VIEW_ID);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
JsfView restoredView = new JsfView(existingRoot, lifecycle, this.context);
|
||||
|
||||
@@ -168,7 +168,7 @@ public class JsfViewTests extends TestCase {
|
||||
UIViewRoot existingRoot = new UIViewRoot();
|
||||
existingRoot.setViewId(VIEW_ID);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
JsfView restoredView = new JsfView(existingRoot, lifecycle, this.context);
|
||||
|
||||
@@ -185,7 +185,7 @@ public class JsfViewTests extends TestCase {
|
||||
requestParameterMap.put("execution", "e1s1");
|
||||
|
||||
EasyMock.expect(this.context.getRequestParameters()).andStubReturn(requestParameterMap);
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
JsfView createdView = new JsfView(new UIViewRoot(), this.jsfMock.lifecycle(), this.context);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class JsfViewTests extends TestCase {
|
||||
this.jsfMock.request().addParameter("execution", "e1s1");
|
||||
this.jsfMock.request().addParameter("javax.faces.ViewState", "e1s1");
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
JsfView createdView = new JsfView(new UIViewRoot(), this.jsfMock.lifecycle(), this.context);
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getResource(String arg0) throws MalformedURLException {
|
||||
public URL getResource(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@ package org.springframework.faces.webflow;
|
||||
|
||||
public interface MockService {
|
||||
|
||||
public void doSomething(String arg);
|
||||
void doSomething(String arg);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,6 @@ public class MockViewHandler extends ViewHandler {
|
||||
return this.restoreViewRoot;
|
||||
}
|
||||
|
||||
public void writeState(FacesContext context) throws IOException {
|
||||
public void writeState(FacesContext context) {
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractAction implements Action, InitializingBean {
|
||||
return new EventFactorySupport();
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
try {
|
||||
initAction();
|
||||
} catch (Exception ex) {
|
||||
@@ -66,7 +66,7 @@ public abstract class AbstractAction implements Action, InitializingBean {
|
||||
* Keep in mind that this hook will only be invoked when this action is deployed in a Spring application context
|
||||
* since it uses the Spring {@link InitializingBean} mechanism to trigger action initialisation.
|
||||
*/
|
||||
protected void initAction() throws Exception {
|
||||
protected void initAction() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ public abstract class AbstractAction implements Action, InitializingBean {
|
||||
* or <code>null</code> if the <code>doExecute()</code> method should be called to obtain the action result
|
||||
* @throws Exception an <b>unrecoverable</b> exception occured, either checked or unchecked
|
||||
*/
|
||||
protected Event doPreExecute(RequestContext context) throws Exception {
|
||||
protected Event doPreExecute(RequestContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public abstract class AbstractAction implements Action, InitializingBean {
|
||||
* Template hook method subclasses should override to encapsulate their specific action execution logic.
|
||||
* @param context the action execution context, for accessing and setting data in "flow scope" or "request scope"
|
||||
* @return the action result event
|
||||
* @throws Exception an <b>unrecoverable</b> exception occured, either checked or unchecked
|
||||
* @an <b>unrecoverable</b> exception occured, either checked or unchecked
|
||||
*/
|
||||
protected abstract Event doExecute(RequestContext context) throws Exception;
|
||||
|
||||
@@ -237,6 +237,6 @@ public abstract class AbstractAction implements Action, InitializingBean {
|
||||
* @param context the action execution context, for accessing and setting data in "flow scope" or "request scope"
|
||||
* @throws Exception an <b>unrecoverable</b> exception occured, either checked or unchecked
|
||||
*/
|
||||
protected void doPostExecute(RequestContext context) throws Exception {
|
||||
protected void doPostExecute(RequestContext context) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ExternalRedirectAction extends AbstractAction {
|
||||
this.resourceUri = resourceUri;
|
||||
}
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
protected Event doExecute(RequestContext context) {
|
||||
String resourceUri = (String) this.resourceUri.getValue(context);
|
||||
context.getExternalContext().requestExternalRedirect(resourceUri);
|
||||
return success();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FlowDefinitionRedirectAction extends AbstractAction {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
protected Event doExecute(RequestContext context) {
|
||||
String encodedRedirect = (String) expression.getValue(context);
|
||||
if (encodedRedirect == null) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -426,8 +426,7 @@ public class FormAction extends MultiAction implements InitializingBean {
|
||||
+ "] does not support form object class [" + getFormObjectClass() + "]");
|
||||
}
|
||||
// signature: public void ${validateMethodName}(${formObjectClass}, Errors)
|
||||
validateMethodInvoker = new DispatchMethodInvoker(getValidator(), new Class[] { getFormObjectClass(),
|
||||
Errors.class });
|
||||
validateMethodInvoker = new DispatchMethodInvoker(getValidator(), getFormObjectClass(), Errors.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,7 +712,7 @@ public class FormAction extends MultiAction implements InitializingBean {
|
||||
logger.debug("Invoking piecemeal validator method '" + validatorMethod + "(" + getFormObjectClass()
|
||||
+ ", Errors)'");
|
||||
}
|
||||
getValidateMethodInvoker().invoke(validatorMethod, new Object[] { formObject, errors });
|
||||
getValidateMethodInvoker().invoke(validatorMethod, formObject, errors);
|
||||
}
|
||||
|
||||
// accessible helpers (subclasses could override if necessary)
|
||||
@@ -775,7 +774,7 @@ public class FormAction extends MultiAction implements InitializingBean {
|
||||
* @see #initBinder(RequestContext, DataBinder)
|
||||
* @see #setMessageCodesResolver(MessageCodesResolver)
|
||||
*/
|
||||
protected DataBinder createBinder(RequestContext context, Object formObject) throws Exception {
|
||||
protected DataBinder createBinder(RequestContext context, Object formObject) {
|
||||
DataBinder binder = new WebDataBinder(formObject, getFormObjectName());
|
||||
if (getMessageCodesResolver() != null) {
|
||||
binder.setMessageCodesResolver(getMessageCodesResolver());
|
||||
@@ -791,7 +790,7 @@ public class FormAction extends MultiAction implements InitializingBean {
|
||||
* @param binder the data binder to use
|
||||
* @throws Exception when an unrecoverable exception occurs
|
||||
*/
|
||||
protected void doBind(RequestContext context, DataBinder binder) throws Exception {
|
||||
protected void doBind(RequestContext context, DataBinder binder) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Binding allowed request parameters in "
|
||||
+ StylerUtils.style(context.getExternalContext().getRequestParameterMap())
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MultiAction extends AbstractAction {
|
||||
* @param target the target
|
||||
*/
|
||||
protected final void setTarget(Object target) {
|
||||
methodInvoker = new DispatchMethodInvoker(target, new Class[] { RequestContext.class });
|
||||
methodInvoker = new DispatchMethodInvoker(target, RequestContext.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ public class MultiAction extends AbstractAction {
|
||||
|
||||
protected final Event doExecute(RequestContext context) throws Exception {
|
||||
String method = getMethodResolver().resolveMethod(context);
|
||||
Object obj = methodInvoker.invoke(method, new Object[] { context });
|
||||
Object obj = methodInvoker.invoke(method, context);
|
||||
if (obj != null) {
|
||||
Assert.isInstanceOf(Event.class, obj, "The '" + method + "' action execution method on target object '"
|
||||
+ methodInvoker.getTarget() + "' did not return an Event object but '" + obj + "' of type "
|
||||
@@ -144,6 +144,6 @@ public class MultiAction extends AbstractAction {
|
||||
* @param context the flow execution request context
|
||||
* @return the name of the method that should handle action execution
|
||||
*/
|
||||
public String resolveMethod(RequestContext context);
|
||||
String resolveMethod(RequestContext context);
|
||||
}
|
||||
}
|
||||
@@ -33,5 +33,5 @@ public interface ResultEventFactory {
|
||||
* @param context a flow execution request context
|
||||
* @return the event
|
||||
*/
|
||||
public Event createResultEvent(Object source, Object resultObject, RequestContext context);
|
||||
Event createResultEvent(Object source, Object resultObject, RequestContext context);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class SetAction extends AbstractAction {
|
||||
this.valueExpression = valueExpression;
|
||||
}
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
protected Event doExecute(RequestContext context) {
|
||||
Object value = valueExpression.getValue(context);
|
||||
nameExpression.setValue(context, value);
|
||||
return success();
|
||||
|
||||
@@ -264,7 +264,7 @@ public class FlowDefinitionRegistryBuilder {
|
||||
}
|
||||
|
||||
private void registerFlow(FlowDefinitionResource resource, DefaultFlowRegistry flowRegistry) {
|
||||
FlowModelBuilder flowModelBuilder = null;
|
||||
FlowModelBuilder flowModelBuilder;
|
||||
if (resource.getPath().getFilename().endsWith(".xml")) {
|
||||
flowModelBuilder = new XmlFlowModelBuilder(resource.getPath(), flowRegistry.getFlowModelRegistry());
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,8 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class FlowExecutionListenerLoaderBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private static final String FLOW_EXECUTION_LISTENER_LOADER_FACTORY_BEAN_CLASS_NAME = "org.springframework.webflow.config.FlowExecutionListenerLoaderFactoryBean";
|
||||
private static final String FLOW_EXECUTION_LISTENER_LOADER_FACTORY_BEAN_CLASS_NAME =
|
||||
"org.springframework.webflow.config.FlowExecutionListenerLoaderFactoryBean";
|
||||
|
||||
protected String getBeanClassName(Element element) {
|
||||
return FLOW_EXECUTION_LISTENER_LOADER_FACTORY_BEAN_CLASS_NAME;
|
||||
|
||||
@@ -131,7 +131,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
flowResourceFactory = new FlowDefinitionResourceFactory(flowBuilderServices.getApplicationContext());
|
||||
if (basePath != null) {
|
||||
flowResourceFactory.setBasePath(basePath);
|
||||
@@ -143,7 +143,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
|
||||
registerFlowBuilders();
|
||||
}
|
||||
|
||||
public FlowDefinitionRegistry getObject() throws Exception {
|
||||
public FlowDefinitionRegistry getObject() {
|
||||
return flowRegistry;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
|
||||
|
||||
// implement DisposableBean
|
||||
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
flowRegistry.destroy();
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class FlowRegistryFactoryBean implements FactoryBean<FlowDefinitionRegistry>, Be
|
||||
if (flowLocationPatterns != null) {
|
||||
for (String pattern : flowLocationPatterns) {
|
||||
FlowDefinitionResource[] resources;
|
||||
AttributeMap<Object> attributes = getFlowAttributes(Collections.<FlowElementAttribute> emptySet());
|
||||
AttributeMap<Object> attributes = getFlowAttributes(Collections.emptySet());
|
||||
try {
|
||||
resources = flowResourceFactory.createResources(pattern, attributes);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -45,28 +45,28 @@ public interface ExternalContext {
|
||||
* Returns the logical path to the application hosting this external context.
|
||||
* @return the context path
|
||||
*/
|
||||
public String getContextPath();
|
||||
String getContextPath();
|
||||
|
||||
/**
|
||||
* Provides access to the parameters associated with the user request that led to SWF being called. This map is
|
||||
* expected to be immutable and cannot be changed.
|
||||
* @return the immutable request parameter map
|
||||
*/
|
||||
public ParameterMap getRequestParameterMap();
|
||||
ParameterMap getRequestParameterMap();
|
||||
|
||||
/**
|
||||
* Provides access to the external request attribute map, providing a storage for data local to the current user
|
||||
* request and accessible to both internal and external SWF artifacts.
|
||||
* @return the mutable request attribute map
|
||||
*/
|
||||
public MutableAttributeMap<Object> getRequestMap();
|
||||
MutableAttributeMap<Object> getRequestMap();
|
||||
|
||||
/**
|
||||
* Provides access to the external session map, providing a storage for data local to the current user session and
|
||||
* accessible to both internal and external SWF artifacts.
|
||||
* @return the mutable session attribute map
|
||||
*/
|
||||
public SharedAttributeMap<Object> getSessionMap();
|
||||
SharedAttributeMap<Object> getSessionMap();
|
||||
|
||||
/**
|
||||
* Provides access to the <i>global</i> external session map, providing a storage for data globally accross the user
|
||||
@@ -76,20 +76,20 @@ public interface ExternalContext {
|
||||
* scope and a "global" session scope. Otherwise this method returns the same map as calling {@link #getSessionMap()}.
|
||||
* @return the mutable global session attribute map
|
||||
*/
|
||||
public SharedAttributeMap<Object> getGlobalSessionMap();
|
||||
SharedAttributeMap<Object> getGlobalSessionMap();
|
||||
|
||||
/**
|
||||
* Provides access to the external application map, providing a storage for data local to the current user
|
||||
* application and accessible to both internal and external SWF artifacts.
|
||||
* @return the mutable application attribute map
|
||||
*/
|
||||
public SharedAttributeMap<Object> getApplicationMap();
|
||||
SharedAttributeMap<Object> getApplicationMap();
|
||||
|
||||
/**
|
||||
* Returns true if the current request is an asynchronous Ajax request.
|
||||
* @return true if the current request is an Ajax request
|
||||
*/
|
||||
public boolean isAjaxRequest();
|
||||
boolean isAjaxRequest();
|
||||
|
||||
/**
|
||||
* Get a flow execution URL for the execution with the provided key. Typically used by response writers that write
|
||||
@@ -98,51 +98,51 @@ public interface ExternalContext {
|
||||
* @param flowExecutionKey the flow execution key
|
||||
* @return the flow execution URL
|
||||
*/
|
||||
public String getFlowExecutionUrl(String flowId, String flowExecutionKey);
|
||||
String getFlowExecutionUrl(String flowId, String flowExecutionKey);
|
||||
|
||||
/**
|
||||
* Provides access to the user's principal security object.
|
||||
* @return the user principal
|
||||
*/
|
||||
public Principal getCurrentUser();
|
||||
Principal getCurrentUser();
|
||||
|
||||
/**
|
||||
* Returns the client locale.
|
||||
* @return the locale
|
||||
*/
|
||||
public Locale getLocale();
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Provides access to the context object for the current environment.
|
||||
* @return the environment specific context object
|
||||
*/
|
||||
public Object getNativeContext();
|
||||
Object getNativeContext();
|
||||
|
||||
/**
|
||||
* Provides access to the request object for the current environment.
|
||||
* @return the environment specific request object.
|
||||
*/
|
||||
public Object getNativeRequest();
|
||||
Object getNativeRequest();
|
||||
|
||||
/**
|
||||
* Provides access to the response object for the current environment.
|
||||
* @return the environment specific response object.
|
||||
*/
|
||||
public Object getNativeResponse();
|
||||
Object getNativeResponse();
|
||||
|
||||
/**
|
||||
* Get a writer for writing out a response.
|
||||
* @return the writer
|
||||
* @throws IllegalStateException if the response has completed or is not allowed
|
||||
*/
|
||||
public Writer getResponseWriter() throws IllegalStateException;
|
||||
Writer getResponseWriter() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Is a <i>render</i> response allowed to be written for this request? Always return false after a response has been
|
||||
* completed. May return false before that to indicate a response is not allowed to be completed.
|
||||
* @return true if yes, false otherwise
|
||||
*/
|
||||
public boolean isResponseAllowed();
|
||||
boolean isResponseAllowed();
|
||||
|
||||
/**
|
||||
* Request that a flow execution redirect be performed by the calling environment. Typically called from within a
|
||||
@@ -151,7 +151,7 @@ public interface ExternalContext {
|
||||
* @see #isResponseComplete()
|
||||
* @throws IllegalStateException if the response has completed
|
||||
*/
|
||||
public void requestFlowExecutionRedirect() throws IllegalStateException;
|
||||
void requestFlowExecutionRedirect() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Request that a flow definition redirect be performed by the calling environment. Typically called from within a
|
||||
@@ -162,7 +162,7 @@ public interface ExternalContext {
|
||||
* @param input input to pass the flow; this input is generally encoded the url to launch the flow
|
||||
* @throws IllegalStateException if the response has completed
|
||||
*/
|
||||
public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap<?> input) throws IllegalStateException;
|
||||
void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap<?> input) throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Request a redirect to an arbitrary resource location. May not be supported in some environments. Calling this
|
||||
@@ -171,7 +171,7 @@ public interface ExternalContext {
|
||||
* @param location the location of the resource to redirect to
|
||||
* @throws IllegalStateException if the response has completed
|
||||
*/
|
||||
public void requestExternalRedirect(String location) throws IllegalStateException;
|
||||
void requestExternalRedirect(String location) throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Request that the current redirect requested be sent to the client in a manner that causes the client to issue the
|
||||
@@ -181,14 +181,14 @@ public interface ExternalContext {
|
||||
* @see #requestExternalRedirect(String)
|
||||
* @throws IllegalStateException if a redirect has not been requested
|
||||
*/
|
||||
public void requestRedirectInPopup() throws IllegalStateException;
|
||||
void requestRedirectInPopup() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Called by flow artifacts such as View states and end states to indicate they handled the response, typically by
|
||||
* writing out content to the response stream. Setting this flag allows this external context to know the response
|
||||
* was handled, and that it not need to take additional response handling action itself.
|
||||
*/
|
||||
public void recordResponseComplete();
|
||||
void recordResponseComplete();
|
||||
|
||||
/**
|
||||
* Has the response been completed? Response complete status can be achieved by:
|
||||
@@ -203,7 +203,7 @@ public interface ExternalContext {
|
||||
* @see #requestExternalRedirect(String)
|
||||
* @return true if yes, false otherwise
|
||||
*/
|
||||
public boolean isResponseComplete();
|
||||
boolean isResponseComplete();
|
||||
|
||||
/**
|
||||
* Returns true if the response has been completed with flow execution redirect request.
|
||||
@@ -211,6 +211,6 @@ public interface ExternalContext {
|
||||
* @see #isResponseComplete()
|
||||
* @see #requestFlowExecutionRedirect()
|
||||
*/
|
||||
public boolean isResponseCompleteFlowExecutionRedirect();
|
||||
boolean isResponseCompleteFlowExecutionRedirect();
|
||||
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ public interface FlowUrlHandler {
|
||||
* @param request the request
|
||||
* @return the flow execution key, or null if no flow execution key is present
|
||||
*/
|
||||
public String getFlowExecutionKey(HttpServletRequest request);
|
||||
String getFlowExecutionKey(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Extract the flow id from the request.
|
||||
* @param request the request
|
||||
* @return the flow id, or null if no flow id is present
|
||||
*/
|
||||
public String getFlowId(HttpServletRequest request);
|
||||
String getFlowId(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Create a URL that when addressed will launch a new execution of a flow.
|
||||
@@ -47,7 +47,7 @@ public interface FlowUrlHandler {
|
||||
* @param request the current request
|
||||
* @return the flow definition url
|
||||
*/
|
||||
public String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, HttpServletRequest request);
|
||||
String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Create a URL that when addressed will resume an existing execution of a flow.
|
||||
@@ -55,5 +55,5 @@ public interface FlowUrlHandler {
|
||||
* @param request the current request
|
||||
* @return the flow execution url
|
||||
*/
|
||||
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request);
|
||||
String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ public interface Conversation {
|
||||
* conversation. This method can be safely called without owning the lock of this conversation.
|
||||
* @return the conversation id
|
||||
*/
|
||||
public ConversationId getId();
|
||||
ConversationId getId();
|
||||
|
||||
/**
|
||||
* Lock this conversation. May block until the lock is available, if someone else has acquired the lock.
|
||||
* @throws ConversationLockException if the lock could not be acquired
|
||||
*/
|
||||
public void lock() throws ConversationLockException;
|
||||
void lock() throws ConversationLockException;
|
||||
|
||||
/**
|
||||
* Returns the conversation attribute with the specified name. You need to acquire the lock on this conversation
|
||||
@@ -67,7 +67,7 @@ public interface Conversation {
|
||||
* @param name the attribute name
|
||||
* @return the attribute value
|
||||
*/
|
||||
public Object getAttribute(Object name);
|
||||
Object getAttribute(Object name);
|
||||
|
||||
/**
|
||||
* Puts a conversation attribute into this context. You need to acquire the lock on this conversation before calling
|
||||
@@ -75,23 +75,23 @@ public interface Conversation {
|
||||
* @param name the attribute name
|
||||
* @param value the attribute value
|
||||
*/
|
||||
public void putAttribute(Object name, Object value);
|
||||
void putAttribute(Object name, Object value);
|
||||
|
||||
/**
|
||||
* Removes a conversation attribute. You need to acquire the lock on this conversation before calling this method.
|
||||
* @param name the attribute name
|
||||
*/
|
||||
public void removeAttribute(Object name);
|
||||
void removeAttribute(Object name);
|
||||
|
||||
/**
|
||||
* Ends this conversation. This method should only be called once to terminate the conversation and cleanup any
|
||||
* allocated resources. You need to aquire the lock on this conversation before calling this method.
|
||||
*/
|
||||
public void end();
|
||||
void end();
|
||||
|
||||
/**
|
||||
* Unlock this conversation, making it available to others for manipulation.
|
||||
*/
|
||||
public void unlock();
|
||||
void unlock();
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public interface ConversationManager {
|
||||
* @return a service interface allowing access to the conversation context
|
||||
* @throws ConversationException an exception occured
|
||||
*/
|
||||
public Conversation beginConversation(ConversationParameters conversationParameters) throws ConversationException;
|
||||
Conversation beginConversation(ConversationParameters conversationParameters) throws ConversationException;
|
||||
|
||||
/**
|
||||
* Get the conversation with the provided id.
|
||||
@@ -60,7 +60,7 @@ public interface ConversationManager {
|
||||
* @return the conversation
|
||||
* @throws NoSuchConversationException the id provided was invalid
|
||||
*/
|
||||
public Conversation getConversation(ConversationId id) throws ConversationException;
|
||||
Conversation getConversation(ConversationId id) throws ConversationException;
|
||||
|
||||
/**
|
||||
* Parse the string-encoded conversationId into its object form. Essentially, the reverse of
|
||||
@@ -69,5 +69,5 @@ public interface ConversationManager {
|
||||
* @return the parsed conversation id
|
||||
* @throws ConversationException an exception occured parsing the id
|
||||
*/
|
||||
public ConversationId parseConversationId(String encodedId) throws ConversationException;
|
||||
ConversationId parseConversationId(String encodedId) throws ConversationException;
|
||||
}
|
||||
@@ -125,10 +125,7 @@ public class ContainedConversation implements Conversation, Serializable {
|
||||
// id based equality
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ContainedConversation)) {
|
||||
return false;
|
||||
}
|
||||
return this.id.equals(((ContainedConversation) obj).id);
|
||||
return obj instanceof ContainedConversation && this.id.equals(((ContainedConversation) obj).id);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
@@ -30,10 +30,10 @@ public interface ConversationLock extends Serializable {
|
||||
* Acquire the conversation lock.
|
||||
* @throws ConversationLockException if an exception is thrown attempting to acquire this lock
|
||||
*/
|
||||
public void lock() throws ConversationLockException;
|
||||
void lock() throws ConversationLockException;
|
||||
|
||||
/**
|
||||
* Release the conversation lock.
|
||||
*/
|
||||
public void unlock();
|
||||
void unlock();
|
||||
}
|
||||
@@ -41,10 +41,7 @@ public class SimpleConversationId extends ConversationId {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof SimpleConversationId)) {
|
||||
return false;
|
||||
}
|
||||
return id.equals(((SimpleConversationId) o).id);
|
||||
return o instanceof SimpleConversationId && id.equals(((SimpleConversationId) o).id);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
@@ -29,19 +29,19 @@ public interface Annotated {
|
||||
* Returns a short summary of this object, suitable for display as an icon caption or tool tip.
|
||||
* @return the caption
|
||||
*/
|
||||
public String getCaption();
|
||||
String getCaption();
|
||||
|
||||
/**
|
||||
* Returns a longer, more detailed description of this object.
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription();
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Returns a attribute map containing the attributes annotating this object. These attributes provide descriptive
|
||||
* characteristics or properties that may affect object behavior.
|
||||
* @return the attribute map
|
||||
*/
|
||||
public MutableAttributeMap<Object> getAttributes();
|
||||
MutableAttributeMap<Object> getAttributes();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,26 +34,26 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @param attributeName the attribute name
|
||||
* @return the attribute value
|
||||
*/
|
||||
public V get(String attributeName);
|
||||
V get(String attributeName);
|
||||
|
||||
/**
|
||||
* Returns the size of this map.
|
||||
* @return the number of entries in the map
|
||||
*/
|
||||
public int size();
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Is this attribute map empty with a size of 0?
|
||||
* @return true if empty, false if not
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Does the attribute with the provided name exist in this map?
|
||||
* @param attributeName the attribute name
|
||||
* @return true if so, false otherwise
|
||||
*/
|
||||
public boolean contains(String attributeName);
|
||||
boolean contains(String attributeName);
|
||||
|
||||
/**
|
||||
* Does the attribute with the provided name exist in this map and is its value of the specified required type?
|
||||
@@ -62,7 +62,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return true if so, false otherwise
|
||||
* @throws IllegalArgumentException when the value is not of the required type
|
||||
*/
|
||||
public boolean contains(String attributeName, Class<? extends V> requiredType) throws IllegalArgumentException;
|
||||
boolean contains(String attributeName, Class<? extends V> requiredType) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get an attribute value, returning the default value if no value is found.
|
||||
@@ -70,7 +70,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @param defaultValue the default value
|
||||
* @return the attribute value, falling back to the default if no such attribute exists
|
||||
*/
|
||||
public V get(String attributeName, V defaultValue);
|
||||
V get(String attributeName, V defaultValue);
|
||||
|
||||
/**
|
||||
* Get an attribute value, asserting the value is of the required type.
|
||||
@@ -79,7 +79,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the attribute value, or null if not found
|
||||
* @throws IllegalArgumentException when the value is not of the required type
|
||||
*/
|
||||
public <T extends V> T get(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
<T extends V> T get(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get an attribute value, asserting the value is of the required type and returning the default value if not found.
|
||||
@@ -89,7 +89,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the attribute value, or the default if not found
|
||||
* @throws IllegalArgumentException when the value (if found) is not of the required type
|
||||
*/
|
||||
public <T extends V> T get(String attributeName, Class<T> requiredType, T defaultValue)
|
||||
<T extends V> T get(String attributeName, Class<T> requiredType, T defaultValue)
|
||||
throws IllegalStateException;
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the attribute value
|
||||
* @throws IllegalArgumentException when the attribute is not found
|
||||
*/
|
||||
public V getRequired(String attributeName) throws IllegalArgumentException;
|
||||
V getRequired(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get the value of a required attribute and make sure it is of the required type.
|
||||
@@ -107,7 +107,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the attribute value
|
||||
* @throws IllegalArgumentException when the attribute is not found or not of the required type
|
||||
*/
|
||||
public <T extends V> T getRequired(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
<T extends V> T getRequired(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a string attribute value in the map, returning <code>null</code> if no value was found.
|
||||
@@ -115,7 +115,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the string attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a string
|
||||
*/
|
||||
public String getString(String attributeName) throws IllegalArgumentException;
|
||||
String getString(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a string attribute value in the map, returning the default value if no value was found.
|
||||
@@ -124,7 +124,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the string attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a string
|
||||
*/
|
||||
public String getString(String attributeName, String defaultValue) throws IllegalArgumentException;
|
||||
String getString(String attributeName, String defaultValue) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a string attribute value in the map, throwing an exception if the attribute is not present and of the
|
||||
@@ -133,7 +133,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the string attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or present but not a string
|
||||
*/
|
||||
public String getRequiredString(String attributeName) throws IllegalArgumentException;
|
||||
String getRequiredString(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a collection attribute value in the map.
|
||||
@@ -141,7 +141,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the collection attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a collection
|
||||
*/
|
||||
public Collection<V> getCollection(String attributeName) throws IllegalArgumentException;
|
||||
Collection<V> getCollection(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a collection attribute value in the map and make sure it is of the required type.
|
||||
@@ -150,7 +150,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the collection attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a collection of the required type
|
||||
*/
|
||||
public <T extends Collection<V>> T getCollection(String attributeName, Class<T> requiredType)
|
||||
<T extends Collection<V>> T getCollection(String attributeName, Class<T> requiredType)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -160,7 +160,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the collection attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or is present but not a collection
|
||||
*/
|
||||
public Collection<V> getRequiredCollection(String attributeName) throws IllegalArgumentException;
|
||||
Collection<V> getRequiredCollection(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a
|
||||
@@ -171,7 +171,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @throws IllegalArgumentException if the attribute is not present or is present but not a collection of the
|
||||
* required type
|
||||
*/
|
||||
public <T extends Collection<V>> T getRequiredCollection(String attributeName, Class<T> requiredType)
|
||||
<T extends Collection<V>> T getRequiredCollection(String attributeName, Class<T> requiredType)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the array attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not an array of the required type
|
||||
*/
|
||||
public <T extends V> T[] getArray(String attributeName, Class<? extends T[]> requiredType)
|
||||
<T extends V> T[] getArray(String attributeName, Class<? extends T[]> requiredType)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @throws IllegalArgumentException if the attribute is not present or is present but not a array of the required
|
||||
* type
|
||||
*/
|
||||
public <T extends V> T[] getRequiredArray(String attributeName, Class<? extends T[]> requiredType)
|
||||
<T extends V> T[] getRequiredArray(String attributeName, Class<? extends T[]> requiredType)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the number attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a number of the required type
|
||||
*/
|
||||
public <T extends Number> T getNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
<T extends Number> T getNumber(String attributeName, Class<T> requiredType) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a number attribute value in the map of the specified type, returning the default value if no value was
|
||||
@@ -214,7 +214,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the number attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a number of the required type
|
||||
*/
|
||||
public <T extends Number> T getNumber(String attributeName, Class<T> requiredType, T defaultValue)
|
||||
<T extends Number> T getNumber(String attributeName, Class<T> requiredType, T defaultValue)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -224,7 +224,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the number attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or present but not a number of the required type
|
||||
*/
|
||||
public <T extends Number> T getRequiredNumber(String attributeName, Class<T> requiredType)
|
||||
<T extends Number> T getRequiredNumber(String attributeName, Class<T> requiredType)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -233,7 +233,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the integer attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not an integer
|
||||
*/
|
||||
public Integer getInteger(String attributeName) throws IllegalArgumentException;
|
||||
Integer getInteger(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns an integer attribute value in the map, returning the default value if no value was found.
|
||||
@@ -242,7 +242,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the integer attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not an integer
|
||||
*/
|
||||
public Integer getInteger(String attributeName, Integer defaultValue) throws IllegalArgumentException;
|
||||
Integer getInteger(String attributeName, Integer defaultValue) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns an integer attribute value in the map, throwing an exception if the attribute is not present and of the
|
||||
@@ -251,7 +251,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the integer attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or present but not an integer
|
||||
*/
|
||||
public Integer getRequiredInteger(String attributeName) throws IllegalArgumentException;
|
||||
Integer getRequiredInteger(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a long attribute value in the map, returning <code>null</code> if no value was found.
|
||||
@@ -259,7 +259,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the long attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a long
|
||||
*/
|
||||
public Long getLong(String attributeName) throws IllegalArgumentException;
|
||||
Long getLong(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a long attribute value in the map, returning the default value if no value was found.
|
||||
@@ -268,7 +268,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the long attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a long
|
||||
*/
|
||||
public Long getLong(String attributeName, Long defaultValue) throws IllegalArgumentException;
|
||||
Long getLong(String attributeName, Long defaultValue) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a long attribute value in the map, throwing an exception if the attribute is not present and of the
|
||||
@@ -277,7 +277,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the long attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or present but not a long
|
||||
*/
|
||||
public Long getRequiredLong(String attributeName) throws IllegalArgumentException;
|
||||
Long getRequiredLong(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a boolean attribute value in the map, returning <code>null</code> if no value was found.
|
||||
@@ -285,7 +285,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the long attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a boolean
|
||||
*/
|
||||
public Boolean getBoolean(String attributeName) throws IllegalArgumentException;
|
||||
Boolean getBoolean(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a boolean attribute value in the map, returning the default value if no value was found.
|
||||
@@ -294,7 +294,7 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the boolean attribute value
|
||||
* @throws IllegalArgumentException if the attribute is present but not a boolean
|
||||
*/
|
||||
public Boolean getBoolean(String attributeName, Boolean defaultValue) throws IllegalArgumentException;
|
||||
Boolean getBoolean(String attributeName, Boolean defaultValue) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a boolean attribute value in the map, throwing an exception if the attribute is not present and of the
|
||||
@@ -303,13 +303,13 @@ public interface AttributeMap<V> extends MapAdaptable<String, V> {
|
||||
* @return the boolean attribute value
|
||||
* @throws IllegalArgumentException if the attribute is not present or present but is not a boolean
|
||||
*/
|
||||
public Boolean getRequiredBoolean(String attributeName) throws IllegalArgumentException;
|
||||
Boolean getRequiredBoolean(String attributeName) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a new attribute map containing the union of this map with the provided map.
|
||||
* @param attributes the map to combine with this map
|
||||
* @return a new, combined map
|
||||
*/
|
||||
public AttributeMap<V> union(AttributeMap<? extends V> attributes);
|
||||
AttributeMap<V> union(AttributeMap<? extends V> attributes);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user