No need to nest in else.
diff --git a/src/main/java/org/apache/commons/ognl/ASTAdd.java b/src/main/java/org/apache/commons/ognl/ASTAdd.java
index bcf6c9e..89885e9 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAdd.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAdd.java
@@ -98,11 +98,11 @@
{
return false;
}
- else if ( parent == null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
+ if ( parent == null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
{
return true;
}
- else if ( parent == null && String.class.isAssignableFrom( type.getGetterClass() ) )
+ if ( parent == null && String.class.isAssignableFrom( type.getGetterClass() ) )
{
return false;
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
index ac91826..316fd92 100644
--- a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
@@ -49,10 +49,7 @@
{
return "~(" + super.coerceToNumeric( source, context, children[0] ) + ")";
}
- else
- {
- return "~(" + source + ")";
- }
+ return "~(" + source + ")";
}
public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
diff --git a/src/main/java/org/apache/commons/ognl/ASTConst.java b/src/main/java/org/apache/commons/ognl/ASTConst.java
index 45b0857..8139863 100644
--- a/src/main/java/org/apache/commons/ognl/ASTConst.java
+++ b/src/main/java/org/apache/commons/ognl/ASTConst.java
@@ -86,7 +86,7 @@
context.setCurrentType( null );
return "null";
}
- else if ( value == null )
+ if ( value == null )
{
context.setCurrentType( null );
return "";
@@ -101,14 +101,14 @@
return value.toString();
}
- else if ( value != null && Number.class.isAssignableFrom( value.getClass() ) )
+ if ( value != null && Number.class.isAssignableFrom( value.getClass() ) )
{
context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( value.getClass() ) );
context.setCurrentObject( value );
return value.toString();
}
- else if ( !( parent != null
+ if ( !( parent != null
&& value != null
&& NumericExpression.class.isAssignableFrom( parent.getClass() ) )
&& String.class.isAssignableFrom( value.getClass() ) )
@@ -121,7 +121,7 @@
return retval.toString();
}
- else if ( Character.class.isInstance( value ) )
+ if ( Character.class.isInstance( value ) )
{
Character val = (Character) value;
diff --git a/src/main/java/org/apache/commons/ognl/ASTCtor.java b/src/main/java/org/apache/commons/ognl/ASTCtor.java
index 17bfe4b..b3d33cc 100644
--- a/src/main/java/org/apache/commons/ognl/ASTCtor.java
+++ b/src/main/java/org/apache/commons/ognl/ASTCtor.java
@@ -87,52 +87,48 @@
}
if ( isArray )
{
- if ( args.length == 1 )
+ if ( args.length != 1 ) {
+ throw new OgnlException( "only expect array size or fixed initializer list" );
+ }
+ try
{
- try
+ Class componentClass = OgnlRuntime.classForName( context, className );
+ List sourceList = null;
+ int size;
+
+ if ( args[0] instanceof List )
{
- Class componentClass = OgnlRuntime.classForName( context, className );
- List sourceList = null;
- int size;
+ sourceList = (List) args[0];
+ size = sourceList.size();
+ }
+ else
+ {
+ size = (int) OgnlOps.longValue( args[0] );
+ }
+ result = Array.newInstance( componentClass, size );
+ if ( sourceList != null )
+ {
+ TypeConverter converter = context.getTypeConverter();
- if ( args[0] instanceof List )
+ for ( int i = 0, icount = sourceList.size(); i < icount; i++ )
{
- sourceList = (List) args[0];
- size = sourceList.size();
- }
- else
- {
- size = (int) OgnlOps.longValue( args[0] );
- }
- result = Array.newInstance( componentClass, size );
- if ( sourceList != null )
- {
- TypeConverter converter = context.getTypeConverter();
+ Object o = sourceList.get( i );
- for ( int i = 0, icount = sourceList.size(); i < icount; i++ )
+ if ( ( o == null ) || componentClass.isInstance( o ) )
{
- Object o = sourceList.get( i );
-
- if ( ( o == null ) || componentClass.isInstance( o ) )
- {
- Array.set( result, i, o );
- }
- else
- {
- Array.set( result, i,
- converter.convertValue( context, null, null, null, o, componentClass ) );
- }
+ Array.set( result, i, o );
+ }
+ else
+ {
+ Array.set( result, i,
+ converter.convertValue( context, null, null, null, o, componentClass ) );
}
}
}
- catch ( ClassNotFoundException ex )
- {
- throw new OgnlException( "array component class '" + className + "' not found", ex );
- }
}
- else
+ catch ( ClassNotFoundException ex )
{
- throw new OgnlException( "only expect array size or fixed initializer list" );
+ throw new OgnlException( "array component class '" + className + "' not found", ex );
}
}
else
diff --git a/src/main/java/org/apache/commons/ognl/ASTMethod.java b/src/main/java/org/apache/commons/ognl/ASTMethod.java
index c213f59..4b369aa 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMethod.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMethod.java
@@ -169,10 +169,7 @@
return "";
}
- else
- {
- getterClass = method.getReturnType();
- }
+ getterClass = method.getReturnType();
// TODO: This is a hacky workaround until javassist supports varargs method invocations
boolean varArgs = method.isVarArgs();
diff --git a/src/main/java/org/apache/commons/ognl/ASTNegate.java b/src/main/java/org/apache/commons/ognl/ASTNegate.java
index 71161a2..dd6f2fe 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNegate.java
@@ -49,10 +49,7 @@
{
return "-" + source;
}
- else
- {
- return "-(" + source + ")";
- }
+ return "-(" + source + ")";
}
public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
diff --git a/src/main/java/org/apache/commons/ognl/ASTProperty.java b/src/main/java/org/apache/commons/ognl/ASTProperty.java
index 5243baf..9825d80 100644
--- a/src/main/java/org/apache/commons/ognl/ASTProperty.java
+++ b/src/main/java/org/apache/commons/ognl/ASTProperty.java
@@ -189,26 +189,23 @@
return "." + m.getName() + "(" + srcString + ")";
}
- else
+ PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
+
+ // System.out.println("child value : " + _children[0].getValue(context, context.getCurrentObject())
+ // + " using propaccessor " + p.getClass().getName()
+ // + " and srcString " + srcString + " on target: " + target);
+
+ Object currentObject = context.getCurrentObject();
+ if ( ASTConst.class.isInstance( child ) && Number.class.isInstance( currentObject ) )
{
- PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
-
- // System.out.println("child value : " + _children[0].getValue(context, context.getCurrentObject())
- // + " using propaccessor " + p.getClass().getName()
- // + " and srcString " + srcString + " on target: " + target);
-
- Object currentObject = context.getCurrentObject();
- if ( ASTConst.class.isInstance( child ) && Number.class.isInstance( currentObject ) )
- {
- context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
- }
- Object indexValue = propertyAccessor.getProperty( context, target, value );
- result = propertyAccessor.getSourceAccessor( context, target, srcString );
- getterClass = context.getCurrentType();
- context.setCurrentObject( indexValue );
-
- return result;
+ context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
}
+ Object indexValue = propertyAccessor.getProperty( context, target, value );
+ result = propertyAccessor.getSourceAccessor( context, target, srcString );
+ getterClass = context.getCurrentType();
+ context.setCurrentObject( indexValue );
+
+ return result;
}
String name = ( (ASTConst) child ).getValue().toString();
@@ -236,14 +233,10 @@
}
else
{
- if ( pd instanceof ObjectIndexedPropertyDescriptor )
- {
- m = ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedReadMethod();
- }
- else
- {
+ if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
throw new OgnlException( "property '" + name + "' is not an indexed property" );
}
+ m = ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedReadMethod();
}
if ( parent == null )
@@ -383,7 +376,7 @@
{
return ( (IndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
}
- else if ( ObjectIndexedPropertyDescriptor.class.isInstance( pd ) )
+ if ( ObjectIndexedPropertyDescriptor.class.isInstance( pd ) )
{
return ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
}
@@ -425,46 +418,7 @@
// System.out.println("astproperty setter using indexed value " + value + " and srcString: " +
// srcString);
- if ( context.get( "_indexedMethod" ) != null )
- {
- m = (Method) context.remove( "_indexedMethod" );
- PropertyDescriptor pd = (PropertyDescriptor) context.remove( "_indexedDescriptor" );
-
- boolean lastChild = lastChild( context );
- if ( lastChild )
- {
- m = getIndexedWriteMethod( pd );
-
- if ( m == null )
- {
- throw new UnsupportedCompilationException(
- "Indexed property has no corresponding write method." );
- }
- }
-
- setterClass = m.getParameterTypes()[0];
-
- Object indexedValue = null;
- if ( !lastChild )
- {
- indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
- }
- context.setCurrentType( setterClass );
- context.setCurrentAccessor(
- OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
-
- if ( !lastChild )
- {
- context.setCurrentObject( indexedValue );
- return "." + m.getName() + "(" + srcString + ")";
- }
- else
- {
- return "." + m.getName() + "(" + srcString + ", $3)";
- }
- }
- else
- {
+ if ( context.get( "_indexedMethod" ) == null ) {
PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
Object currentObject = context.getCurrentObject();
@@ -496,6 +450,38 @@
*/
return result;
}
+ m = (Method) context.remove( "_indexedMethod" );
+ PropertyDescriptor pd = (PropertyDescriptor) context.remove( "_indexedDescriptor" );
+
+ boolean lastChild = lastChild( context );
+ if ( lastChild )
+ {
+ m = getIndexedWriteMethod( pd );
+
+ if ( m == null )
+ {
+ throw new UnsupportedCompilationException(
+ "Indexed property has no corresponding write method." );
+ }
+ }
+
+ setterClass = m.getParameterTypes()[0];
+
+ Object indexedValue = null;
+ if ( !lastChild )
+ {
+ indexedValue = OgnlRuntime.callMethod( context, target, m.getName(), new Object[]{ value } );
+ }
+ context.setCurrentType( setterClass );
+ context.setCurrentAccessor(
+ OgnlRuntime.getCompiler( context ).getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
+
+ if ( !lastChild )
+ {
+ context.setCurrentObject( indexedValue );
+ return "." + m.getName() + "(" + srcString + ")";
+ }
+ return "." + m.getName() + "(" + srcString + ", $3)";
}
String name = ( (ASTConst) child ).getValue().toString();
@@ -532,16 +518,12 @@
}
else
{
- if ( pd instanceof ObjectIndexedPropertyDescriptor )
- {
- ObjectIndexedPropertyDescriptor opd = (ObjectIndexedPropertyDescriptor) pd;
-
- m = lastChild( context ) ? opd.getIndexedWriteMethod() : opd.getIndexedReadMethod();
- }
- else
- {
+ if ( !(pd instanceof ObjectIndexedPropertyDescriptor) ) {
throw new OgnlException( "property '" + name + "' is not an indexed property" );
}
+ ObjectIndexedPropertyDescriptor opd = (ObjectIndexedPropertyDescriptor) pd;
+
+ m = lastChild( context ) ? opd.getIndexedWriteMethod() : opd.getIndexedReadMethod();
}
if ( parent == null )
diff --git a/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java b/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
index 7dc07f5..c747749 100644
--- a/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
+++ b/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
@@ -66,10 +66,7 @@
{
return "";
}
- else
- {
- return ExpressionCompiler.getRootExpression( this, target, context );
- }
+ return ExpressionCompiler.getRootExpression( this, target, context );
}
public String toSetSourceString( OgnlContext context, Object target )
@@ -78,10 +75,7 @@
{
return "";
}
- else
- {
- return "$3";
- }
+ return "$3";
}
public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data )
diff --git a/src/main/java/org/apache/commons/ognl/ASTStaticField.java b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
index 231e904..7357b93 100644
--- a/src/main/java/org/apache/commons/ognl/ASTStaticField.java
+++ b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
@@ -130,16 +130,13 @@
{
return clazz;
}
- else if ( clazz.isEnum() )
+ if ( clazz.isEnum() )
{
return clazz;
}
- else
- {
- Field field = clazz.getField( fieldName );
+ Field field = clazz.getField( fieldName );
- return field.getType();
- }
+ return field.getType();
}
catch ( ClassNotFoundException e )
{
diff --git a/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
index 82ed58e..ca6094f 100644
--- a/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
@@ -77,16 +77,12 @@
}
if ( result == null )
{
- if ( index instanceof Number )
- {
- int i = ( (Number) index ).intValue();
-
- result = ( i >= 0 ) ? Array.get( target, i ) : null;
- }
- else
- {
+ if ( !(index instanceof Number) ) {
throw new NoSuchPropertyException( target, index );
}
+ int i = ( (Number) index ).intValue();
+
+ result = ( i >= 0 ) ? Array.get( target, i ) : null;
}
}
return result;
@@ -130,14 +126,10 @@
}
else
{
- if ( name instanceof String )
- {
- super.setProperty( context, target, name, value );
- }
- else
- {
+ if ( !(name instanceof String) ) {
throw new NoSuchPropertyException( target, name );
}
+ super.setProperty( context, target, name, value );
}
}
diff --git a/src/main/java/org/apache/commons/ognl/BooleanExpression.java b/src/main/java/org/apache/commons/ognl/BooleanExpression.java
index 3288e22..7dd947f 100644
--- a/src/main/java/org/apache/commons/ognl/BooleanExpression.java
+++ b/src/main/java/org/apache/commons/ognl/BooleanExpression.java
@@ -89,7 +89,7 @@
{
return "false";
}
- else if ( "(true)".equals( ret ) )
+ if ( "(true)".equals( ret ) )
{
return "true";
}
diff --git a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
index af16434..833ab5e 100644
--- a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
@@ -127,17 +127,17 @@
context.setCurrentType( int.class );
return ".size()";
}
- else if ( "keys".equals( key ) || "keySet".equals( key ) )
+ if ( "keys".equals( key ) || "keySet".equals( key ) )
{
context.setCurrentType( Set.class );
return ".keySet()";
}
- else if ( "values".equals( key ) )
+ if ( "values".equals( key ) )
{
context.setCurrentType( Collection.class );
return ".values()";
}
- else if ( "isEmpty".equals( key ) )
+ if ( "isEmpty".equals( key ) )
{
context.setCurrentType( boolean.class );
return ".isEmpty()";
diff --git a/src/main/java/org/apache/commons/ognl/OgnlOps.java b/src/main/java/org/apache/commons/ognl/OgnlOps.java
index c75ed2f..6254e20 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlOps.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlOps.java
@@ -873,22 +873,18 @@
}
return Math.max( DOUBLE, t1 );
}
- else if ( t2 >= MIN_REAL_TYPE )
- {
- if ( t1 < INT )
- {
- return t2;
- }
- if ( t1 == BIGINT )
- {
- return BIGDEC;
- }
- return Math.max( DOUBLE, t2 );
- }
- else
- {
+ if ( t2 < MIN_REAL_TYPE ) {
return Math.max( t1, t2 );
}
+ if ( t1 < INT )
+ {
+ return t2;
+ }
+ if ( t1 == BIGINT )
+ {
+ return BIGDEC;
+ }
+ return Math.max( DOUBLE, t2 );
}
/**
diff --git a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
index e670817..755adea 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
@@ -508,7 +508,7 @@
{
return Boolean.TYPE;
}
- else if ( clazz.getSuperclass() == Number.class )
+ if ( clazz.getSuperclass() == Number.class )
{
if ( clazz == Integer.class )
{
@@ -629,11 +629,11 @@
{
return true;
}
- else if ( class1.isAssignableFrom( class2 ) )
+ if ( class1.isAssignableFrom( class2 ) )
{
return false;
}
- else if ( class2.isAssignableFrom( class1 ) )
+ if ( class2.isAssignableFrom( class1 ) )
{
return true;
}
@@ -1071,21 +1071,17 @@
}
if ( methodValue == null )
{
- if ( method != null )
- {
- try
- {
- methodValue = invokeMethod( target, method, NoArguments );
- }
- catch ( InvocationTargetException ex )
- {
- throw new OgnlException( propertyName, ex.getTargetException() );
- }
- }
- else
- {
+ if ( method == null ) {
throw new NoSuchMethodException( propertyName );
}
+ try
+ {
+ methodValue = invokeMethod( target, method, NoArguments );
+ }
+ catch ( InvocationTargetException ex )
+ {
+ throw new OgnlException( propertyName, ex.getTargetException() );
+ }
}
return methodValue;
}
@@ -1203,16 +1199,12 @@
{
Object state;
- if ( !Modifier.isStatic( field.getModifiers() ) )
- {
- state = context.getMemberAccess().setup( context, target, field, propertyName );
- result = field.get( target );
- context.getMemberAccess().restore( context, target, field, propertyName, state );
- }
- else
- {
+ if ( Modifier.isStatic( field.getModifiers() ) ) {
throw new NoSuchFieldException( propertyName );
}
+ state = context.getMemberAccess().setup( context, target, field, propertyName );
+ result = field.get( target );
+ context.getMemberAccess().restore( context, target, field, propertyName, state );
}
catch ( IllegalAccessException ex )
@@ -1292,20 +1284,17 @@
{
return clazz;
}
- else if ( clazz.isEnum() )
+ if ( clazz.isEnum() )
{
return Enum.valueOf( (Class<? extends Enum>) clazz, fieldName );
}
- else
+ Field field = clazz.getField( fieldName );
+ if ( !Modifier.isStatic(field.getModifiers()) )
{
- Field field = clazz.getField( fieldName );
- if ( !Modifier.isStatic(field.getModifiers()) )
- {
- throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
- }
-
- return field.get( null );
+ throw new OgnlException( "Field " + fieldName + " of class " + className + " is not static" );
}
+
+ return field.get( null );
}
catch ( ClassNotFoundException e )
{
@@ -1658,14 +1647,10 @@
}
else
{
- if ( propertyDescriptor instanceof ObjectIndexedPropertyDescriptor )
- {
- method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
- }
- else
- {
+ if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
throw new OgnlException( "property '" + name + "' is not an indexed property" );
}
+ method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedReadMethod();
}
return callMethod( context, source, method.getName(), args );
@@ -1697,14 +1682,10 @@
}
else
{
- if ( propertyDescriptor instanceof ObjectIndexedPropertyDescriptor )
- {
- method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
- }
- else
- {
+ if ( !(propertyDescriptor instanceof ObjectIndexedPropertyDescriptor) ) {
throw new OgnlException( "property '" + name + "' is not an indexed property" );
}
+ method = ( (ObjectIndexedPropertyDescriptor) propertyDescriptor ).getIndexedWriteMethod();
}
callMethod( context, source, method.getName(), args );
@@ -1866,13 +1847,13 @@
{
return methodDescriptor.getMethod();
}
- else if ( numParms < 0 )
+ if ( numParms < 0 )
{
if ( methodName.equals( name ) )
{
return methodDescriptor.getMethod();
}
- else if ( method == null || ( method.getParameterTypes().length > methodParamLen ) )
+ if ( method == null || ( method.getParameterTypes().length > methodParamLen ) )
{
method = methodDescriptor.getMethod();
}
@@ -1899,7 +1880,8 @@
if ( numParms > 0 && methodDescriptor.getMethod().getParameterTypes().length == numParms )
{
return methodDescriptor.getMethod();
- } else if ( (numParms < 0) && (method == null || ( method.getParameterTypes().length
+ }
+ if ( (numParms < 0) && (method == null || ( method.getParameterTypes().length
> methodDescriptor.getMethod().getParameterTypes().length )) )
{
method = methodDescriptor.getMethod();
@@ -1958,7 +1940,7 @@
{
return method.getMethod();
}
- else if ( numParms < 0 )
+ if ( numParms < 0 )
{
return method.getMethod();
}
@@ -1984,7 +1966,7 @@
{
return cmethod;
}
- else if ( numParms < 0 )
+ if ( numParms < 0 )
{
return cmethod;
}
diff --git a/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java b/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
index e74fe11..3eed6a8 100644
--- a/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
+++ b/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
@@ -265,7 +265,7 @@
{
return intface.getName();
}
- else if ( intface.getName().indexOf( "Iterator" ) > 0 )
+ if ( intface.getName().indexOf( "Iterator" ) > 0 )
{
return intface.getName();
}
@@ -428,19 +428,19 @@
{
return List.class;
}
- else if ( Iterator.class.isAssignableFrom( anIntf ) )
+ if ( Iterator.class.isAssignableFrom( anIntf ) )
{
return Iterator.class;
}
- else if ( Map.class.isAssignableFrom( anIntf ) )
+ if ( Map.class.isAssignableFrom( anIntf ) )
{
return Map.class;
}
- else if ( Set.class.isAssignableFrom( anIntf ) )
+ if ( Set.class.isAssignableFrom( anIntf ) )
{
return Set.class;
}
- else if ( Collection.class.isAssignableFrom( anIntf ) )
+ if ( Collection.class.isAssignableFrom( anIntf ) )
{
return Collection.class;
}
diff --git a/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java b/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
index f3a29c3..bde12ce 100644
--- a/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
+++ b/src/main/java/org/apache/commons/ognl/internal/ClassCacheHandler.java
@@ -53,29 +53,25 @@
for ( Class<?> clazz = forClass; clazz != null; clazz = clazz.getSuperclass() )
{
answer = handlers.get( clazz );
- if ( answer == null )
- {
- Class<?>[] interfaces = clazz.getInterfaces();
- for ( Class<?> iface : interfaces )
- {
- answer = handlers.get( iface );
- if ( answer == null )
- {
- /* Try super-interfaces */
- answer = getHandler( iface, handlers );
- }
- if ( answer != null )
- {
- keyFound = iface;
- break outer;
- }
- }
- }
- else
- {
+ if ( answer != null ) {
keyFound = clazz;
break;
}
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for ( Class<?> iface : interfaces )
+ {
+ answer = handlers.get( iface );
+ if ( answer == null )
+ {
+ /* Try super-interfaces */
+ answer = getHandler( iface, handlers );
+ }
+ if ( answer != null )
+ {
+ keyFound = iface;
+ break outer;
+ }
+ }
}
}
if ( answer != null && keyFound != forClass )
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
index 68086c4..989e10b 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java
@@ -41,18 +41,12 @@
{
return true;
}
- else
+ boolean isStatic = Modifier.isStatic( method.getModifiers() );
+ if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC )
{
- boolean isStatic = Modifier.isStatic( method.getModifiers() );
- if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC )
- {
- return isStatic;
- }
- else
- {
- return !isStatic;
- }
+ return isStatic;
}
+ return !isStatic;
}
}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
index 5155458..181ae8b 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodAccessCacheEntryFactory.java
@@ -44,20 +44,13 @@
{
final boolean notPublic = !Modifier.isPublic( method.getModifiers() ) || !Modifier.isPublic(
method.getDeclaringClass().getModifiers() );
- if ( notPublic )
- {
- if ( !method.isAccessible() )
- {
- return INACCESSIBLE_NON_PUBLIC_METHOD;
- }
- else
- {
- return ACCESSIBLE_NON_PUBLIC_METHOD;
- }
- }
- else
- {
+ if ( !notPublic ) {
return PUBLIC_METHOD;
}
+ if ( !method.isAccessible() )
+ {
+ return INACCESSIBLE_NON_PUBLIC_METHOD;
+ }
+ return ACCESSIBLE_NON_PUBLIC_METHOD;
}
}
diff --git a/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java b/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
index 39fc82d..8a39e4f 100644
--- a/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
+++ b/src/test/java/org/apache/commons/ognl/test/OgnlTestCase.java
@@ -233,14 +233,10 @@
ex = (Exception) ex.getCause();
}
- if ( testedResult instanceof Class )
- {
- Assert.assertTrue( Exception.class.isAssignableFrom( (Class<?>) testedResult ) );
- }
- else
- {
+ if ( !(testedResult instanceof Class) ) {
throw ex;
}
+ Assert.assertTrue( Exception.class.isAssignableFrom( (Class<?>) testedResult ) );
}
}
diff --git a/src/test/java/org/apache/commons/ognl/test/Performance.java b/src/test/java/org/apache/commons/ognl/test/Performance.java
index 798b676..697cf94 100644
--- a/src/test/java/org/apache/commons/ognl/test/Performance.java
+++ b/src/test/java/org/apache/commons/ognl/test/Performance.java
@@ -319,17 +319,11 @@
{
return ( t1 - t0 ) >= MAX_TIME;
}
- else
+ if ( ITERATIONS_MODE )
{
- if ( ITERATIONS_MODE )
- {
- return _iterations >= MAX_ITERATIONS;
- }
- else
- {
- throw new RuntimeException( "no maximums specified" );
- }
+ return _iterations >= MAX_ITERATIONS;
}
+ throw new RuntimeException( "no maximums specified" );
}
/*