public static final VirtualCircuit create ( ByteChannel ch1 , ByteChannel ch2 , int capacity , boolean direct ) { if ( ( ch1 instanceof SelectableChannel ) && ( ch2 instanceof SelectableChannel ) ) { SelectableChannel sc1 = ( SelectableChannel ) ch1 ; SelectableChannel sc2 = ( SelectableChannel ) ch2 ; return new SelectableVirtualCircuit ( sc1 , sc2 , capacity , direct ) ; } else { if ( ( ch1 instanceof SelectableBySelector ) && ( ch2 instanceof SelectableBySelector ) ) { SelectableBySelector sbs1 = ( SelectableBySelector ) ch1 ; SelectableBySelector sbs2 = ( SelectableBySelector ) ch2 ; return new SelectableVirtualCircuit ( sbs1 . getSelector ( ) , sbs2 . getSelector ( ) , ch1 , ch2 , capacity , direct ) ; } else { return new ByteChannelVirtualCircuit ( ch1 , ch2 , capacity , direct ) ; } } }
Creates either SelectableVirtualCircuit or ByteChannelVirtualCircuit depending on channel .