public static List < Permission > id2Permissions ( int id ) { List < Permission > list = new ArrayList < Permission > ( ) ; if ( id <= 0 || id > 31 ) { list . add ( Permission . NONE ) ; } else { if ( ( id & Permission . READ . getId ( ) ) != 0 ) { list . add ( Permission . READ ) ; } if ( ( id & Permission . WRITE . getId ( ) ) != 0 ) { list . add ( Permission . WRITE ) ; } if ( ( id & Permission . CREATE . getId ( ) ) != 0 ) { list . add ( Permission . CREATE ) ; } if ( ( id & Permission . DELETE . getId ( ) ) != 0 ) { list . add ( Permission . DELETE ) ; } if ( ( id & Permission . ADMIN . getId ( ) ) != 0 ) { list . add ( Permission . ADMIN ) ; } } return list ; }
Transfer the permission id to Permission list .