private boolean isOptional(FieldAccess fieldAccess) { return (fieldAccess.type() == Optional.class); }
private Schema convertFieldToDefinitionRef(final FieldAccess fieldAccess) { if (!definitionMap.containsKey(fieldAccess.type().getSimpleName())) { addClass(fieldAccess.type()); } final String description = getDescription(fieldAccess); return Schema.definitionRef(fieldAccess.type().getSimpleName(), description); }
private Schema convertFieldToSchema(final FieldAccess fieldAccess) { try { final Class<?> type = fieldAccess.type(); final Schema schema = mappings.get(type); final String description = getDescription(fieldAccess); if (schema != null) { if (description == null) { return schema; } else { return Schema.schemaWithDescription(schema, description); } } return convertFieldToComplexSchema(fieldAccess); } catch (Exception ex) { logger.warn("unable to convert field " + fieldAccess.name() + " from " + fieldAccess.declaringParent(), ex); return Schema.schemaWithFormat("error", "error.see.logs"); } }
/** * Get property value, loads nested properties * * @param root root * @param property property * @return type at this prop path */ public static Class<?> getPropertyType( final Object root, final String property ) { Map<String, FieldAccess> fields = getPropertyFieldAccessMap( root.getClass() ); FieldAccess field = fields.get(property); return field.type(); }
/** * Get property value, loads nested properties * * @param root root * @param property property * @return type at this prop path */ public static Class<?> getPropertyType( final Object root, final String property ) { Map<String, FieldAccess> fields = getPropertyFieldAccessMap( root.getClass() ); FieldAccess field = fields.get(property); return field.type(); }
/** * Get Property Path TypeType * @param root root * @param properties properties forming a path * @return class */ public static Class<?> getPropertyPathType( final Object root, final String... properties ) { Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); final String lastProperty = properties[ properties.length - 1 ]; FieldAccess field = fields.get( lastProperty ); return field.type(); }
/** * Get Property Path TypeType * @param root root * @param properties properties forming a path * @return class */ public static Class<?> getPropertyPathType( final Object root, final String... properties ) { Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); final String lastProperty = properties[ properties.length - 1 ]; FieldAccess field = fields.get( lastProperty ); return field.type(); }
private static String getPropertyString(Object root, String[] properties) { Object object = baseForGetProperty(root, properties); Map<String, FieldAccess> fields = getFieldsFromObject( object ); final String lastProperty = properties[ properties.length - 1 ]; FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.string ) { return (String) field.getObject( object ); } else { return Conversions.toString(field.getValue(object)); } }
private static String getPropertyString(Object root, String[] properties) { Object object = baseForGetProperty(root, properties); Map<String, FieldAccess> fields = getFieldsFromObject( object ); final String lastProperty = properties[ properties.length - 1 ]; FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.string ) { return (String) field.getObject( object ); } else { return Conversions.toString(field.getValue(object)); } }
public static int getPropertyInt( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toInt(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); FieldAccess field = fields.get(lastProperty); if ( field.type() == Typ.intgr ) { return field.getInt( object ); } else { return Conversions.toInt(field.getValue(object)); } }
public static float getPropertyFloat( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toFloat(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.flt ) { return field.getFloat( object ); } else { return Conversions.toFloat( field.getValue( object ) ); } }
public static float getPropertyFloat( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toFloat(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.flt ) { return field.getFloat( object ); } else { return Conversions.toFloat( field.getValue( object ) ); } }
public static int getPropertyInt( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toInt(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); FieldAccess field = fields.get(lastProperty); if ( field.type() == Typ.intgr ) { return field.getInt( object ); } else { return Conversions.toInt(field.getValue(object)); } }
public static short getPropertyShort( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toShort(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.shrt ) { return field.getShort( object ); } else { return Conversions.toShort( field.getValue( object ) ); } }
public static double getPropertyDouble( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toDouble(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.dbl ) { return field.getDouble( object ); } else { return Conversions.toDouble( field.getValue( object ) ); } }
public static char getPropertyChar( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toChar(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.chr ) { return field.getChar( object ); } else { return Conversions.toChar( field.getValue( object ) ); } }
public static char getPropertyChar( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toChar(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.chr ) { return field.getChar( object ); } else { return Conversions.toChar( field.getValue( object ) ); } }
public static double getPropertyDouble( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toDouble(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.dbl ) { return field.getDouble( object ); } else { return Conversions.toDouble( field.getValue( object ) ); } }
public static long getPropertyLong( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toLong(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.lng ) { return field.getLong( object ); } else { return Conversions.toLong( field.getValue( object ) ); } }
public static long getPropertyLong( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toLong(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject( object ); FieldAccess field = fields.get( lastProperty ); if ( field.type() == Typ.lng ) { return field.getLong( object ); } else { return Conversions.toLong( field.getValue( object ) ); } }