-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat(KeyResolver): Support specifying key resolver for assemble opera…
1 parent
de84a38
commit 7622bdf
Showing
38 changed files
with
1,022 additions
and
39 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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
...j-core/src/main/java/cn/crane4j/core/executor/key/DefaultKeyResolverProviderRegistry.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,25 @@ | ||
package cn.crane4j.core.executor.key; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* <p>Default key resolver registry | ||
* | ||
* @author huangchengxing | ||
* @since 2.7.0 | ||
*/ | ||
public class DefaultKeyResolverProviderRegistry implements KeyResolverRegistry { | ||
|
||
private final Map<String, KeyResolverProvider> providers = new HashMap<>(); | ||
|
||
@Override | ||
public void register(String name, KeyResolverProvider resolverProvider) { | ||
providers.put(name, resolverProvider); | ||
} | ||
|
||
@Override | ||
public KeyResolverProvider getKeyResolver(String name) { | ||
return providers.get(name); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
crane4j-core/src/main/java/cn/crane4j/core/executor/key/KeyResolver.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,32 @@ | ||
package cn.crane4j.core.executor.key; | ||
|
||
import cn.crane4j.core.parser.operation.AssembleOperation; | ||
|
||
/** | ||
* <p>Key resolver, which is used to resolve the key of the operation. | ||
* | ||
* @author huangchengxing | ||
* @since 2.7.0 | ||
*/ | ||
public interface KeyResolver extends KeyResolverProvider { | ||
|
||
/** | ||
* Get the resolver of the operation. | ||
* | ||
* @param operation operation | ||
* @return resolver | ||
*/ | ||
@Override | ||
default KeyResolver getResolver(AssembleOperation operation) { | ||
return this; | ||
} | ||
|
||
/** | ||
* Resolve the key of the operation. | ||
* | ||
* @param target target | ||
* @param operation operation | ||
* @return key | ||
*/ | ||
Object resolve(Object target, AssembleOperation operation); | ||
} |
20 changes: 20 additions & 0 deletions
20
crane4j-core/src/main/java/cn/crane4j/core/executor/key/KeyResolverProvider.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,20 @@ | ||
package cn.crane4j.core.executor.key; | ||
|
||
import cn.crane4j.core.parser.operation.AssembleOperation; | ||
|
||
/** | ||
* <p>Key resolver provider | ||
* | ||
* @author huangchengxing | ||
* @since 2.7.0 | ||
*/ | ||
public interface KeyResolverProvider { | ||
|
||
/** | ||
* Get the resolver of the operation. | ||
* | ||
* @param operation operation | ||
* @return resolver | ||
*/ | ||
KeyResolver getResolver(AssembleOperation operation); | ||
} |
Oops, something went wrong.