use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project Engine by VoltzEngine-Project.
the class EffectJsonProcessor method process.
@Override
public EffectLayer process(JsonElement element) {
final JsonObject effectDataJson = element.getAsJsonObject();
ensureValuesExist(effectDataJson, "effectID", "key");
String effectID = effectDataJson.get("effectID").getAsString();
String key = effectDataJson.get("key").getAsString().toLowerCase();
EffectLayer data = new EffectLayer(this, key, effectID);
processAdditionalKeys(data, effectDataJson);
return data;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project Engine by VoltzEngine-Project.
the class JsonBlockListenerProcessor method process.
@Override
public void process(BlockBase block, JsonElement arrayElement, List<IJsonGenObject> objectList) {
JsonArray array = arrayElement.getAsJsonArray();
for (JsonElement element : array) {
String key = null;
JsonObject data = null;
if (element.isJsonPrimitive()) {
key = element.getAsString().toLowerCase();
} else if (element.isJsonObject()) {
JsonObject object = element.getAsJsonObject();
JsonProcessor.ensureValuesExist(object, "id");
key = object.get("id").getAsString().toLowerCase();
data = object;
}
if (builders.containsKey(key)) {
ITileEventListener listener = builders.get(key).createListener(block);
if (listener != null) {
if (data != null) {
if (!injectionMaps.containsKey(listener.getClass())) {
injectionMaps.put(listener.getClass(), new JsonProcessorInjectionMap(listener.getClass()));
}
JsonProcessorInjectionMap injectionMap = injectionMaps.get(listener.getClass());
for (Map.Entry<String, JsonElement> entry : data.entrySet()) {
injectionMap.handle(listener, entry.getKey(), entry.getValue());
}
}
block.addListener(listener);
}
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project Engine by VoltzEngine-Project.
the class JsonBlockProcessor method process.
@Override
public boolean process(JsonElement element, List<IJsonGenObject> objectList) {
debugPrinter.start("BlockProcessor", "Processing entry", Engine.runningAsDev);
//Get object and ensure minimal keys exist
JsonObject blockData = element.getAsJsonObject();
ensureValuesExist(blockData, "name", "id", "mod");
//Load default data
String mod = blockData.getAsJsonPrimitive("mod").getAsString();
String id = blockData.getAsJsonPrimitive("id").getAsString();
String name = blockData.get("name").getAsString();
debugPrinter.log("Name: " + name);
debugPrinter.log("Mod: " + mod);
debugPrinter.log("ID: " + id);
//Generate object
BlockPropertyData blockPropertyData = new BlockPropertyData(this, id, mod, name);
//Load blocks
BlockBase block;
//Meta data loading
if (blockData.has("subtypes")) {
blockPropertyData.localization += "." + BlockMeta.META_LOCAL_KEY;
block = new BlockMeta(blockPropertyData);
//Call to load metadata
readMeta((BlockMeta) block, blockData.get("subtypes").getAsJsonArray(), objectList);
} else //No meta data
{
block = new BlockBase(blockPropertyData);
}
processAdditionalKeys(blockPropertyData, blockData, block, objectList);
//Add block to object list
objectList.add(block);
debugPrinter.end("Done...");
return true;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project Engine by VoltzEngine-Project.
the class JsonBlockProcessor method readMeta.
/**
* Reads the meta data stored in the subtypes entry
*
* @param block - meta block, unregistered
* @param array - array of subtypes
*/
public void readMeta(BlockMeta block, JsonArray array, List<IJsonGenObject> objectList) {
//Loop every entry in the array, each entry should be meta values
for (int i = 0; i < array.size() && i < 16; i++) {
JsonObject json = array.get(i).getAsJsonObject();
MetaData meta = new MetaData();
//Reads the meta entry and then returns the meta to assign
int m = readMetaEntry(block, meta, json, objectList);
//Meta of -1 is invalid
if (m != -1) {
//Meta is locked to 0-15
if (m >= 0 && m < 16) {
//Prevent overriding by mistake
if (block.metaDataValues[m] == null) {
meta.index = m;
block.metaDataValues[m] = meta;
} else {
throw new IllegalArgumentException("JsonBlockProcessor: Meta value[" + m + "] was overridden inside the same file for block " + block.data.name);
}
} else {
throw new IllegalArgumentException("JsonBlockProcessor: Meta values are restricted from 0 to 15");
}
} else {
throw new IllegalArgumentException("JsonBlockProcessor: Each meta entry requires the value 'meta' of type Integer");
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project Engine by VoltzEngine-Project.
the class JsonMissingMapEventProcessor method process.
@Override
public IJsonGenObject process(JsonElement element) {
JsonObject data = element.getAsJsonObject();
JsonProcessor.ensureValuesExist(data, "oldValue", "newValue");
String oldValue = data.get("oldValue").getAsString().trim();
String newValue = data.get("newValue").getAsString().trim();
if (!oldValue.isEmpty() && !newValue.isEmpty()) {
if (oldValue.contains(":") && newValue.contains(":")) {
mappings.put(oldValue, newValue);
} else {
throw new IllegalArgumentException("Old and New value must contain : noting 'domain:name' ex: 'icbm:silo'");
}
} else {
throw new IllegalArgumentException("Old and New value for missing mapping can not be empty");
}
return null;
}
Aggregations