private Schema convertFieldToArraySchema(final FieldAccess fieldAccess) { String description = getDescription(fieldAccess); Schema componentSchema = mappings.get(fieldAccess.getComponentClass()); /* If it was not in the mapping, then it is complex. */ if (componentSchema == null) { if (!definitionMap.containsKey(fieldAccess.getComponentClass().getSimpleName())) { addClass(fieldAccess.getComponentClass()); } componentSchema = Schema.definitionRef(fieldAccess.getComponentClass().getSimpleName(), description); } return Schema.array(componentSchema); }
private Schema convertFieldToMapSchema(final FieldAccess fieldAccess) { final Type[] actualTypeArguments = fieldAccess.getParameterizedType().getActualTypeArguments(); final String description = getDescription(fieldAccess); if (actualTypeArguments[1] instanceof Class) { Schema componentSchema = mappings.get(actualTypeArguments[1]); /* If it was not in the mapping, then it is complex. */ if (componentSchema == null) { if (!definitionMap.containsKey(fieldAccess.getComponentClass().getSimpleName())) { addClass(fieldAccess.getComponentClass()); } componentSchema = Schema.definitionRef(fieldAccess.getComponentClass().getSimpleName(), ""); } return Schema.map(componentSchema, description); } else { return null; } }
public static Class<?> getComponentType( Collection<?> collection, FieldAccess fieldAccess ) { Class<?> clz = fieldAccess.getComponentClass(); if ( clz == null ) { clz = getComponentType( collection ); } return clz; }
public static Class<?> getComponentType( Collection<?> collection, FieldAccess fieldAccess ) { Class<?> clz = fieldAccess.getComponentClass(); if ( clz == null ) { clz = getComponentType( collection ); } return clz; }
private static void handleCollectionFieldCopy( Object dst, FieldAccess dstField, Collection srcValue ) { if ( dstField.getComponentClass () != Typ.string ) { Collection dstCollection = Conversions.createCollection( dstField.type(), srcValue.size() ); for ( Object srcComponentValue : srcValue ) { Object newInstance = Reflection.newInstance( dstField.getComponentClass() ); fieldByFieldCopy( srcComponentValue, newInstance ); dstCollection.add ( newInstance ); } dstField.setObject ( dst, dstCollection ); } else { Collection dstCollection = Conversions.createCollection( dstField.type(), srcValue.size() ); for ( Object srcComponentValue : srcValue ) { if (srcComponentValue!=null) { dstCollection.add ( srcComponentValue.toString () ); } } dstField.setObject ( dst, dstCollection ); } }
private static void handleCollectionFieldCopy( Object dst, FieldAccess dstField, Collection srcValue ) { if ( dstField.getComponentClass () != Typ.string ) { Collection dstCollection = Conversions.createCollection( dstField.type(), srcValue.size() ); for ( Object srcComponentValue : srcValue ) { Object newInstance = Reflection.newInstance( dstField.getComponentClass() ); fieldByFieldCopy( srcComponentValue, newInstance ); dstCollection.add ( newInstance ); } dstField.setObject ( dst, dstCollection ); } else { Collection dstCollection = Conversions.createCollection( dstField.type(), srcValue.size() ); for ( Object srcComponentValue : srcValue ) { if (srcComponentValue!=null) { dstCollection.add ( srcComponentValue.toString () ); } } dstField.setObject ( dst, dstCollection ); } }
/** * Processes an collection of maps. * @param newInstance new instance we are injecting field into * @param field field we are injecting a value into */ @SuppressWarnings("unchecked") private void handleCollectionOfMaps( Object newInstance, FieldAccess field, Collection<Map<String, Object>> collectionOfMaps ) { Collection<Object> newCollection = Conversions.createCollection( field.type(), collectionOfMaps.size() ); Class<?> componentClass = field.getComponentClass(); if ( componentClass != null ) { for ( Map<String, Object> mapComponent : collectionOfMaps ) { newCollection.add( fromMap( mapComponent, componentClass ) ); } field.setObject( newInstance, newCollection ); } }
/** * Processes an collection of maps. * @param newInstance new instance we are injecting field into * @param field field we are injecting a value into */ @SuppressWarnings("unchecked") private void handleCollectionOfMaps( Object newInstance, FieldAccess field, Collection<Map<String, Object>> collectionOfMaps ) { Collection<Object> newCollection = Conversions.createCollection( field.type(), collectionOfMaps.size() ); Class<?> componentClass = field.getComponentClass(); if ( componentClass != null ) { for ( Map<String, Object> mapComponent : collectionOfMaps ) { newCollection.add( fromMap( mapComponent, componentClass ) ); } field.setObject( newInstance, newCollection ); } }
/** * Processes an collection of maps. * @param newInstance new instance we are injecting field into * @param field field we are injecting a value into */ @SuppressWarnings("unchecked") private void handleCollectionOfMaps( Object newInstance, FieldAccess field, Collection<Map<String, Object>> collectionOfMaps ) { Collection<Object> newCollection = Conversions.createCollection( field.type(), collectionOfMaps.size() ); Class<?> componentClass = field.getComponentClass(); if ( componentClass != null ) { for ( Map<String, Object> mapComponent : collectionOfMaps ) { newCollection.add( fromMap( mapComponent, componentClass ) ); } field.setObject( newInstance, newCollection ); } }
/** * Processes an collection of maps. * @param newInstance new instance we are injecting field into * @param field field we are injecting a value into */ @SuppressWarnings("unchecked") private void handleCollectionOfMaps( Object newInstance, FieldAccess field, Collection<Map<String, Object>> collectionOfMaps ) { Collection<Object> newCollection = Conversions.createCollection( field.type(), collectionOfMaps.size() ); Class<?> componentClass = field.getComponentClass(); if ( componentClass != null ) { for ( Map<String, Object> mapComponent : collectionOfMaps ) { newCollection.add( fromMap( mapComponent, componentClass ) ); } field.setObject( newInstance, newCollection ); } }
case ARRAY_STRING: case ARRAY_OBJECT: if (Typ.isBasicType( access.getComponentClass() )) { map.put(fieldName, value); } else { case SET: Collection<?> collection = ( Collection<?> ) value; Class<?> componentType = access.getComponentClass(); if ( Typ.isBasicType( componentType ) ) { map.put(fieldName, value);
case ARRAY_STRING: case ARRAY_OBJECT: if (Typ.isBasicType( access.getComponentClass() )) { map.put(fieldName, value); } else { case SET: Collection<?> collection = ( Collection<?> ) value; Class<?> componentType = access.getComponentClass(); if ( Typ.isBasicType( componentType ) ) { map.put(fieldName, value);
final FieldAccess field, final Collection<?> collection ) { final Class<?> fieldComponentClass = field.getComponentClass(); if (collection instanceof List) { try { Object value = fromList( (List) collection, field.getComponentClass()); field.setValue(newInstance, value); } catch (Exception ex) {
final FieldAccess field, final Collection<?> collection ) { final Class<?> fieldComponentClass = field.getComponentClass(); if (collection instanceof List) { try { Object value = fromList( (List) collection, field.getComponentClass()); field.setValue(newInstance, value); } catch (Exception ex) {
final FieldAccess field, final Collection<?> collection ) { final Class<?> fieldComponentClass = field.getComponentClass(); if (collection instanceof List) { try { Object value = fromList( (List) collection, field.getComponentClass()); field.setValue(newInstance, value); } catch (Exception ex) {
final FieldAccess field, final Collection<?> collection ) { final Class<?> fieldComponentClass = field.getComponentClass(); if (collection instanceof List) { try { Object value = fromList( (List) collection, field.getComponentClass()); field.setValue(newInstance, value); } catch (Exception ex) {
Object dst = Array.newInstance(field.getComponentClass(), length);
Object dst = Array.newInstance(field.getComponentClass(), length);
if ( srcValue instanceof Collection && dstField.getComponentClass() != null && Typ.isCollection ( dstField.type() ) ) {
if ( srcValue instanceof Collection && dstField.getComponentClass() != null && Typ.isCollection ( dstField.type() ) ) {