Skip to content

Commit

Permalink
Add shardingsphere-infra-expr-type module (#28561)
Browse files Browse the repository at this point in the history
* Revise javadoc on InlineExpressionParser

* Add shardingsphere-infra-expr-type module

* Fix javadoc

* Refactor PureListInlineExpressionParser

* Refactor PureListInlineExpressionParser

* Remove useless javadoc

* Simply refactor
  • Loading branch information
terrymanu authored Sep 24, 2023
1 parent 745d259 commit 3312690
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class CustomInlineExpressionParserFixture implements InlineExpressi

@Override
public void init(final Properties props) {
this.inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
}

@Override
Expand Down
4 changes: 1 addition & 3 deletions infra/expr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<modules>
<module>spi</module>
<module>core</module>
<module>groovy</module>
<module>purelist</module>
<module>espresso</module>
<module>type</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public interface InlineExpressionParser extends TypedSPI {

/**
* This method is used to return the inlineExpression String itself. In some cases, you may want to do
* additional processing on inlineExpression to return a specific value, in which case you need to override this
* method.
* additional processing on inlineExpression to return a specific value, in which case you need to override this method.
*
* @return result processed inline expression defined by the SPI implementation.
* @return result processed inline expression defined by the SPI implementation
*/
String handlePlaceHolder();

Expand All @@ -54,8 +53,7 @@ public interface InlineExpressionParser extends TypedSPI {
* Evaluate closure.
*
* @return closure
* @throws UnsupportedOperationException In most cases, users should not implement this method, and the return value
* of this method can only be a Groovy Closure.
* @throws UnsupportedOperationException In most cases, users should not implement this method, and the return value of this method can only be a Groovy closure
*/
default Closure<?> evaluateClosure() {
throw new UnsupportedOperationException("This SPI implementation does not support the use of this method.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-expr</artifactId>
<artifactId>shardingsphere-infra-expr-type</artifactId>
<version>5.4.1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-expr-espresso</artifactId>
Expand Down Expand Up @@ -85,7 +85,7 @@
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
<outputDirectory>${project.build.outputDirectory}/espresso-need-libs</outputDirectory>
<outputDirectory>target/classes/espresso-need-libs</outputDirectory>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ public final class EspressoInlineExpressionParser implements InlineExpressionPar
JAVA_CLASSPATH = dir + File.separator + "groovy.jar";
}

/**
* Initialize SPI.
*
* @param props A Properties instance that carries inlineExpression.
* And for compatibility reasons, inlineExpression allows to be null.
*/
@Override
public void init(final Properties props) {
this.inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-expr</artifactId>
<artifactId>shardingsphere-infra-expr-type</artifactId>
<version>5.4.1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-expr-groovy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ public final class GroovyInlineExpressionParser implements InlineExpressionParse

private String inlineExpression;

/**
* Initialize SPI.
*
* @param props A Properties instance that carries inlineExpression.
* And for compatibility reasons, inlineExpression allows to be null.
*/
@Override
public void init(final Properties props) {
this.inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
}

@Override
Expand Down
35 changes: 35 additions & 0 deletions infra/expr/type/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-expr</artifactId>
<version>5.4.1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-expr-type</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>

<modules>
<module>groovy</module>
<module>purelist</module>
<module>espresso</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-expr</artifactId>
<artifactId>shardingsphere-infra-expr-type</artifactId>
<version>5.4.1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-expr-purelist</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ public final class PureListInlineExpressionParser implements InlineExpressionPar

private String inlineExpression;

/**
* Initialize SPI.
*
* @param props A Properties instance that carries inlineExpression.
* And for compatibility reasons, inlineExpression allows to be null.
*/
@Override
public void init(final Properties props) {
this.inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
inlineExpression = props.getProperty(INLINE_EXPRESSION_KEY);
}

@Override
Expand All @@ -60,7 +54,7 @@ private List<String> split(final String inlineExpression) {
StringBuilder segment = new StringBuilder();
for (int i = 0; i < inlineExpression.length(); i++) {
char each = inlineExpression.charAt(i);
if (each == SPLITTER) {
if (SPLITTER == each) {
result.add(segment.toString().trim());
segment.setLength(0);
} else {
Expand Down

0 comments on commit 3312690

Please sign in to comment.