public boolean isComplexType() { return typeInfo.isComplexType(); }
public boolean isComplexElementType() { return null != elementTypeInfo && elementTypeInfo.isComplexType(); }
/** * Returns true if the type is a complex type. */ default boolean isComplexType() { return getTypeInfo().isComplexType(); }
public SimpleProperty(Class<T> type, T value) { Args.notNull(type); this.type = type; this.complex = Types.getTypeInfo(type, null).isComplexType();; this.value = value; }
protected boolean validateMap(String name, Map map, Validation validation, int maxErrors) { TypeInfo typeInfo = null; for(Object item : map.entrySet()) { Map.Entry entry = (Map.Entry)item; Object value = entry.getValue(); if(null == value) { continue; } if(null == typeInfo) { typeInfo = Types.getTypeInfo(value.getClass()); } if(typeInfo.isComplexType() || typeInfo.isCollectionType()) { String fullName = Strings.nullToEmpty(name) + "['" + entry.getKey().toString() + "']"; if(!validate(fullName, value, validation, maxErrors) ){ return false; } } else { return true; } } return true; }
protected boolean validateArray(String name, Object[] array, Validation validation, int maxErrors) { TypeInfo typeInfo = null; for(int i=0;i<array.length;i++) { Object value = array[i]; if(value == null) { continue; } if(typeInfo == null) { typeInfo = Types.getTypeInfo(value.getClass()); } if(typeInfo.isComplexType() || typeInfo.isCollectionType()) { String fullName = Strings.nullToEmpty(name) + "[" + String.valueOf(i) + "]"; if(!validate(fullName, value, validation, maxErrors) ){ return false; } } else { return true; } } return true; }
protected boolean validateCollection(String name, Iterable iterable, Validation validation, int maxErrors) { int i=0; TypeInfo typeInfo = null; for(Object value : iterable) { if(value == null) { continue; } if(typeInfo == null) { typeInfo = Types.getTypeInfo(value.getClass()); } if(typeInfo.isComplexType() || typeInfo.isCollectionType()) { String fullName = Strings.nullToEmpty(name) + "[" + String.valueOf(i) + "]"; if(!validate(fullName, value, validation, maxErrors) ){ return false; } } else { return true; } i++; } return true; }
@Override public <T> Property<T> getDynaProperty(String name, Class<T> type) { if(null != propertyProvider) { try { Property<T> p = propertyProvider.getDynaProperty(name, type); return p; } catch (UnsupportedDynaPropertyException e) { log.info("property {0} unsupported by {1}, use local config",name,propertyProvider.getClass()); } } String v = properties.get(name); if(null == v || v.isEmpty()) { return new NullProperty<>(); } TypeInfo ti = Types.getTypeInfo(type,null); if(ti.isComplexType()) { return new SimpleProperty<>(type, JSON.decode(v, type)); }else{ return new SimpleProperty<>(type, Converts.convert(v, type)); } }