cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] branch master updated: minor code cleanup
Date Thu, 14 May 2020 15:44:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new d02b0a4  minor code cleanup
d02b0a4 is described below

commit d02b0a43938b314b608565450cddb9b66e595e28
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Thu May 14 18:44:26 2020 +0300

    minor code cleanup
---
 .../org/apache/cayenne/exp/parser/ASTEqual.java    | 27 +++++++++++-----------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTEqual.java b/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTEqual.java
index 8fdfe06..2e4bc65 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTEqual.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTEqual.java
@@ -124,23 +124,22 @@ public class ASTEqual extends ConditionNode implements ValueInjector
{
 	}
 
 	public void injectValue(Object o) {
-		// try to inject value, if one of the operands is scalar, and other is a
-		// path
-
-		Node[] args = new Node[] { jjtGetChild(0), jjtGetChild(1) };
-
-		int scalarIndex = -1;
-		if (args[0] instanceof ASTScalar) {
-			scalarIndex = 0;
-		} else if (args[1] instanceof ASTScalar) {
-			scalarIndex = 1;
+		// try to inject value, if one of the operands is scalar, and other is a path
+		ASTScalar scalar = null;
+		ASTObjPath path = null;
+
+		for(int i=0; i<=1; i++) {
+			Node node = jjtGetChild(i);
+			if(node instanceof ASTScalar) {
+				scalar = (ASTScalar)node;
+			} else if(node instanceof ASTObjPath) {
+				path = (ASTObjPath) node;
+			}
 		}
 
-		if (scalarIndex != -1 && args[1 - scalarIndex] instanceof ASTObjPath) {
-			// inject
-			ASTObjPath path = (ASTObjPath) args[1 - scalarIndex];
+		if (scalar != null && path != null) {
 			try {
-				path.injectValue(o, evaluateChild(scalarIndex, o));
+				path.injectValue(o, scalar.getValue());
 			} catch (Exception ex) {
 				LOGGER.warn("Failed to inject value " + " on path " + path.getPath() + " to " + o, ex);
 			}


Mime
View raw message