private List < DColumn > loadAttributes ( Map < String , AttributeValue > attributeMap , Predicate < String > colNamePredicate ) { List < DColumn > columns = new ArrayList <> ( ) ; if ( attributeMap != null ) { for ( Map . Entry < String , AttributeValue > mapEntry : attributeMap . entrySet ( ) ) { String colName = mapEntry . getKey ( ) ; if ( ! colName . equals ( DynamoDBService . ROW_KEY_ATTR_NAME ) && // Don't add row key attribute as a column colNamePredicate . test ( colName ) ) { AttributeValue attrValue = mapEntry . getValue ( ) ; if ( attrValue . getB ( ) != null ) { columns . add ( new DColumn ( colName , Utils . getBytes ( attrValue . getB ( ) ) ) ) ; } else if ( attrValue . getS ( ) != null ) { String value = attrValue . getS ( ) ; if ( value . equals ( DynamoDBService . NULL_COLUMN_MARKER ) ) { value = "" ; } columns . add ( new DColumn ( colName , value ) ) ; } else { throw new RuntimeException ( "Unknown AttributeValue type: " + attrValue ) ; } } } } // Sort or reverse sort column names. Collections . sort ( columns , new Comparator < DColumn > ( ) { @ Override public int compare ( DColumn col1 , DColumn col2 ) { return col1 . getName ( ) . compareTo ( col2 . getName ( ) ) ; } } ) ; return columns ; }
Filter store and sort attributes from the given map .