net.sf.aguacate.configuration.field.FieldStructureArray Maven / Gradle / Ivy
package net.sf.aguacate.configuration.field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.aguacate.validator.ValidationConversionResult;
/**
*
* "field": {
* "type": "STRUCTURE_ARRAY",
* "data": {
* "innerField1": {
* "type": "INTEGER",
* "minval": ...,
* "maxval": ...
* },
* "innerField2": {
* "type" : "STRING",
* "minlen": ...,
* "maxlen": ...,
* "regex": ...
* }
* }
* }
*
*
*/
public class FieldStructureArray extends Field {
private final Field[] fields;
public FieldStructureArray(String name, boolean optional, Map fields) {
this(name, optional, fields.values());
}
public FieldStructureArray(String name, boolean optional, Collection fields) {
this(name, optional, fields.toArray(new Field[fields.size()]));
}
public FieldStructureArray(String name, boolean optional, Field[] fields) {
super(name, Field.STRUCTURE_ARRAY, optional);
this.fields = fields;
}
@Override
public ValidationConversionResult validateAndConvert(Object value) {
@SuppressWarnings("unchecked")
List