-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from mmnaseri/release-v1.0.3
Release v1.0.3
- Loading branch information
Showing
470 changed files
with
747 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2016 Milad Naseri | ||
~ | ||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
~ software and associated documentation files (the "Software"), to deal in the Software | ||
~ without restriction, including without limitation the rights to use, copy, modify, merge, | ||
~ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | ||
~ to whom the Software is furnished to do so, subject to the following conditions: | ||
~ | ||
~ The above copyright notice and this permission notice shall be included in all copies or | ||
~ substantial portions of the Software. | ||
~ | ||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
~ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
~ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
~ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
~ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
~ SOFTWARE. | ||
--> | ||
|
||
<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> | ||
|
||
<groupId>com.mmnaseri.utils</groupId> | ||
<artifactId>spring-data-mock-build</artifactId> | ||
<version>1.0.2</version> | ||
<name>Spring Data Mock: Build Aggregator</name> | ||
<description>This is the build module that will aggregate all reactors for the spring-data-mock project</description> | ||
<url>https://mmnaseri.github.io/spring-data-mock</url> | ||
<packaging>pom</packaging> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT</name> | ||
<url>http://mit-license.org</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Milad Naseri</name> | ||
<email>[email protected]</email> | ||
<url>http://www.mmnaseri.com</url> | ||
<roles> | ||
<role>designer</role> | ||
<role>developer</role> | ||
</roles> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:[email protected]:mmnaseri/spring-data-mock.git</connection> | ||
<developerConnection>scm:git:[email protected]:mmnaseri/spring-data-mock.git</developerConnection> | ||
<url>[email protected]:mmnaseri/spring-data-mock.git</url> | ||
</scm> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven-compiler-plugin.version}</version> | ||
<configuration> | ||
<source>${target-jdk.version}</source> | ||
<target>${target-jdk.version}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<modules> | ||
<module>../spring-data-mock/</module> | ||
</modules> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> | ||
<target-jdk.version>1.7</target-jdk.version> | ||
</properties> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/MatchedOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mmnaseri.utils.spring.data.domain; | ||
|
||
/** | ||
* Represents an operator that was picked because of a parse operation | ||
* | ||
* @author Mohammad Milad Naseri ([email protected]) | ||
* @since 1.0 (4/17/16, 12:36 PM) | ||
*/ | ||
public interface MatchedOperator extends Operator { | ||
|
||
/** | ||
* @return the suffix that was matched when looking up this operator | ||
*/ | ||
String getMatchedToken(); | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
87 changes: 87 additions & 0 deletions
87
...mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultOperatorContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.mmnaseri.utils.spring.data.domain.impl; | ||
|
||
import com.mmnaseri.utils.spring.data.domain.Operator; | ||
import com.mmnaseri.utils.spring.data.domain.OperatorContext; | ||
import com.mmnaseri.utils.spring.data.domain.impl.matchers.*; | ||
import com.mmnaseri.utils.spring.data.error.DuplicateOperatorException; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.concurrent.CopyOnWriteArraySet; | ||
|
||
/** | ||
* This class is used to store the operators used in the name of a query method. Operators are matched by | ||
* the "suffixes" eagerly (meaning that "EqualTo" will precede over "To"). | ||
* | ||
* @author Milad Naseri ([email protected]) | ||
* @since 1.0 (9/29/15) | ||
*/ | ||
public class DefaultOperatorContext implements OperatorContext { | ||
|
||
private static final Log log = LogFactory.getLog(DefaultOperatorContext.class); | ||
private final Set<Operator> operators; | ||
|
||
public DefaultOperatorContext() { | ||
this(true); | ||
} | ||
|
||
public DefaultOperatorContext(boolean registerDefaults) { | ||
operators = new CopyOnWriteArraySet<>(); | ||
if (registerDefaults) { | ||
log.info("Registering all the default operators"); | ||
operators.add(new ImmutableOperator("AFTER", 1, new IsGreaterThanMatcher(), "After", "IsAfter")); | ||
operators.add(new ImmutableOperator("BEFORE", 1, new IsLessThanMatcher(), "Before", "IsBefore")); | ||
operators.add(new ImmutableOperator("CONTAINING", 1, new ContainingMatcher(), "Containing", "IsContaining", "Contains")); | ||
operators.add(new ImmutableOperator("BETWEEN", 2, new IsBetweenMatcher(), "Between", "IsBetween")); | ||
operators.add(new ImmutableOperator("NOT_BETWEEN", 2, new IsNotBetweenMatcher(), "NotBetween", "IsNotBetween")); | ||
operators.add(new ImmutableOperator("ENDING_WITH", 1, new EndingWithMatcher(), "EndingWith", "IsEndingWith", "EndsWith")); | ||
operators.add(new ImmutableOperator("FALSE", 0, new IsFalseMatcher(), "False", "IsFalse")); | ||
operators.add(new ImmutableOperator("GREATER_THAN", 1, new IsGreaterThanMatcher(), "GreaterThan", "IsGreaterThan")); | ||
operators.add(new ImmutableOperator("GREATER_THAN_EQUALS", 1, new IsGreaterThanOrEqualToMatcher(), "GreaterThanEqual", "IsGreaterThanEqual")); | ||
operators.add(new ImmutableOperator("IN", 1, new IsInMatcher(), "In", "IsIn")); | ||
operators.add(new ImmutableOperator("IS", 1, new IsEqualToMatcher(), "Is", "EqualTo", "IsEqualTo", "Equals")); | ||
operators.add(new ImmutableOperator("NOT_NULL", 0, new IsNotNullMatcher(), "NotNull", "IsNotNull")); | ||
operators.add(new ImmutableOperator("NULL", 0, new IsNullMatcher(), "Null", "IsNull")); | ||
operators.add(new ImmutableOperator("LESS_THAN", 1, new IsLessThanMatcher(), "LessThan", "IsLessThan")); | ||
operators.add(new ImmutableOperator("LESS_THAN_EQUAL", 1, new IsLessThanOrEqualToMatcher(), "LessThanEqual", "IsLessThanEqual")); | ||
operators.add(new ImmutableOperator("LIKE", 1, new IsLikeMatcher(), "Like", "IsLike")); | ||
operators.add(new ImmutableOperator("NEAR", 1, null, "Near", "IsNear")); | ||
operators.add(new ImmutableOperator("NOT", 1, new IsNotMatcher(), "IsNot", "Not", "IsNotEqualTo", "DoesNotEqual")); | ||
operators.add(new ImmutableOperator("NOT_IN", 1, new IsNotInMatcher(), "NotIn", "IsNotIn")); | ||
operators.add(new ImmutableOperator("NOT_LIKE", 1, new IsNotLikeMatcher(), "NotLike", "IsNotLike")); | ||
operators.add(new ImmutableOperator("REGEX", 1, new RegexMatcher(), "Regex", "MatchesRegex", "Matches")); | ||
operators.add(new ImmutableOperator("STARTING_WITH", 1, new StartingWithMatcher(), "StartingWith", "IsStartingWith", "StartsWith")); | ||
operators.add(new ImmutableOperator("TRUE", 0, new IsTrueMatcher(), "True", "IsTrue")); | ||
} | ||
} | ||
|
||
@Override | ||
public void register(Operator operator) { | ||
log.info("Registering operator " + operator.getName() + " which will respond to suffixes " + Arrays.toString(operator.getTokens())); | ||
for (Operator item : operators) { | ||
for (String token : item.getTokens()) { | ||
for (String newToken : operator.getTokens()) { | ||
if (newToken.equals(token)) { | ||
throw new DuplicateOperatorException(item, token); | ||
} | ||
} | ||
} | ||
} | ||
operators.add(operator); | ||
} | ||
|
||
@Override | ||
public Operator getBySuffix(String suffix) { | ||
for (Operator operator : operators) { | ||
for (String token : operator.getTokens()) { | ||
if (token.equals(suffix)) { | ||
return operator; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ck/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/ImmutableMatchedOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.mmnaseri.utils.spring.data.domain.impl; | ||
|
||
import com.mmnaseri.utils.spring.data.domain.MatchedOperator; | ||
import com.mmnaseri.utils.spring.data.domain.Matcher; | ||
import com.mmnaseri.utils.spring.data.domain.Operator; | ||
|
||
/** | ||
* @author Mohammad Milad Naseri ([email protected]) | ||
* @since 1.0 (4/17/16, 12:37 PM) | ||
*/ | ||
@SuppressWarnings("WeakerAccess") | ||
public class ImmutableMatchedOperator implements MatchedOperator { | ||
|
||
private final Operator original; | ||
private final String matchedToken; | ||
|
||
public ImmutableMatchedOperator(Operator original, String matchedToken) { | ||
this.original = original; | ||
this.matchedToken = matchedToken; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return original.getName(); | ||
} | ||
|
||
@Override | ||
public int getOperands() { | ||
return original.getOperands(); | ||
} | ||
|
||
@Override | ||
public Matcher getMatcher() { | ||
return original.getMatcher(); | ||
} | ||
|
||
@Override | ||
public String[] getTokens() { | ||
return original.getTokens(); | ||
} | ||
|
||
@Override | ||
public String getMatchedToken() { | ||
return matchedToken; | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.