public static < T > T getObjectFromAerospikeRecord ( Class < T > classEntity , AerospikeRecord aerospikeRecord , AerospikeDeepJobConfig aerospikeConfig ) throws IllegalAccessException , InstantiationException , InvocationTargetException { Tuple2 < String , Object > equalsFilter = aerospikeConfig . getEqualsFilter ( ) ; String equalsFilterBin = equalsFilter != null ? equalsFilter . _1 ( ) : null ; Object equalsFilterValue = equalsFilter != null ? equalsFilter . _2 ( ) : null ; Map < String , Object > bins = aerospikeRecord . bins ; T t = classEntity . newInstance ( ) ; if ( equalsFilter == null || checkEqualityFilter ( bins , equalsFilterBin , equalsFilterValue ) ) { Field [ ] fields = AnnotationUtils . filterDeepFields ( classEntity ) ; Object insert = null ; List < String > inputColumns = null ; if ( aerospikeConfig . getInputColumns ( ) != null ) { inputColumns = Arrays . asList ( aerospikeConfig . getInputColumns ( ) ) ; } for ( Field field : fields ) { if ( inputColumns != null && ! inputColumns . contains ( AnnotationUtils . deepFieldName ( field ) ) ) { continue ; } Object currentBin = null ; Method method = null ; Class < ? > classField = field . getType ( ) ; try { method = Utils . findSetter ( field . getName ( ) , classEntity , field . getType ( ) ) ; currentBin = bins . get ( AnnotationUtils . deepFieldName ( field ) ) ; if ( currentBin != null ) { if ( currentBin instanceof Integer && classField . equals ( Long . class ) ) { currentBin = new Long ( ( Integer ) currentBin ) ; } if ( currentBin instanceof String || currentBin instanceof Integer || currentBin instanceof Long ) { insert = currentBin ; } else { throw new DeepGenericException ( "Data type [" + classField . toString ( ) + "] not supported in Aerospike entity extractor (only Strings and Integers)" ) ; } method . invoke ( t , insert ) ; } } catch ( IllegalAccessException | InvocationTargetException | IllegalArgumentException e ) { LOG . error ( "impossible to create a java object from Bin:" + field . getName ( ) + " and type:" + field . getType ( ) + " and value:" + t + "; recordReceived:" + currentBin ) ; method . invoke ( t , Utils . castNumberType ( insert , classField ) ) ; } } } return t ; }
Converts from AerospikeRecord to an entity class with deep s anotations .