-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tags: new tag feature with service aggregation and custom module support
- Loading branch information
Showing
13 changed files
with
203 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.noleme.vault.container.definition; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
/** | ||
* @author Pierre LECERF ([email protected]) | ||
* Created on 08/05/2021 | ||
|
@@ -8,11 +10,13 @@ public class Tag | |
{ | ||
private final String identifier; | ||
private final String service; | ||
private final ObjectNode node; | ||
|
||
public Tag(String identifier, String service) | ||
public Tag(String identifier, String service, ObjectNode node) | ||
{ | ||
this.identifier = identifier; | ||
this.service = service; | ||
this.node = node; | ||
} | ||
|
||
public String getIdentifier() | ||
|
@@ -24,4 +28,9 @@ public String getService() | |
{ | ||
return this.service; | ||
} | ||
|
||
public ObjectNode getNode() | ||
{ | ||
return this.node; | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/noleme/vault/parser/module/TagModule.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,49 @@ | ||
package com.noleme.vault.parser.module; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.noleme.vault.container.definition.Definitions; | ||
import com.noleme.vault.container.definition.ServiceTag; | ||
import com.noleme.vault.exception.VaultParserException; | ||
|
||
import static com.noleme.commons.function.RethrowConsumer.rethrower; | ||
|
||
/** | ||
* @author Pierre LECERF ([email protected]) | ||
* Created on 10/05/2021 | ||
*/ | ||
public class TagModule implements VaultModule | ||
{ | ||
@Override | ||
public String identifier() | ||
{ | ||
return "tags"; | ||
} | ||
|
||
@Override | ||
public void process(ObjectNode json, Definitions definitions) throws VaultParserException | ||
{ | ||
json.fields().forEachRemaining(rethrower(entry -> { | ||
String identifier = entry.getKey(); | ||
ObjectNode tagNode = (ObjectNode) entry.getValue(); | ||
|
||
if (tagNode.has("identifier") && !identifier.equals(tagNode.get("identifier").asText())) | ||
throw new VaultParserException("A tag was declared with conflicting identifiers, the shorthand notation '"+identifier+"' is different from the 'identifier' field of value '"+tagNode.get("identifier").asText()+"' found in the declaration "); | ||
|
||
tagNode.put("identifier", identifier); | ||
|
||
this.extractTag(tagNode, definitions); | ||
})); | ||
} | ||
|
||
/** | ||
* | ||
* @param definition | ||
* @param definitions | ||
*/ | ||
private void extractTag(ObjectNode definition, Definitions definitions) | ||
{ | ||
String identifier = definition.get("identifier").asText(); | ||
|
||
definitions.services().set(identifier, new ServiceTag(identifier)); | ||
} | ||
} |
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
Oops, something went wrong.