ModCommand () { if (myRenameSymbol != null && !myTemplateFields.isEmpty()) { throw new IllegalStateException("Cannot have both rename and template commands"); } if (myErrorMessage != null) { return error(myErrorMessage); } return myChangedFiles.values().stream() .map(fileTracker -> fileTracker.getUpdateCommand()).reduce(nop(), ModCommand::andThen) .andThen(myChangedDirectories.values().stream() .flatMap(info -> info.createFileCommands(myTracker.myProject)) .reduce(nop(), ModCommand::andThen)) .andThen(getNavigateCommand()).andThen(getHighlightCommand()).andThen(getTemplateCommand()) .andThen(myTrackedDeclarations.stream().<ModCommand>map(c -> c).reduce(nop(), ModCommand::andThen)) .andThen(myRenameSymbol == null ? nop() : myRenameSymbol) .andThen(myInfoMessage == null ? nop() : ModCommand.info(myInfoMessage)); }