TerminalOperation (String name, PsiExpression[] args) { if ("get".equals(name) && args.length == 0) { return new Get(); } if ("orElse".equals(name) && args.length == 1) { return new OrElse(args[0].getText()); } if ("ifPresentOrElse".equals(name) && args.length == 2) { FunctionHelper ifPresentFn = FunctionHelper.create(args[0], 1); if (ifPresentFn == null) return null; FunctionHelper orElseFn = FunctionHelper.create(args[1], 0); return orElseFn == null ? null : new IfPresentOrElse(ifPresentFn, orElseFn); } if ("ifPresent".equals(name) && args.length == 1) { FunctionHelper fn = FunctionHelper.create(args[0], 1); return fn == null ? null : new IfPresent(fn); } if (("isPresent".equals(name) || "isEmpty".equals(name)) && args.length == 0) { return new IsPresent("isEmpty".equals(name)); } if ("orElseGet".equals(name) && args.length == 1) { FunctionHelper myFn = FunctionHelper.create(args[0], 0); return myFn == null ? null : new OrElseGet(myFn); } if ("orElseThrow".equals(name)) { if (args.length == 0) return new OrElseThrow(null); FunctionHelper myFn = args.length == 1 ? FunctionHelper.create(args[0], 0) : null; return myFn == null ? null : new OrElseThrow(myFn); } if ("stream".equals(name) && args.length == 0) { return new Stream(); } return null; }