-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tsl): EITHER action omitting displaying message
Closes #21
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
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
57 changes: 57 additions & 0 deletions
57
src/main/java/net/programmer/igoodie/twitchspawn/configuration/validation/JSONValidator.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,57 @@ | ||
package net.programmer.igoodie.twitchspawn.configuration.validation; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import java.util.Map; | ||
|
||
public class JSONValidator { | ||
|
||
private JsonObject actualJson; | ||
private JsonObject expectedJson; | ||
private JsonObject builtJson; | ||
|
||
public JSONValidator(String actualScript, String defaultScript) { | ||
Gson gson = new Gson(); | ||
this.actualJson = gson.fromJson(actualScript, JsonObject.class); | ||
this.expectedJson = gson.fromJson(actualScript, JsonObject.class); | ||
this.builtJson = new JsonObject(); | ||
} | ||
|
||
public boolean isValid() { | ||
return false; // TODO | ||
} | ||
|
||
public JsonObject validate() { | ||
|
||
|
||
return builtJson; | ||
} | ||
|
||
private JsonObject validate(JsonObject actualJson, JsonObject expectedJson) { | ||
JsonObject validated = new JsonObject(); | ||
|
||
// Traverse each key-value pair in Expected JSON | ||
for (Map.Entry<String, JsonElement> property : expectedJson.entrySet()) { | ||
String key = property.getKey(); | ||
JsonElement expectedValue = property.getValue(); | ||
|
||
// Value in the Expected JSON is a primitive | ||
// if (expectedValue.isJsonPrimitive()) { | ||
// validated.add(key, actualJson.has(key) && actualJson.get(key).getClass() | ||
// ? actualJson.get(key) | ||
// : expectedValue); | ||
// } | ||
|
||
// Value in the Expected JSON is an array | ||
if(expectedValue.isJsonArray()) { | ||
|
||
} | ||
} | ||
|
||
return validated; | ||
} | ||
|
||
} |
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