@ Override public int compareTo ( StructureName o ) { if ( this . equals ( o ) ) return 0 ; String pdb1 = null ; String pdb2 = null ; try { pdb1 = this . getPdbId ( ) ; } catch ( StructureException e ) { } try { pdb2 = this . getPdbId ( ) ; } catch ( StructureException e ) { } int comp = 0 ; // Sort those with PDBIDs before those without if ( pdb1 == null ) { if ( pdb2 != null ) { return 1 ; // this > o } // both null } else if ( pdb2 == null ) { return - 1 ; // this < o } else { // neither null comp = pdb1 . compareTo ( pdb2 ) ; } if ( comp != 0 ) { return comp ; } // break tie with full identifiers pdb1 = this . getIdentifier ( ) ; pdb2 = o . getIdentifier ( ) ; // Throws NPE for nulls return pdb1 . compareTo ( pdb2 ) ; }
Orders identifiers lexicographically by PDB ID and then full Identifier