public Assignment update ( Border border ) { Arrays . sort ( cs ) ; int j = 1 ; boolean found = ( cs [ 0 ] . core == border . core ) ; for ( int i = 1 ; i < cs . length ; i ++ ) { if ( cs [ i ] . core != cs [ i - 1 ] . core ) { cs [ j ++ ] = cs [ i ] ; } found |= ( cs [ i ] . core == border . core ) ; } if ( found ) { if ( j == 1 ) { Border r = cs [ 0 ] ; cs = null ; // Prevent further use return r ; } if ( j < cs . length ) { cs = Arrays . copyOf ( cs , j ) ; } return this ; } if ( j + 1 != cs . length ) { cs = Arrays . copyOf ( cs , j + 1 ) ; } cs [ j ] = border ; return this ; }
Add a new border to the existing borders .