private static boolean isAppropriateDevice(MidiDevice device,Class deviceClass,boolean allowSynthesizer,boolean allowSequencer){
  if (deviceClass.isInstance(device)) {
    return true;
  }
 else {
    if ((!(device instanceof Sequencer) && !(device instanceof Synthesizer)) || ((device instanceof Sequencer) && allowSequencer) || ((device instanceof Synthesizer) && allowSynthesizer)) {
      if ((deviceClass == Receiver.class && device.getMaxReceivers() != 0) || (deviceClass == Transmitter.class && device.getMaxTransmitters() != 0)) {
        return true;
      }
    }
  }
  return false;
}

private static boolean isAppropriateDevice ( MidiDevice device , Class deviceClass , boolean allowSynthesizer , boolean allowSequencer ) { if ( deviceClass . isInstance ( device ) ) { return true ; } else { if ( ( ! ( device instanceof Sequencer ) && ! ( device instanceof Synthesizer ) ) || ( ( device instanceof Sequencer ) && allowSequencer ) || ( ( device instanceof Synthesizer ) && allowSynthesizer ) ) { if ( ( deviceClass == Receiver . class && device . getMaxReceivers ( ) != 0 ) || ( deviceClass == Transmitter . class && device . getMaxTransmitters ( ) != 0 ) ) { return true ; } } } return false ; }
checks if a mididevice is appropriate . if deviceclass is synthesizer or sequencer , a device implementing the respective interface is considered appropriate . if deviceclass is receiver or transmitter , a device is considered appropriate if it implements neither synthesizer nor transmitter , and if it can provide at least one receiver or transmitter , respectively .
