Merge pull request #35 from apache/dependabot/maven/org.easymock-easymock-4.3
Bump easymock from 4.2 to 4.3
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 85e85c8..f0f1410 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -32,16 +32,11 @@
steps:
- uses: actions/checkout@v2.3.4
- - uses: actions/cache@v2.1.5
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: ${{ matrix.java }}
+ cache: 'maven'
- name: Build with Maven
run: mvn -V -Ddoclint=all --file pom.xml --no-transfer-progress
diff --git a/.travis.yml b/.travis.yml
index cc26727..cefab1c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@
jdk:
- openjdk8
- openjdk11
- - openjdk15
+ - openjdk16
- openjdk-ea
matrix:
diff --git a/pom.xml b/pom.xml
index 3410223..94a693d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -190,7 +190,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -213,7 +213,7 @@
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
- <version>3.2.18</version>
+ <version>3.2.21</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -398,7 +398,7 @@
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
- <version>3.14.0</version>
+ <version>3.15.0</version>
<configuration>
<targetJdk>${maven.compile.target}</targetJdk>
</configuration>
@@ -481,7 +481,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.30</version>
+ <version>1.7.32</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -555,7 +555,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
- <version>3.0.0</version>
<executions>
<execution>
<id>prepare-checkout</id>
@@ -566,23 +565,18 @@
<configuration>
<tasks>
<exec executable="svn">
- <arg line="checkout ${commons.scmPubUrl} ${commons.scmPubCheckoutDirectory}" />
+ <arg line="checkout --depth immediates ${commons.scmPubUrl} ${commons.scmPubCheckoutDirectory}" />
</exec>
- <!-- in case of paths to ignore (added manually) -->
- <!--
+
<exec executable="svn">
- <arg line="update - -set-depth exclude ${commons.scmPubCheckoutDirectory}/javadocs" />
+ <arg line="update --set-depth exclude ${commons.scmPubCheckoutDirectory}/javadocs" />
</exec>
<pathconvert pathsep=" " property="dirs">
<dirset dir="${commons.scmPubCheckoutDirectory}" includes="*" />
</pathconvert>
<exec executable="svn">
- <arg line="update - -set-depth infinity ${dirs}" />
- </exec>
- -->
- <exec executable="svn">
- <arg line="update" />
+ <arg line="update --set-depth infinity ${dirs}" />
</exec>
</tasks>
</configuration>
diff --git a/src/main/java/org/apache/commons/ognl/ASTAdd.java b/src/main/java/org/apache/commons/ognl/ASTAdd.java
index 89885e9..04a4427 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAdd.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAdd.java
@@ -143,7 +143,7 @@
{
try
{
- String result = "";
+ StringBuilder result = new StringBuilder();
NodeType lastType = null;
// go through once to determine the ultimate type
@@ -159,7 +159,7 @@
{
aChildren.toGetSourceString( context, target );
- if ( NodeType.class.isInstance( aChildren ) && ( (NodeType) aChildren ).getGetterClass() != null
+ if ( aChildren instanceof NodeType && ( (NodeType) aChildren ).getGetterClass() != null
&& isWider( (NodeType) aChildren, lastType ) )
{
lastType = (NodeType) aChildren;
@@ -183,13 +183,13 @@
{
if ( i > 0 )
{
- result += " " + getExpressionOperator( i ) + " ";
+ result.append(" ").append(getExpressionOperator(i)).append(" ");
}
String expr = children[i].toGetSourceString( context, target );
if ( ( "null".equals( expr ) )
- || ( !ASTConst.class.isInstance( children[i] )
+ || ( !(children[i] instanceof ASTConst)
&& ( expr == null || expr.trim().isEmpty() ) ) )
{
expr = "null";
@@ -198,12 +198,12 @@
// System.out.println("astadd child class: " + _children[i].getClass().getName() +
// " and return expr: " + expr);
- if ( ASTProperty.class.isInstance( children[i] ) )
+ if (children[i] instanceof ASTProperty)
{
expr = ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + expr;
context.setCurrentAccessor( context.getRoot().getClass() );
}
- else if ( ASTMethod.class.isInstance( children[i] ) )
+ else if (children[i] instanceof ASTMethod)
{
String chain = (String) context.get( "_currentChain" );
String rootExpr =
@@ -222,17 +222,17 @@
context.setCurrentAccessor( context.getRoot().getClass() );
}
- else if ( ExpressionNode.class.isInstance( children[i] ) )
+ else if (children[i] instanceof ExpressionNode)
{
expr = "(" + expr + ")";
}
- else if ( ( parent == null || !ASTChain.class.isInstance( parent ) )
- && ASTChain.class.isInstance( children[i] ) )
+ else if ( ( parent == null || !(parent instanceof ASTChain))
+ && children[i] instanceof ASTChain)
{
String rootExpr =
ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context );
- if ( !ASTProperty.class.isInstance( children[i].jjtGetChild( 0 ) ) && rootExpr.endsWith( ")" )
+ if ( !(children[i].jjtGetChild(0) instanceof ASTProperty) && rootExpr.endsWith( ")" )
&& expr.startsWith( ")" ) )
{
expr = expr.substring( 1 );
@@ -253,7 +253,7 @@
// turn quoted characters into quoted strings
if ( context.getCurrentType() != null && context.getCurrentType() == Character.class
- && ASTConst.class.isInstance( children[i] ) )
+ && children[i] instanceof ASTConst)
{
expr = expr.replace( "'", "\"" );
context.setCurrentType( String.class );
@@ -262,14 +262,14 @@
{
if ( !ASTVarRef.class.isAssignableFrom( children[i].getClass() )
- && !ASTProperty.class.isInstance( children[i] )
- && !ASTMethod.class.isInstance( children[i] )
- && !ASTSequence.class.isInstance( children[i] )
- && !ASTChain.class.isInstance( children[i] )
+ && !(children[i] instanceof ASTProperty)
+ && !(children[i] instanceof ASTMethod)
+ && !(children[i] instanceof ASTSequence)
+ && !(children[i] instanceof ASTChain)
&& !NumericExpression.class.isAssignableFrom( children[i].getClass() )
- && !ASTStaticField.class.isInstance( children[i] )
- && !ASTStaticMethod.class.isInstance( children[i] )
- && !ASTTest.class.isInstance( children[i] ) )
+ && !(children[i] instanceof ASTStaticField)
+ && !(children[i] instanceof ASTStaticMethod)
+ && !(children[i] instanceof ASTTest))
{
if ( lastType != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
{
@@ -282,7 +282,7 @@
}
}
- result += expr;
+ result.append(expr);
// hanlde addition for numeric types when applicable or just string concatenation
@@ -292,16 +292,16 @@
{
if ( context.getCurrentType() != null
&& Number.class.isAssignableFrom( context.getCurrentType() )
- && !ASTMethod.class.isInstance( children[i] ) )
+ && !(children[i] instanceof ASTMethod))
{
- if ( ASTVarRef.class.isInstance( children[i] )
- || ASTProperty.class.isInstance( children[i] )
- || ASTChain.class.isInstance( children[i] ) )
+ if ( children[i] instanceof ASTVarRef
+ || children[i] instanceof ASTProperty
+ || children[i] instanceof ASTChain)
{
- result += ".";
+ result.append(".");
}
- result += OgnlRuntime.getNumericValueGetter( context.getCurrentType() );
+ result.append(OgnlRuntime.getNumericValueGetter(context.getCurrentType()));
context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( context.getCurrentType() ) );
}
}
@@ -335,7 +335,7 @@
throw OgnlOps.castToRuntime( t );
}
- return result;
+ return result.toString();
}
catch ( Throwable t )
diff --git a/src/main/java/org/apache/commons/ognl/ASTAssign.java b/src/main/java/org/apache/commons/ognl/ASTAssign.java
index b394435..7a6d3aa 100644
--- a/src/main/java/org/apache/commons/ognl/ASTAssign.java
+++ b/src/main/java/org/apache/commons/ognl/ASTAssign.java
@@ -53,7 +53,7 @@
String first = children[0].toGetSourceString( context, target );
String second = "";
- if ( ASTProperty.class.isInstance( children[1] ) )
+ if (children[1] instanceof ASTProperty)
{
second += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
}
@@ -79,8 +79,8 @@
Object.class );
}
- if ( NodeType.class.isInstance( children[1] ) && !ASTProperty.class.isInstance( children[1] )
- && ( (NodeType) children[1] ).getGetterClass() != null && !OrderedReturn.class.isInstance( children[1] ) )
+ if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
+ && ( (NodeType) children[1] ).getGetterClass() != null && !(children[1] instanceof OrderedReturn))
{
second = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + second + ")";
@@ -113,7 +113,7 @@
result += children[0].toSetSourceString( context, target );
- if ( ASTProperty.class.isInstance( children[1] ) )
+ if (children[1] instanceof ASTProperty)
{
result += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
}
@@ -133,7 +133,7 @@
value = seq.getLastExpression();
}
- if ( NodeType.class.isInstance( children[1] ) && !ASTProperty.class.isInstance( children[1] )
+ if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
&& ( (NodeType) children[1] ).getGetterClass() != null )
{
diff --git a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
index 316fd92..f612e45 100644
--- a/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
@@ -45,7 +45,7 @@
{
String source = children[0].toGetSourceString( context, target );
- if ( !ASTBitNegate.class.isInstance( children[0] ) )
+ if ( !(children[0] instanceof ASTBitNegate))
{
return "~(" + super.coerceToNumeric( source, context, children[0] ) + ")";
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTChain.java b/src/main/java/org/apache/commons/ognl/ASTChain.java
index 8ca6e3c..8344376 100644
--- a/src/main/java/org/apache/commons/ognl/ASTChain.java
+++ b/src/main/java/org/apache/commons/ognl/ASTChain.java
@@ -295,22 +295,22 @@
// System.out.println("astchain child returned >> " + value + " <<");
- if ( ASTCtor.class.isInstance( child ) )
+ if (child instanceof ASTCtor)
{
constructor = true;
}
- if ( NodeType.class.isInstance( child ) && ( (NodeType) child ).getGetterClass() != null )
+ if ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null )
{
lastType = (NodeType) child;
}
// System.out.println("Astchain i: " + i + " currentobj : " + context.getCurrentObject() +
// " and root: " + context.getRoot());
- if ( !ASTVarRef.class.isInstance( child ) && !constructor && !(
- OrderedReturn.class.isInstance( child )
+ if ( !(child instanceof ASTVarRef) && !constructor && !(
+ child instanceof OrderedReturn
&& ( (OrderedReturn) child ).getLastExpression() != null ) && ( parent == null
- || !ASTSequence.class.isInstance( parent ) ) )
+ || !(parent instanceof ASTSequence)) )
{
value = OgnlRuntime.getCompiler( context ).castExpression( context, child, value );
}
@@ -321,7 +321,7 @@
* context.getPreviousType() + " prev accessor " + context.getPreviousAccessor());
*/
- if ( OrderedReturn.class.isInstance( child )
+ if ( child instanceof OrderedReturn
&& ( (OrderedReturn) child ).getLastExpression() != null )
{
ordered = true;
@@ -343,8 +343,8 @@
lastExpression = context.remove( ExpressionCompiler.PRE_CAST ) + lastExpression;
}
}
- else if ( ASTOr.class.isInstance( child ) || ASTAnd.class.isInstance( child )
- || ASTCtor.class.isInstance( child ) || ( ASTStaticField.class.isInstance( child )
+ else if ( child instanceof ASTOr || child instanceof ASTAnd
+ || child instanceof ASTCtor || ( child instanceof ASTStaticField
&& parent == null ) )
{
context.put( "_noRoot", "true" );
@@ -403,7 +403,7 @@
{
if ( ( children != null ) && ( children.length > 0 ) )
{
- if ( ASTConst.class.isInstance( children[0] ) )
+ if (children[0] instanceof ASTConst)
{
throw new UnsupportedCompilationException( "Can't modify constant values." );
}
@@ -423,22 +423,22 @@
// System.out.println("astchain setter child returned >> " + value + " <<");
- if ( ASTCtor.class.isInstance( children[i] ) )
+ if (children[i] instanceof ASTCtor)
{
constructor = true;
}
- if ( NodeType.class.isInstance( children[i] )
+ if ( children[i] instanceof NodeType
&& ( (NodeType) children[i] ).getGetterClass() != null )
{
lastType = (NodeType) children[i];
}
- if ( !ASTVarRef.class.isInstance( children[i] )
+ if ( !(children[i] instanceof ASTVarRef)
&& !constructor
- && !( OrderedReturn.class.isInstance( children[i] )
+ && !( children[i] instanceof OrderedReturn
&& ( (OrderedReturn) children[i] ).getLastExpression() != null )
- && ( parent == null || !ASTSequence.class.isInstance( parent ) ) )
+ && ( parent == null || !(parent instanceof ASTSequence)) )
{
value = OgnlRuntime.getCompiler( context ).castExpression( context, children[i], value );
}
@@ -451,8 +451,8 @@
* OgnlRuntime.getCompiler().castExpression(context, _children[i], value); }
*/
- if ( ASTOr.class.isInstance( children[i] ) || ASTAnd.class.isInstance( children[i] )
- || ASTCtor.class.isInstance( children[i] ) || ASTStaticField.class.isInstance( children[i] ) )
+ if ( children[i] instanceof ASTOr || children[i] instanceof ASTAnd
+ || children[i] instanceof ASTCtor || children[i] instanceof ASTStaticField)
{
context.put( "_noRoot", "true" );
result = value;
diff --git a/src/main/java/org/apache/commons/ognl/ASTConst.java b/src/main/java/org/apache/commons/ognl/ASTConst.java
index 8139863..9813f3a 100644
--- a/src/main/java/org/apache/commons/ognl/ASTConst.java
+++ b/src/main/java/org/apache/commons/ognl/ASTConst.java
@@ -81,7 +81,7 @@
public String toGetSourceString( OgnlContext context, Object target )
{
- if ( value == null && parent != null && ExpressionNode.class.isInstance( parent ) )
+ if ( value == null && parent != null && parent instanceof ExpressionNode)
{
context.setCurrentType( null );
return "null";
@@ -95,7 +95,7 @@
getterClass = value.getClass();
Object retval = value;
- if ( parent != null && ASTProperty.class.isInstance( parent ) )
+ if ( parent != null && parent instanceof ASTProperty)
{
context.setCurrentObject( value );
@@ -121,7 +121,7 @@
return retval.toString();
}
- if ( Character.class.isInstance( value ) )
+ if (value instanceof Character)
{
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 b3d33cc..5ac44a6 100644
--- a/src/main/java/org/apache/commons/ognl/ASTCtor.java
+++ b/src/main/java/org/apache/commons/ognl/ASTCtor.java
@@ -142,7 +142,7 @@
public String toGetSourceString( OgnlContext context, Object target )
{
- String result = "new " + className;
+ StringBuilder result = new StringBuilder("new " + className);
Class clazz = null;
Object ctorValue = null;
@@ -179,30 +179,28 @@
if ( children[0] instanceof ASTConst )
{
- result = result + "[" + children[0].toGetSourceString( context, target ) + "]";
+ result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
}
- else if ( ASTProperty.class.isInstance( children[0] ) )
+ else if (children[0] instanceof ASTProperty)
{
- result =
- result + "[" + ExpressionCompiler.getRootExpression( children[0], target, context )
- + children[0].toGetSourceString( context, target ) + "]";
+ result.append("[").append(ExpressionCompiler.getRootExpression(children[0], target, context)).append(children[0].toGetSourceString(context, target)).append("]");
}
- else if ( ASTChain.class.isInstance( children[0] ) )
+ else if (children[0] instanceof ASTChain)
{
- result = result + "[" + children[0].toGetSourceString( context, target ) + "]";
+ result.append("[").append(children[0].toGetSourceString(context, target)).append("]");
}
else
{
- result = result + "[] " + children[0].toGetSourceString( context, target );
+ result.append("[] ").append(children[0].toGetSourceString(context, target));
}
}
else
{
- result = result + "(";
+ result.append("(");
if ( ( children != null ) && ( children.length > 0 ) )
{
@@ -219,7 +217,7 @@
Object objValue = children[i].getValue( context, context.getRoot() );
String value = children[i].toGetSourceString( context, target );
- if ( !ASTRootVarRef.class.isInstance( children[i] ) )
+ if ( !(children[i] instanceof ASTRootVarRef))
{
value = ExpressionCompiler.getRootExpression( children[i], target, context ) + value;
}
@@ -235,7 +233,7 @@
cast = "";
}
- if ( !ASTConst.class.isInstance( children[i] ) )
+ if ( !(children[i] instanceof ASTConst))
{
value = cast + value;
}
@@ -284,7 +282,7 @@
{
if ( i > 0 )
{
- result = result + ", ";
+ result.append(", ");
}
String value = expressions[i];
@@ -303,15 +301,15 @@
{
if ( values[i] != null && !types[i].isPrimitive() && !values[i].getClass().isArray()
- && !ASTConst.class.isInstance( children[i] ) )
+ && !(children[i] instanceof ASTConst))
{
value =
"(" + OgnlRuntime.getCompiler( context ).getInterfaceClass( values[i].getClass() ).getName()
+ ")" + value;
}
- else if ( !ASTConst.class.isInstance( children[i] )
- || ( ASTConst.class.isInstance( children[i] ) && !types[i].isPrimitive() ) )
+ else if ( !(children[i] instanceof ASTConst)
+ || ( children[i] instanceof ASTConst && !types[i].isPrimitive() ) )
{
if ( !types[i].isArray() && types[i].isPrimitive() && !ctorParamTypes[i].isPrimitive() )
@@ -329,11 +327,11 @@
}
}
- result += value;
+ result.append(value);
}
}
- result = result + ")";
+ result.append(")");
}
context.setCurrentType( ctorValue != null ? ctorValue.getClass() : clazz );
@@ -348,7 +346,7 @@
context.remove( "_ctorClass" );
- return result;
+ return result.toString();
}
public String toSetSourceString( OgnlContext context, Object target )
diff --git a/src/main/java/org/apache/commons/ognl/ASTInstanceof.java b/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
index 3b6b5d9..9eb4b5d 100644
--- a/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
+++ b/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
@@ -72,7 +72,7 @@
String ret = "";
- if ( ASTConst.class.isInstance( children[0] ) )
+ if (children[0] instanceof ASTConst)
{
ret = ( (Boolean) getValueBody( context, target ) ).toString();
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTList.java b/src/main/java/org/apache/commons/ognl/ASTList.java
index 9709c5d..eb019a7 100644
--- a/src/main/java/org/apache/commons/ognl/ASTList.java
+++ b/src/main/java/org/apache/commons/ognl/ASTList.java
@@ -66,14 +66,8 @@
public String toGetSourceString( OgnlContext context, Object target )
{
- String result = "";
- boolean array = false;
-
- if ( parent != null && ASTCtor.class.isInstance( parent ) && ( (ASTCtor) parent ).isArray() )
- {
-
- array = true;
- }
+ StringBuilder result = new StringBuilder();
+ boolean array = parent instanceof ASTCtor && ((ASTCtor) parent).isArray();
context.setCurrentType( List.class );
context.setCurrentAccessor( List.class );
@@ -84,10 +78,10 @@
{
return "java.util.Arrays.asList( new Object[0])";
}
- result += "java.util.Arrays.asList( new Object[] ";
+ result.append("java.util.Arrays.asList( new Object[] ");
}
- result += "{ ";
+ result.append("{ ");
try
{
@@ -96,7 +90,7 @@
{
if ( i > 0 )
{
- result = result + ", ";
+ result.append(", ");
}
Class prevType = context.getCurrentType();
@@ -105,7 +99,7 @@
String value = children[i].toGetSourceString( context, target );
// to undo type setting of constants when used as method parameters
- if ( ASTConst.class.isInstance( children[i] ) )
+ if (children[i] instanceof ASTConst)
{
context.setCurrentType( prevType );
@@ -124,7 +118,7 @@
cast = "";
}
- if ( !ASTConst.class.isInstance( children[i] ) )
+ if ( !(children[i] instanceof ASTConst))
{
value = cast + value;
}
@@ -170,7 +164,7 @@
+ ctorClass.getName() + ".class)", ctorClass );
}
- else if ( ( NodeType.class.isInstance( children[i] )
+ else if ( ( children[i] instanceof NodeType
&& ( (NodeType) children[i] ).getGetterClass() != null
&& Number.class.isAssignableFrom( ( (NodeType) children[i] ).getGetterClass() ) )
|| valueClass.isPrimitive() )
@@ -194,7 +188,7 @@
{
value = "null";
}
- result += value;
+ result.append(value);
}
}
@@ -206,13 +200,13 @@
context.setCurrentType( List.class );
context.setCurrentAccessor( List.class );
- result += "}";
+ result.append("}");
if ( !array )
{
- result += ")";
+ result.append(")");
}
- return result;
+ return result.toString();
}
public String toSetSourceString( OgnlContext context, Object target )
diff --git a/src/main/java/org/apache/commons/ognl/ASTMethod.java b/src/main/java/org/apache/commons/ognl/ASTMethod.java
index 4b369aa..0a52322 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMethod.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMethod.java
@@ -274,10 +274,10 @@
}
String post = "";
- String result = "." + method.getName() + "(";
+ StringBuilder result = new StringBuilder("." + method.getName() + "(");
if ( method.getReturnType() != void.class && method.getReturnType().isPrimitive() && ( parent == null
- || !ASTTest.class.isInstance( parent ) ) )
+ || !(parent instanceof ASTTest)) )
{
Class wrapper = OgnlRuntime.getPrimitiveWrapperClass( method.getReturnType() );
@@ -310,7 +310,7 @@
{
if ( i > 0 )
{
- result += ", ";
+ result.append(", ");
}
Class prevType = context.getCurrentType();
@@ -331,8 +331,8 @@
if ( parmString == null || parmString.trim().length() < 1 )
{
- if ( ASTProperty.class.isInstance( child ) || ASTMethod.class.isInstance( child )
- || ASTStaticMethod.class.isInstance( child ) || ASTChain.class.isInstance( child ) )
+ if ( child instanceof ASTProperty || child instanceof ASTMethod
+ || child instanceof ASTStaticMethod || child instanceof ASTChain)
{
throw new UnsupportedCompilationException(
"ASTMethod setter child returned null from a sub property expression." );
@@ -341,7 +341,7 @@
}
// to undo type setting of constants when used as method parameters
- if ( ASTConst.class.isInstance( child ) )
+ if (child instanceof ASTConst)
{
context.setCurrentType( prevType );
}
@@ -373,7 +373,7 @@
ASTMethodUtil.getParmString( context, parms[i], parmString, child, valueClass, ".class)" );
}
- result += parmString;
+ result.append(parmString);
}
if ( prevCast != null )
diff --git a/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java b/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
index b702e8a..55e9eab 100644
--- a/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
+++ b/src/main/java/org/apache/commons/ognl/ASTMethodUtil.java
@@ -44,7 +44,7 @@
}
// to undo type setting of constants when used as method parameters
- if ( ASTConst.class.isInstance( child ) )
+ if (child instanceof ASTConst)
{
context.setCurrentType( prevType );
}
@@ -62,7 +62,7 @@
cast = "";
}
- if ( !ASTConst.class.isInstance( child ) )
+ if ( !(child instanceof ASTConst))
{
parmString = cast + parmString;
}
@@ -108,7 +108,7 @@
parm );
}
- else if ( ( NodeType.class.isInstance( child ) && ( (NodeType) child ).getGetterClass() != null
+ else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
&& Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) ) || ( valueClass != null
&& valueClass.isPrimitive() ) )
{
diff --git a/src/main/java/org/apache/commons/ognl/ASTNegate.java b/src/main/java/org/apache/commons/ognl/ASTNegate.java
index dd6f2fe..d40322c 100644
--- a/src/main/java/org/apache/commons/ognl/ASTNegate.java
+++ b/src/main/java/org/apache/commons/ognl/ASTNegate.java
@@ -45,7 +45,7 @@
{
String source = children[0].toGetSourceString( context, target );
- if ( !ASTNegate.class.isInstance( children[0] ) )
+ if ( !(children[0] instanceof ASTNegate))
{
return "-" + source;
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTProperty.java b/src/main/java/org/apache/commons/ognl/ASTProperty.java
index 9825d80..8a5caf3 100644
--- a/src/main/java/org/apache/commons/ognl/ASTProperty.java
+++ b/src/main/java/org/apache/commons/ognl/ASTProperty.java
@@ -196,7 +196,7 @@
// + " and srcString " + srcString + " on target: " + target);
Object currentObject = context.getCurrentObject();
- if ( ASTConst.class.isInstance( child ) && Number.class.isInstance( currentObject ) )
+ if ( child instanceof ASTConst && currentObject instanceof Number)
{
context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
}
@@ -300,8 +300,7 @@
String srcString = child.toGetSourceString( context, context.getRoot() );
- if ( ASTConst.class.isInstance( child ) && String.class.isInstance(
- context.getCurrentObject() ) )
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
{
srcString = "\"" + srcString + "\"";
}
@@ -372,11 +371,11 @@
Method getIndexedWriteMethod( PropertyDescriptor pd )
{
- if ( IndexedPropertyDescriptor.class.isInstance( pd ) )
+ if (pd instanceof IndexedPropertyDescriptor)
{
return ( (IndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
}
- if ( ObjectIndexedPropertyDescriptor.class.isInstance( pd ) )
+ if (pd instanceof ObjectIndexedPropertyDescriptor)
{
return ( (ObjectIndexedPropertyDescriptor) pd ).getIndexedWriteMethod();
}
@@ -422,7 +421,7 @@
PropertyAccessor propertyAccessor = OgnlRuntime.getPropertyAccessor( target.getClass() );
Object currentObject = context.getCurrentObject();
- if ( ASTConst.class.isInstance( child ) && Number.class.isInstance( currentObject ) )
+ if ( child instanceof ASTConst && currentObject instanceof Number)
{
context.setCurrentType( OgnlRuntime.getPrimitiveWrapperClass( currentObject.getClass() ) );
}
@@ -577,8 +576,7 @@
String srcString = child.toGetSourceString( context, context.getRoot() );
- if ( ASTConst.class.isInstance( child ) && String.class.isInstance(
- context.getCurrentObject() ) )
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
{
srcString = "\"" + srcString + "\"";
}
@@ -630,7 +628,7 @@
String srcString = child.toGetSourceString( context, context.getRoot() );
srcString = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + srcString;
- if ( ASTChain.class.isInstance( child ) )
+ if (child instanceof ASTChain)
{
String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
if ( cast != null )
@@ -639,7 +637,7 @@
}
}
- if ( ASTConst.class.isInstance( child ) && String.class.isInstance( context.getCurrentObject() ) )
+ if ( child instanceof ASTConst && context.getCurrentObject() instanceof String)
{
srcString = "\"" + srcString + "\"";
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTSequence.java b/src/main/java/org/apache/commons/ognl/ASTSequence.java
index 4f4d4f6..0142420 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSequence.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSequence.java
@@ -109,12 +109,12 @@
// System.out.println("astsequence child : " + _children[i].getClass().getName());
String seqValue = children[i].toGetSourceString( context, target );
- if ( ( i + 1 ) < children.length && ASTOr.class.isInstance( children[i] ) )
+ if ( ( i + 1 ) < children.length && children[i] instanceof ASTOr)
{
seqValue = "(" + seqValue + ")";
}
- if ( i > 0 && ASTProperty.class.isInstance( children[i] ) && seqValue != null
+ if ( i > 0 && children[i] instanceof ASTProperty && seqValue != null
&& !seqValue.trim().isEmpty() )
{
String pre = (String) context.get( "_currentChain" );
@@ -144,7 +144,7 @@
}
// set last known type from last child with a type
- if ( NodeType.class.isInstance( children[i] ) && ( (NodeType) children[i] ).getGetterClass() != null )
+ if ( children[i] instanceof NodeType && ( (NodeType) children[i] ).getGetterClass() != null )
{
lastType = (NodeType) children[i];
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTStaticField.java b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
index 7357b93..f6f4ad8 100644
--- a/src/main/java/org/apache/commons/ognl/ASTStaticField.java
+++ b/src/main/java/org/apache/commons/ognl/ASTStaticField.java
@@ -92,15 +92,7 @@
result = Modifier.isFinal( field.getModifiers() );
}
}
- catch ( ClassNotFoundException e )
- {
- cause = e;
- }
- catch ( NoSuchFieldException e )
- {
- cause = e;
- }
- catch ( SecurityException e )
+ catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
@@ -138,15 +130,7 @@
return field.getType();
}
- catch ( ClassNotFoundException e )
- {
- cause = e;
- }
- catch ( NoSuchFieldException e )
- {
- cause = e;
- }
- catch ( SecurityException e )
+ catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java b/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
index c41a8bb..7134dfc 100644
--- a/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
+++ b/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
@@ -84,7 +84,7 @@
public String toGetSourceString( OgnlContext context, Object target )
{
- String result = className + "#" + methodName + "(";
+ StringBuilder result = new StringBuilder(className + "#" + methodName + "(");
try
{
@@ -113,7 +113,7 @@
{
if ( i > 0 )
{
- result = result + ", ";
+ result.append(", ");
}
Class prevType = context.getCurrentType();
@@ -150,7 +150,7 @@
+ ")org.apache.commons.ognl.OgnlOps.convertValue(" + parmString + ","
+ parms[i].getName() + ".class)", parms[i] );
}
- else if ( ( NodeType.class.isInstance( child ) && ( (NodeType) child ).getGetterClass() != null
+ else if ( ( child instanceof NodeType && ( (NodeType) child ).getGetterClass() != null
&& Number.class.isAssignableFrom( ( (NodeType) child ).getGetterClass() ) )
|| valueClass.isPrimitive() )
{
@@ -162,11 +162,11 @@
}
}
- result += parmString;
+ result.append(parmString);
}
}
- result += ")";
+ result.append(")");
try
{
@@ -192,7 +192,7 @@
throw OgnlOps.castToRuntime( t );
}
- return result;
+ return result.toString();
}
public String toSetSourceString( OgnlContext context, Object target )
diff --git a/src/main/java/org/apache/commons/ognl/ASTTest.java b/src/main/java/org/apache/commons/ognl/ASTTest.java
index 0d9ead9..62bb200 100644
--- a/src/main/java/org/apache/commons/ognl/ASTTest.java
+++ b/src/main/java/org/apache/commons/ognl/ASTTest.java
@@ -82,7 +82,7 @@
first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, context.getCurrentType() );
}
- if ( ExpressionNode.class.isInstance( children[0] ) )
+ if (children[0] instanceof ExpressionNode)
{
first = "(" + first + ")";
}
@@ -95,7 +95,7 @@
second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
}
- if ( ExpressionNode.class.isInstance( children[1] ) )
+ if (children[1] instanceof ExpressionNode)
{
second = "(" + second + ")";
}
@@ -109,7 +109,7 @@
}
- if ( ExpressionNode.class.isInstance( children[2] ) )
+ if (children[2] instanceof ExpressionNode)
{
third = "(" + third + ")";
}
diff --git a/src/main/java/org/apache/commons/ognl/ASTVarRef.java b/src/main/java/org/apache/commons/ognl/ASTVarRef.java
index 28f8c2d..53d5fef 100644
--- a/src/main/java/org/apache/commons/ognl/ASTVarRef.java
+++ b/src/main/java/org/apache/commons/ognl/ASTVarRef.java
@@ -124,7 +124,7 @@
post = ")";
}
- if ( parent != null && ASTAssign.class.isInstance( parent ) )
+ if ( parent != null && parent instanceof ASTAssign)
{
core = "$1.put(\"" + name + "\",";
last = pre + "$1.get(\"" + name + "\")" + post;
diff --git a/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
index ca6094f..5c32cf0 100644
--- a/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/ArrayPropertyAccessor.java
@@ -184,7 +184,7 @@
// means it needs to be cast first as well
String toString =
- String.class.isInstance( index ) && context.getCurrentType() != Object.class ? "" : ".toString()";
+ index instanceof String && context.getCurrentType() != Object.class ? "" : ".toString()";
indexStr = format( "org.apache.commons.ognl.OgnlOps#getIntValue(%s%s)", indexStr, toString );
}
diff --git a/src/main/java/org/apache/commons/ognl/Evaluation.java b/src/main/java/org/apache/commons/ognl/Evaluation.java
index 7b1b121..e348dac 100644
--- a/src/main/java/org/apache/commons/ognl/Evaluation.java
+++ b/src/main/java/org/apache/commons/ognl/Evaluation.java
@@ -277,33 +277,32 @@
*/
public String toString( boolean compact, boolean showChildren, String depth )
{
- String stringResult;
+ StringBuilder stringResult;
if ( compact )
{
- stringResult = depth + "<" + node.getClass().getName() + " " + System.identityHashCode( this ) + ">";
+ stringResult = new StringBuilder(depth + "<" + node.getClass().getName() + " " + System.identityHashCode(this) + ">");
}
else
{
String ss = ( source != null ) ? source.getClass().getName() : "null", rs =
( result != null ) ? result.getClass().getName() : "null";
- stringResult =
- depth + "<" + node.getClass().getName() + ": [" + ( setOperation ? "set" : "get" ) + "] source = " + ss
- + ", result = " + result + " [" + rs + "]>";
+ stringResult = new StringBuilder(depth + "<" + node.getClass().getName() + ": [" + (setOperation ? "set" : "get") + "] source = " + ss
+ + ", result = " + result + " [" + rs + "]>");
}
if ( showChildren )
{
Evaluation child = firstChild;
- stringResult += "\n";
+ stringResult.append("\n");
while ( child != null )
{
- stringResult += child.toString( compact, depth + " " );
+ stringResult.append(child.toString(compact, depth + " "));
child = child.next;
}
}
- return stringResult;
+ return stringResult.toString();
}
/**
diff --git a/src/main/java/org/apache/commons/ognl/ExpressionNode.java b/src/main/java/org/apache/commons/ognl/ExpressionNode.java
index 76e4a7b..4fdf017 100644
--- a/src/main/java/org/apache/commons/ognl/ExpressionNode.java
+++ b/src/main/java/org/apache/commons/ognl/ExpressionNode.java
@@ -94,13 +94,13 @@
String value = children[i].toGetSourceString( context, target );
- if ( ( ASTProperty.class.isInstance( children[i] ) || ASTMethod.class.isInstance( children[i] )
- || ASTSequence.class.isInstance( children[i] ) || ASTChain.class.isInstance( children[i] ) )
+ if ( ( children[i] instanceof ASTProperty || children[i] instanceof ASTMethod
+ || children[i] instanceof ASTSequence || children[i] instanceof ASTChain)
&& value != null && !value.trim().isEmpty() )
{
String pre = null;
- if ( ASTMethod.class.isInstance( children[i] ) )
+ if (children[i] instanceof ASTMethod)
{
pre = (String) context.get( "_currentChain" );
}
diff --git a/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
index cfc955d..bafd9cc 100644
--- a/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
@@ -183,7 +183,7 @@
{
String indexStr = index.toString().replace( "\"", "" );
- if ( String.class.isInstance( index ) )
+ if (index instanceof String)
{
if ( "size".equals( indexStr ) )
{
@@ -231,7 +231,7 @@
{
Object currentObject = context.getCurrentObject();
Class<?> currentType = context.getCurrentType();
- if ( currentObject != null && !Number.class.isInstance( currentObject ) )
+ if ( currentObject != null && !(currentObject instanceof Number))
{
try
{
@@ -274,7 +274,7 @@
{
// means it needs to be cast first as well
- String toString = String.class.isInstance( index ) && currentType != Object.class ? "" : ".toString()";
+ String toString = index instanceof String && currentType != Object.class ? "" : ".toString()";
indexStr = "org.apache.commons.ognl.OgnlOps#getIntValue(" + indexStr + toString + ")";
}
diff --git a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
index 833ab5e..df526d4 100644
--- a/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java
@@ -118,7 +118,7 @@
context.setCurrentAccessor( Map.class );
context.setCurrentType( Object.class );
- if ( String.class.isInstance( index ) && !indexedAccess )
+ if ( index instanceof String && !indexedAccess )
{
String key = indexStr.replace( "\"", "" );
@@ -154,7 +154,7 @@
String indexStr = index.toString();
- if ( String.class.isInstance( index ) )
+ if (index instanceof String)
{
String key = indexStr.replace( "\"", "" );
diff --git a/src/main/java/org/apache/commons/ognl/NumericExpression.java b/src/main/java/org/apache/commons/ognl/NumericExpression.java
index 06dc46a..266ba46 100644
--- a/src/main/java/org/apache/commons/ognl/NumericExpression.java
+++ b/src/main/java/org/apache/commons/ognl/NumericExpression.java
@@ -108,13 +108,13 @@
StringBuilder ret = new StringBuilder( source );
Object value = context.getCurrentObject();
- if ( ASTConst.class.isInstance( child ) && value != null )
+ if ( child instanceof ASTConst && value != null )
{
return value.toString();
}
if ( context.getCurrentType() != null && !context.getCurrentType().isPrimitive()
- && context.getCurrentObject() != null && Number.class.isInstance( context.getCurrentObject() ) )
+ && context.getCurrentObject() != null && context.getCurrentObject() instanceof Number)
{
ret = new StringBuilder( "((" ).append(
ExpressionCompiler.getCastString( context.getCurrentObject().getClass() ) ).append( ")" ).append(
@@ -122,7 +122,7 @@
OgnlRuntime.getNumericValueGetter( context.getCurrentObject().getClass() ) );
}
else if ( context.getCurrentType() != null && context.getCurrentType().isPrimitive()
- && ( ASTConst.class.isInstance( child ) || NumericExpression.class.isInstance( child ) ) )
+ && ( child instanceof ASTConst || child instanceof NumericExpression) )
{
@SuppressWarnings( "unchecked" ) // checked by the condition in the if clause
Class<? extends Number> numberClass = (Class<? extends Number>) context.getCurrentType();
@@ -136,7 +136,7 @@
context.setCurrentType( Double.TYPE );
}
- if ( NumericExpression.class.isInstance( child ) )
+ if (child instanceof NumericExpression)
{
ret = new StringBuilder( "(" ).append( ret ).append( ")" );
}
diff --git a/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java b/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java
index 39d52e9..ba5c743 100644
--- a/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java
+++ b/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java
@@ -52,16 +52,10 @@
{
result = OgnlRuntime.getFieldValue( ognlContext, target, name, true );
}
- }
- catch ( IntrospectionException ex )
- {
- throw new OgnlException( name, ex );
- }
- catch ( OgnlException ex )
+ } catch ( OgnlException ex )
{
throw ex;
- }
- catch ( Exception ex )
+ } catch ( Exception ex )
{
throw new OgnlException( name, ex );
}
@@ -93,16 +87,10 @@
result = m.invoke( target, value );
}
}
- }
- catch ( IntrospectionException ex )
- {
- throw new OgnlException( name, ex );
- }
- catch ( OgnlException ex )
+ } catch ( OgnlException ex )
{
throw ex;
- }
- catch ( Exception ex )
+ } catch ( Exception ex )
{
throw new OgnlException( name, ex );
}
diff --git a/src/main/java/org/apache/commons/ognl/Ognl.java b/src/main/java/org/apache/commons/ognl/Ognl.java
index 16616f7..6d1394b 100644
--- a/src/main/java/org/apache/commons/ognl/Ognl.java
+++ b/src/main/java/org/apache/commons/ognl/Ognl.java
@@ -111,11 +111,7 @@
OgnlParser parser = new OgnlParser( new StringReader( expression ) );
return parser.topLevelExpression();
}
- catch ( ParseException e )
- {
- throw new ExpressionSyntaxException( expression, e );
- }
- catch ( TokenMgrError e )
+ catch ( ParseException | TokenMgrError e )
{
throw new ExpressionSyntaxException( expression, e );
}
diff --git a/src/main/java/org/apache/commons/ognl/OgnlCache.java b/src/main/java/org/apache/commons/ognl/OgnlCache.java
index 6a0fe58..2d836d2 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlCache.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlCache.java
@@ -112,14 +112,7 @@
cacheFactory.createClassCache( new PropertyDescriptorCacheEntryFactory() );
private final ClassCache<List<Constructor<?>>> constructorCache =
- cacheFactory.createClassCache( new ClassCacheEntryFactory<List<Constructor<?>>>()
- {
- public List<Constructor<?>> create( Class<?> key )
- throws CacheException
- {
- return Arrays.<Constructor<?>>asList( key.getConstructors() );
- }
- } );
+ cacheFactory.createClassCache(key -> Arrays.<Constructor<?>>asList( key.getConstructors() ));
private final Cache<DeclaredMethodCacheEntry, Map<String, List<Method>>> _methodCache =
cacheFactory.createCache( new DeclaredMethodCacheEntryFactory() );
@@ -131,26 +124,13 @@
cacheFactory.createClassCache( new FieldCacheEntryFactory() );
private final Cache<Method, Class<?>[]> _methodParameterTypesCache =
- cacheFactory.createCache( new CacheEntryFactory<Method, Class<?>[]>()
- {
- public Class<?>[] create( Method key )
- throws CacheException
- {
- return key.getParameterTypes( );
- }
- } );
+ cacheFactory.createCache(Method::getParameterTypes);
private final Cache<GenericMethodParameterTypeCacheEntry, Class<?>[]> _genericMethodParameterTypesCache =
cacheFactory.createCache( new GenericMethodParameterTypeFactory() );
private final Cache<Constructor<?>, Class<?>[]> _ctorParameterTypesCache =
- cacheFactory.createCache( new CacheEntryFactory<Constructor<?>, Class<?>[]>()
- {
- public Class<?>[] create( Constructor<?> key ) throws CacheException
- {
- return key.getParameterTypes( );
- }
- } );
+ cacheFactory.createCache(Constructor::getParameterTypes);
private final Cache<Method, MethodAccessEntryValue> _methodAccessCache =
cacheFactory.createCache( new MethodAccessCacheEntryFactory( ) );
diff --git a/src/main/java/org/apache/commons/ognl/OgnlOps.java b/src/main/java/org/apache/commons/ognl/OgnlOps.java
index 6254e20..58fd1c7 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlOps.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlOps.java
@@ -87,13 +87,13 @@
double dv1 = doubleValue( v1 ),
dv2 = doubleValue( v2 );
- return ( dv1 == dv2 ) ? 0 : ( ( dv1 < dv2 ) ? -1 : 1 );
+ return Double.compare(dv1, dv2);
default:
long lv1 = longValue( v1 ),
lv2 = longValue( v2 );
- return ( lv1 == lv2 ) ? 0 : ( ( lv1 < lv2 ) ? -1 : 1 );
+ return Long.compare(lv1, lv2);
}
}
return result;
@@ -798,13 +798,13 @@
return -1;
}
- if ( Number.class.isInstance( value ) )
+ if (value instanceof Number)
{
return ( (Number) value ).intValue();
}
- String str = String.class.isInstance( value ) ? (String) value : value.toString();
+ String str = value instanceof String ? (String) value : value.toString();
return Integer.parseInt( str );
}
@@ -1292,12 +1292,12 @@
*/
public static RuntimeException castToRuntime( Throwable t )
{
- if ( RuntimeException.class.isInstance( t ) )
+ if (t instanceof RuntimeException)
{
return (RuntimeException) t;
}
- if ( OgnlException.class.isInstance( t ) )
+ if (t instanceof OgnlException)
{
throw new UnsupportedCompilationException( "Error evluating expression: " + t.getMessage(), t );
}
diff --git a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
index 755adea..338fed3 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
@@ -122,7 +122,7 @@
*/
private static final String NULL_OBJECT_STRING = "<null>";
- static OgnlCache cache = new OgnlCache();
+ static final OgnlCache cache = new OgnlCache();
private static final PrimitiveTypes primitiveTypes = new PrimitiveTypes();
@@ -395,8 +395,7 @@
public static Class<?>[] findParameterTypes( Class<?> type, Method method )
throws CacheException
{
- if ( type == null || type.getGenericSuperclass() == null || !ParameterizedType.class.isInstance(
- type.getGenericSuperclass() ) || method.getDeclaringClass().getTypeParameters() == null )
+ if ( type == null || type.getGenericSuperclass() == null || !(type.getGenericSuperclass() instanceof ParameterizedType) || method.getDeclaringClass().getTypeParameters() == null )
{
return getParameterTypes( method );
}
@@ -809,7 +808,7 @@
for ( Method method : methods )
{
Class<?> typeClass = target != null ? target.getClass() : null;
- if ( typeClass == null && source != null && Class.class.isInstance( source ) )
+ if ( typeClass == null && source != null && source instanceof Class)
{
typeClass = (Class<?>) source;
}
@@ -927,15 +926,10 @@
return invokeMethod( target, method, convertedArgs );
}
- catch ( NoSuchMethodException e )
+ catch ( NoSuchMethodException | IllegalAccessException e )
{
cause = e;
- }
- catch ( IllegalAccessException e )
- {
- cause = e;
- }
- catch ( InvocationTargetException e )
+ } catch ( InvocationTargetException e )
{
cause = e.getTargetException();
}
@@ -1019,26 +1013,13 @@
}
return ctor.newInstance( actualArgs );
}
- catch ( ClassNotFoundException e )
+ catch ( ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException e )
{
cause = e;
- }
- catch ( NoSuchMethodException e )
- {
- cause = e;
- }
- catch ( IllegalAccessException e )
- {
- cause = e;
- }
- catch ( InvocationTargetException e )
+ } catch ( InvocationTargetException e )
{
cause = e.getTargetException();
}
- catch ( InstantiationException e )
- {
- cause = e;
- }
throw new MethodFailedException( className, "new", cause );
}
@@ -1296,19 +1277,7 @@
return field.get( null );
}
- catch ( ClassNotFoundException e )
- {
- cause = e;
- }
- catch ( NoSuchFieldException e )
- {
- cause = e;
- }
- catch ( SecurityException e )
- {
- cause = e;
- }
- catch ( IllegalAccessException e )
+ catch ( ClassNotFoundException | IllegalAccessException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
@@ -2116,7 +2085,7 @@
// handle root / method expressions that may not have proper root java source access
- if ( !ASTConst.class.isInstance( child ) && ( target == null || context.getRoot() != target ) )
+ if ( !(child instanceof ASTConst) && ( target == null || context.getRoot() != target ) )
{
source = pre + source;
}
@@ -2127,7 +2096,7 @@
context.setCurrentAccessor( context.getRoot().getClass() );
}
- if ( ASTChain.class.isInstance( child ) )
+ if (child instanceof ASTChain)
{
String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
if ( cast == null )
diff --git a/src/main/java/org/apache/commons/ognl/SimpleNode.java b/src/main/java/org/apache/commons/ognl/SimpleNode.java
index 8247731..97f4d19 100644
--- a/src/main/java/org/apache/commons/ognl/SimpleNode.java
+++ b/src/main/java/org/apache/commons/ognl/SimpleNode.java
@@ -243,17 +243,11 @@
{
result = evaluateGetValueBody( context, source );
}
- catch ( OgnlException ex )
+ catch ( OgnlException | RuntimeException ex )
{
evalException = ex;
throw ex;
- }
- catch ( RuntimeException ex )
- {
- evalException = ex;
- throw ex;
- }
- finally
+ } finally
{
Evaluation eval = context.popEvaluation();
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 3eed6a8..628af40 100644
--- a/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
+++ b/src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java
@@ -148,27 +148,26 @@
return rootExpr;
}
- if ( ( !ASTList.class.isInstance( expression ) && !ASTVarRef.class.isInstance( expression )
- && !ASTStaticMethod.class.isInstance( expression ) && !ASTStaticField.class.isInstance( expression )
- && !ASTConst.class.isInstance( expression ) && !ExpressionNode.class.isInstance( expression )
- && !ASTCtor.class.isInstance( expression ) && !ASTStaticMethod.class.isInstance( expression )
- && root != null ) || ( root != null && ASTRootVarRef.class.isInstance( expression ) ) )
+ if ( ( !(expression instanceof ASTList) && !(expression instanceof ASTVarRef)
+ && !(expression instanceof ASTStaticMethod) && !(expression instanceof ASTStaticField)
+ && !(expression instanceof ASTConst) && !(expression instanceof ExpressionNode)
+ && !(expression instanceof ASTCtor) && !(expression instanceof ASTStaticMethod)
+ && root != null ) || ( root != null && expression instanceof ASTRootVarRef) )
{
Class<?> castClass = OgnlRuntime.getCompiler( context ).getRootExpressionClass( expression, context );
- if ( castClass.isArray() || ASTRootVarRef.class.isInstance( expression ) || ASTThisVarRef.class.isInstance(
- expression ) )
+ if ( castClass.isArray() || expression instanceof ASTRootVarRef || expression instanceof ASTThisVarRef)
{
rootExpr = "((" + getCastString( castClass ) + ")$2)";
- if ( ASTProperty.class.isInstance( expression ) && !( (ASTProperty) expression ).isIndexedAccess() )
+ if ( expression instanceof ASTProperty && !( (ASTProperty) expression ).isIndexedAccess() )
{
rootExpr += ".";
}
}
- else if ( ( ASTProperty.class.isInstance( expression ) && ( (ASTProperty) expression ).isIndexedAccess() )
- || ASTChain.class.isInstance( expression ) )
+ else if ( ( expression instanceof ASTProperty && ( (ASTProperty) expression ).isIndexedAccess() )
+ || expression instanceof ASTChain)
{
rootExpr = "((" + getCastString( castClass ) + ")$2)";
}
@@ -190,18 +189,18 @@
*/
public static boolean shouldCast( Node expression )
{
- if ( ASTChain.class.isInstance( expression ) )
+ if (expression instanceof ASTChain)
{
Node child = expression.jjtGetChild( 0 );
- if ( ASTConst.class.isInstance( child ) || ASTStaticMethod.class.isInstance( child )
- || ASTStaticField.class.isInstance( child ) || ( ASTVarRef.class.isInstance( child )
- && !ASTRootVarRef.class.isInstance( child ) ) )
+ if ( child instanceof ASTConst || child instanceof ASTStaticMethod
+ || child instanceof ASTStaticField || ( child instanceof ASTVarRef
+ && !(child instanceof ASTRootVarRef)) )
{
return false;
}
}
- return !ASTConst.class.isInstance( expression );
+ return !(expression instanceof ASTConst);
}
/**
@@ -218,11 +217,11 @@
&& context.getCurrentAccessor().isAssignableFrom( context.getPreviousType() ) ) || body == null
|| body.trim().length() < 1 || ( context.getCurrentType() != null && context.getCurrentType().isArray() && (
context.getPreviousType() == null || context.getPreviousType() != Object.class ) )
- || ASTOr.class.isInstance( expression ) || ASTAnd.class.isInstance( expression )
- || ASTRootVarRef.class.isInstance( expression ) || context.getCurrentAccessor() == Class.class || (
+ || expression instanceof ASTOr || expression instanceof ASTAnd
+ || expression instanceof ASTRootVarRef || context.getCurrentAccessor() == Class.class || (
context.get( ExpressionCompiler.PRE_CAST ) != null && ( (String) context.get(
- ExpressionCompiler.PRE_CAST ) ).startsWith( "new" ) ) || ASTStaticField.class.isInstance( expression )
- || ASTStaticMethod.class.isInstance( expression ) || ( OrderedReturn.class.isInstance( expression )
+ ExpressionCompiler.PRE_CAST ) ).startsWith( "new" ) ) || expression instanceof ASTStaticField
+ || expression instanceof ASTStaticMethod || ( expression instanceof OrderedReturn
&& ( (OrderedReturn) expression ).getLastExpression() != null ) )
{
return body;
@@ -619,10 +618,10 @@
createLocalReferences( context, classPool, newClass, objClass, valueGetter.getParameterTypes() );
- if ( OrderedReturn.class.isInstance( expression )
+ if ( expression instanceof OrderedReturn
&& ( (OrderedReturn) expression ).getLastExpression() != null )
{
- body = "{ " + ( ASTMethod.class.isInstance( expression ) || ASTChain.class.isInstance( expression )
+ body = "{ " + ( expression instanceof ASTMethod || expression instanceof ASTChain
? rootExpr
: "" ) + ( castExpression != null ? castExpression : "" )
+ ( (OrderedReturn) expression ).getCoreExpression() + " return " + pre
@@ -697,7 +696,7 @@
CtMethod valueSetter, Node expression, Object root )
throws Exception
{
- if ( ExpressionNode.class.isInstance( expression ) || ASTConst.class.isInstance( expression ) )
+ if ( expression instanceof ExpressionNode || expression instanceof ASTConst)
{
throw new UnsupportedCompilationException( "Can't compile expression/constant setters." );
}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
index b3c4ca7..7e7d424 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeCacheEntry.java
@@ -28,9 +28,9 @@
public class GenericMethodParameterTypeCacheEntry
implements CacheEntry
{
- Method method;
+ final Method method;
- Class<?> type;
+ final Class<?> type;
public GenericMethodParameterTypeCacheEntry( Method method, Class<?> type )
{
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
index 2e6e5d8..55af62b 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/GenericMethodParameterTypeFactory.java
@@ -49,20 +49,20 @@
{
TypeVariable<?> paramType = null;
- if ( TypeVariable.class.isInstance( genTypes[i] ) )
+ if (genTypes[i] instanceof TypeVariable)
{
paramType = (TypeVariable<?>) genTypes[i];
}
- else if ( GenericArrayType.class.isInstance( genTypes[i] ) )
+ else if (genTypes[i] instanceof GenericArrayType)
{
paramType = (TypeVariable<?>) ( (GenericArrayType) genTypes[i] ).getGenericComponentType();
}
- else if ( ParameterizedType.class.isInstance( genTypes[i] ) )
+ else if (genTypes[i] instanceof ParameterizedType)
{
types[i] = (Class<?>) ( (ParameterizedType) genTypes[i] ).getRawType();
continue;
}
- else if ( Class.class.isInstance( genTypes[i] ) )
+ else if (genTypes[i] instanceof Class)
{
types[i] = (Class<?>) genTypes[i];
continue;
@@ -72,7 +72,7 @@
if ( resolved != null )
{
- if ( GenericArrayType.class.isInstance( genTypes[i] ) )
+ if (genTypes[i] instanceof GenericArrayType)
{
resolved = Array.newInstance( resolved, 0 ).getClass();
}
@@ -95,7 +95,7 @@
for ( int i = 0; i < declaredTypes.length; i++ )
{
- if ( !TypeVariable.class.isInstance( param.getActualTypeArguments()[i] )
+ if ( !(param.getActualTypeArguments()[i] instanceof TypeVariable)
&& declaredTypes[i].getName().equals( var.getName() ) )
{
return (Class<?>) param.getActualTypeArguments()[i];
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
index cfb126a..cccaf78 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntry.java
@@ -26,7 +26,7 @@
public class MethodCacheEntry
implements CacheEntry
{
- public Class<?> targetClass;
+ public final Class<?> targetClass;
public MethodCacheEntry( Class<?> targetClass )
{
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
index 58c82cb..95b0f72 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/MethodCacheEntryFactory.java
@@ -55,13 +55,7 @@
if ( shouldCache( key, method ) )
{
- List<Method> ml = result.get( method.getName() );
-
- if ( ml == null )
- {
- ml = new ArrayList<Method>();
- result.put( method.getName(), ml );
- }
+ List<Method> ml = result.computeIfAbsent(method.getName(), k -> new ArrayList<Method>());
ml.add( method );
}
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
index 52405dd..68c0890 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/PermissionCacheEntry.java
@@ -28,7 +28,7 @@
public class PermissionCacheEntry
implements CacheEntry
{
- public Method method;
+ public final Method method;
public PermissionCacheEntry( Method method )
{
diff --git a/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java b/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
index 3c8616c..67e5a03 100644
--- a/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
+++ b/src/main/java/org/apache/commons/ognl/internal/entry/PropertyDescriptorCacheEntryFactory.java
@@ -67,11 +67,7 @@
findObjectIndexedPropertyDescriptors( targetClass, result );
}
- catch ( IntrospectionException e )
- {
- throw new CacheException( e );
- }
- catch ( OgnlException e )
+ catch ( IntrospectionException | OgnlException e )
{
throw new CacheException( e );
}
@@ -127,22 +123,14 @@
if ( isGet && ( parameterCount == 1 ) && ( method.getReturnType() != Void.TYPE ) )
{
- List<Method> pair = pairs.get( propertyName );
+ List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
- if ( pair == null )
- {
- pairs.put( propertyName, pair = new ArrayList<Method>() );
- }
pair.add( method );
}
if ( isSet && ( parameterCount == 2 ) && ( method.getReturnType() == Void.TYPE ) )
{
- List<Method> pair = pairs.get( propertyName );
+ List<Method> pair = pairs.computeIfAbsent(propertyName, k -> new ArrayList<Method>());
- if ( pair == null )
- {
- pairs.put( propertyName, pair = new ArrayList<Method>() );
- }
pair.add( method );
}
}
diff --git a/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java b/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
index 3ad0f6a..677ea2c 100644
--- a/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
+++ b/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
@@ -205,7 +205,7 @@
SetterReturns root = new SetterReturns();
Method m = OgnlRuntime.getWriteMethod( root.getClass(), "value" );
- assertTrue( m != null );
+ assertNotNull(m);
Ognl.setValue( "value", context, root, "12__" );
assertEquals( Ognl.getValue( "value", context, root ), "12__" );
diff --git a/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
index 76c8b63..bdc8feb 100644
--- a/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ASTPropertyTest.java
@@ -63,18 +63,18 @@
context.setCurrentNode( pRef );
assertEquals( root.getClass(), context.getCurrentType() );
- assertEquals( null, context.getPreviousType() );
+ assertNull(context.getPreviousType());
assertEquals( root, context.getCurrentObject() );
- assertEquals( null, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
int type = p.getIndexedPropertyType( context, root );
assertEquals( OgnlRuntime.INDEXED_PROPERTY_NONE, type );
assertEquals( root.getClass(), context.getCurrentType() );
- assertEquals( null, context.getPreviousType() );
- assertEquals( null, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousType());
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
}
public void test_Get_Value_Body()
@@ -95,18 +95,18 @@
context.setCurrentNode( pRef );
assertEquals( root.getClass(), context.getCurrentType() );
- assertEquals( null, context.getPreviousType() );
+ assertNull(context.getPreviousType());
assertEquals( root, context.getCurrentObject() );
- assertEquals( null, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
Object value = p.getValue( context, root );
assertEquals( root.get( "nested" ), value );
assertEquals( root.getClass(), context.getCurrentType() );
- assertEquals( null, context.getPreviousType() );
- assertEquals( null, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousType());
+ assertNull(context.getCurrentAccessor());
+ assertNull(context.getPreviousAccessor());
}
public void test_Get_Source()
@@ -130,14 +130,14 @@
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Map.class, context.getCurrentAccessor() );
assertEquals( root.getClass(), context.getPreviousType() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
assertEquals( root.get( "nested" ), context.getCurrentObject() );
assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
assertEquals( root.getClass(), context.getPreviousType() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
}
public void test_Set_Source()
@@ -164,7 +164,7 @@
assert Map.class.isAssignableFrom( context.getCurrentAccessor() );
assertEquals( root.getClass(), context.getPreviousType() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
}
public void test_Indexed_Object_Type()
@@ -206,7 +206,7 @@
assertEquals( ".getList()", listp.toGetSourceString( context, root ) );
assertEquals( List.class, context.getCurrentType() );
assertEquals( Root.class, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
assertEquals( root.getClass(), context.getPreviousType() );
assertEquals( root.getList(), context.getCurrentObject() );
@@ -225,7 +225,7 @@
assertEquals( ".getList()", chain.toGetSourceString( context, root ) );
assertEquals( List.class, context.getCurrentType() );
assertEquals( Root.class, context.getCurrentAccessor() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
assertEquals( Root.class, context.getPreviousType() );
assertEquals( root.getList(), context.getCurrentObject() );
diff --git a/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java b/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
index 675dac0..2b78a60 100644
--- a/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
+++ b/src/test/java/org/apache/commons/ognl/test/CompilingPropertyAccessor.java
@@ -47,28 +47,16 @@
private static final NameFactory NAME_FACTORY = new NameFactory( "ognl.PropertyAccessor", "v" );
- private static final Getter NOT_FOUND_GETTER = new Getter()
- {
+ private static final Getter NOT_FOUND_GETTER = (context, target, propertyName) -> null;
- public Object get( OgnlContext context, Object target, String propertyName )
+ private static final Getter DEFAULT_GETTER = (context, target, propertyName) -> {
+ try
{
- return null;
+ return OgnlRuntime.getMethodValue( context, target, propertyName, true );
}
- };
-
- private static final Getter DEFAULT_GETTER = new Getter()
- {
-
- public Object get( OgnlContext context, Object target, String propertyName )
+ catch ( Exception ex )
{
- try
- {
- return OgnlRuntime.getMethodValue( context, target, propertyName, true );
- }
- catch ( Exception ex )
- {
- throw new RuntimeException( ex );
- }
+ throw new RuntimeException( ex );
}
};
diff --git a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
index 0f4723d..349a00d 100644
--- a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -77,7 +78,7 @@
public void runTest()
throws Exception
{
- assertTrue( Ognl.isConstant( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
+ Assert.assertEquals(Ognl.isConstant(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}
/*
diff --git a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
index 04209e4..a78d8fb 100644
--- a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import junit.framework.Assert;
import org.apache.commons.ognl.OgnlException;
import org.apache.commons.ognl.OgnlOps;
import org.junit.Test;
@@ -213,7 +214,7 @@
double scalingFactor = Math.pow( 10, scale ), v1 = ( (Number) value ).doubleValue() * scalingFactor, v2 =
( (Number) expectedValue ).doubleValue() * scalingFactor;
- assertTrue( (int) v1 == (int) v2 );
+ Assert.assertEquals((int) v1, (int) v2);
}
else
{
diff --git a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
index 23b0d93..a2171de 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -78,6 +79,6 @@
public void runTest()
throws Exception
{
- assertTrue( Ognl.isSimpleNavigationChain( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
+ Assert.assertEquals(Ognl.isSimpleNavigationChain(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}
}
diff --git a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
index debe179..989c3b8 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -78,6 +79,6 @@
public void runTest()
throws Exception
{
- assertTrue( Ognl.isSimpleProperty( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
+ Assert.assertEquals(Ognl.isSimpleProperty(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}
}
diff --git a/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java b/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
index aeee9de..57738d7 100644
--- a/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/accessors/ListPropertyAccessorTest.java
@@ -56,7 +56,7 @@
assertEquals( List.class, context.getCurrentAccessor() );
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Integer.TYPE, context.getPreviousType() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
}
@Test
@@ -76,7 +76,7 @@
assertEquals( List.class, context.getCurrentAccessor() );
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Integer.class, context.getPreviousType() );
- assertEquals( null, context.getPreviousAccessor() );
+ assertNull(context.getPreviousAccessor());
}
@Test
diff --git a/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java b/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
index b3ddf7f..a28152c 100644
--- a/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
+++ b/src/test/java/org/apache/commons/ognl/test/enhance/TestExpressionCompiler.java
@@ -242,7 +242,7 @@
GenericRoot root = new GenericRoot();
Node node = Ognl.compileExpression( _context, root, "cracker.param" );
- assertEquals( null, node.getAccessor().get( _context, root ) );
+ assertNull(node.getAccessor().get(_context, root));
node.getAccessor().set( _context, root, 0 );
assertEquals( 0, node.getAccessor().get( _context, root ) );