com.futuresight.util.mystique.CopyMystTurn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-mystique Show documentation
Show all versions of json-mystique Show documentation
Json Utility to transform Jsons
/*
* Copyright (c) Balajee TM 2016.
* All rights reserved.
* License - @see
*/
/*
* Created on 25 Aug, 2016 by balajeetm
*/
package com.futuresight.util.mystique;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Component;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
/**
* The Class CopyMystTurn.
*
* @author balajeetm
*/
@Component
public class CopyMystTurn extends AbstractMystTurn {
/* (non-Javadoc)
* @see com.futuresight.util.mystique.Mystique#transform(java.util.List, com.google.gson.JsonObject, java.lang.String)
*/
@Override
public JsonElement transmute(List source, JsonObject deps, JsonObject aces, JsonObject turn) {
JsonElement transform = null;
if (CollectionUtils.isNotEmpty(source)) {
if (source.size() > 1) {
transform = new JsonArray();
for (JsonElement jsonElement : source) {
JsonElement granularSource = getGranularSource(jsonElement, turn, deps, aces);
transform.getAsJsonArray().add(granularSource);
}
}
else {
transform = getGranularSource(source.get(0), turn, deps, aces);
}
}
return transform;
}
}