@Override protected Plugin parse(Object json) { WSUtils utils = WSUtils.getINSTANCE(); return new Plugin() .setKey(utils.getString(json, "key")) .setName(utils.getString(json, "name")) .setVersion(utils.getString(json, "version")); }
private TimeMachineColumn[] toColumns(Object cols) { WSUtils utils = WSUtils.getINSTANCE(); int size = utils.getArraySize(cols); TimeMachineColumn[] result = new TimeMachineColumn[size]; for (int index = 0; index < size; index++) { Object colJson = utils.getArrayElement(cols, index); result[index] = new TimeMachineColumn(index, utils.getString(colJson, "metric"), null, null); } return result; }
private TimeMachineCell[] toCells(Object cells) { WSUtils utils = WSUtils.getINSTANCE(); int size = utils.getArraySize(cells); TimeMachineCell[] result = new TimeMachineCell[size]; for (int i = 0; i < size; i++) { Object cellJson = utils.getArrayElement(cells, i); Object valuesJson = utils.getField(cellJson, "v"); Object[] resultValues = new Object[utils.getArraySize(valuesJson)]; for (int indexValue = 0; indexValue < utils.getArraySize(valuesJson); indexValue++) { Object value = utils.getArrayElement(valuesJson, indexValue); resultValues[indexValue] = value; } result[i] = new TimeMachineCell(utils.getDateTime(cellJson, "d"), resultValues); } return result; }
protected TimeMachine parse(Object json) { WSUtils utils = WSUtils.getINSTANCE(); Object cols = utils.getField(json, "cols"); Object cells = utils.getField(json, "cells"); return new TimeMachine(toColumns(cols), toCells(cells)); }