public static ImmutableSet < OpenOption > getOptionsForChannel ( Set < ? extends OpenOption > options ) { if ( options . isEmpty ( ) ) { return DEFAULT_READ ; } boolean append = options . contains ( APPEND ) ; boolean write = append || options . contains ( WRITE ) ; boolean read = ! write || options . contains ( READ ) ; if ( read ) { if ( append ) { throw new UnsupportedOperationException ( "'READ' + 'APPEND' not allowed" ) ; } if ( ! write ) { // ignore all write related options return options . contains ( LinkOption . NOFOLLOW_LINKS ) ? DEFAULT_READ_NOFOLLOW_LINKS : DEFAULT_READ ; } } // options contains write or append and may also contain read // it does not contain both read and append return addWrite ( options ) ; }
Returns an immutable set of open options for opening a new file channel .