[Major] Changes in FlatJsonVisitor
This commit is contained in:
parent
c89e04a356
commit
e27a0969ee
|
@ -15,23 +15,23 @@ import li.strolch.utils.collections.MapOfSets;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Maps a given {@link JsonObject} to a {@link StrolchRootElement}. All {@link Parameter Parameters} on the element are
|
* Maps a given {@link JsonObject} to a {@link StrolchRootElement}. All {@link Parameter Parameters} on the element are
|
||||||
* iterated expected to be found as a member on the {@link JsonObject}.
|
* iterated and expected to be found as a member on the {@link JsonObject}.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* To not map a {@link Parameter} add it to the {@link MapOfSets}, to ignore a whole {@link ParameterBag} then add an
|
* To ignore {@link Parameter Parameters} or {@link ParameterBag ParameterBags} use the
|
||||||
* empty set with the bag id.
|
* {@link #ignoreParameter(String, String)} and {@link #ignoreBag(String)} methods
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Optional values are handled similar, but only a parameter can be optional, not a whole bag
|
* {@link Parameter} can be made optional by using the {@link #optionalParameter(String, String)} method
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
public class FromFlatJsonVisitor<T extends StrolchRootElement> {
|
public class FromFlatJsonVisitor {
|
||||||
|
|
||||||
private MapOfSets<String, String> ignoredKeys;
|
private MapOfSets<String, String> ignoredKeys;
|
||||||
private MapOfSets<String, String> optionalKeys;
|
private MapOfSets<String, String> optionalKeys;
|
||||||
|
@ -58,7 +58,7 @@ public class FromFlatJsonVisitor<T extends StrolchRootElement> {
|
||||||
this.optionalKeys.addElement(bagId, paramId);
|
this.optionalKeys.addElement(bagId, paramId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visit(T element, JsonObject jsonObject) {
|
public void visit(StrolchRootElement element, JsonObject jsonObject) {
|
||||||
|
|
||||||
Set<String> bagKeySet = element.getParameterBagKeySet();
|
Set<String> bagKeySet = element.getParameterBagKeySet();
|
||||||
for (String bagId : bagKeySet) {
|
for (String bagId : bagKeySet) {
|
||||||
|
|
|
@ -21,14 +21,24 @@ import li.strolch.utils.collections.MapOfSets;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Maps a given {@link StrolchRootElement} to a {@link JsonObject}. All {@link Parameter Parameters} are mapped to a
|
* Maps a given {@link StrolchRootElement} to a {@link JsonObject}. All {@link Parameter Parameters} are mapped to a
|
||||||
* member of the {@link JsonObject}.
|
* member of the {@link JsonObject}, {@link ParameterBag ParameterBags} are thus removed
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* To not map a {@link Parameter} add it to the {@link MapOfSets}, to ignore a whole {@link ParameterBag} then add an
|
* To ignore {@link Parameter Parameters} or {@link ParameterBag ParameterBags} use the
|
||||||
* empty set with the bag id.
|
* {@link #ignoreParameter(String, String)} and {@link #ignoreBag(String)} methods
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
* <p>
|
||||||
|
* The mapping can be extended by setting hook:
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* visitor.setHook((element, jsonObject) -> {
|
||||||
|
* // do work
|
||||||
|
* });
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class ToFlatJsonVisitor<T extends StrolchRootElement> {
|
public class ToFlatJsonVisitor<T extends StrolchRootElement> {
|
||||||
|
|
|
@ -13,7 +13,14 @@ import li.strolch.service.api.ServiceArgument;
|
||||||
*/
|
*/
|
||||||
public class JsonServiceArgument extends ServiceArgument {
|
public class JsonServiceArgument extends ServiceArgument {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public String baseUrl;
|
|
||||||
|
/**
|
||||||
|
* the objectId - its context is defined by the service
|
||||||
|
*/
|
||||||
public String objectId;
|
public String objectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The input object
|
||||||
|
*/
|
||||||
public JsonElement jsonElement;
|
public JsonElement jsonElement;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue