Skip to content

Commit e6779af

Browse files
author
qiushui
committed
多维数组
1 parent 34cab56 commit e6779af

5 files changed

Lines changed: 53 additions & 7 deletions

File tree

‎pom.xml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@
3939
<tag>HEAD</tag>
4040
</scm>
4141

42-
<properties>
42+
<!-- 配置私库地址 -->
43+
<distributionManagement>
44+
<snapshotRepository>
45+
<id>hclc aliyun nexus</id>
46+
<url>http://nexus.hclcaliyun.com:8082/repository/maven-snapshots/</url>
47+
</snapshotRepository>
48+
<repository>
49+
<id>hclc aliyun nexus</id>
50+
<url>http://nexus.hclcaliyun.com:8082/repository/maven-releases/</url>
51+
</repository>
52+
</distributionManagement>
53+
54+
<properties>
4355
<maven.compiler.source>11</maven.compiler.source>
4456
<maven.compiler.target>11</maven.compiler.target>
4557
</properties>

‎src/main/java/com/github/developframework/expression/Expression.java‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,34 @@ public boolean hasParentExpression() {
4747
return parentExpression != EmptyExpression.INSTANCE;
4848
}
4949

50+
/**
51+
* 是否是对象表达式
52+
*/
53+
public boolean isObject() {
54+
return this instanceof ObjectExpression;
55+
}
56+
57+
/**
58+
* 是否是数组表达式
59+
*/
60+
public boolean isArray() {
61+
return this instanceof ArrayExpression;
62+
}
63+
64+
/**
65+
* 是否是方法表达式
66+
*/
67+
public boolean isMethod() {
68+
return this instanceof MethodExpression;
69+
}
70+
71+
/**
72+
* 是否是空表达式
73+
*/
74+
public boolean isEmpty() {
75+
return this == EmptyExpression.INSTANCE;
76+
}
77+
5078
/**
5179
* 返回表达式树
5280
*
@@ -199,5 +227,4 @@ public static Expression concat(Expression parentExpression, Expression childExp
199227
return newExpression;
200228
}
201229
}
202-
203230
}

‎src/main/java/com/github/developframework/expression/ExpressionUtils.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
* @author qiushui
1515
*/
1616
@SuppressWarnings("unchecked")
17-
public final class ExpressionUtils {
18-
19-
private ExpressionUtils() {
20-
throw new AssertionError("No " + getClass().getName() + " instances for you!");
21-
}
17+
public abstract class ExpressionUtils {
2218

2319
/**
2420
* 获取值

‎src/test/java/test/JunitTest.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ public void testArray() {
6161
Assert.assertNull(item2);
6262
}
6363

64+
@Test
65+
public void testMethod() {
66+
List<User> users = List.of(new User("a", 20));
67+
String say = ExpressionUtils.getValue(Map.of("data", Map.of("users", users)), "data.users[0].say()", String.class);
68+
Assert.assertEquals(say, "Hi");
69+
}
70+
6471
}

‎src/test/java/test/User.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ public class User {
1010
private final String name;
1111

1212
private final int age;
13+
14+
public String say() {
15+
return "Hi";
16+
}
1317
}

0 commit comments

Comments
 (0)