Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1001701 // makeResponder

JavaX fragment (include)

static S makeResponder_callAnswerMethod(O bot, S s, L<S> history) {
  S answer = (S) callOpt(bot, "answer", s, history);
  if (answer == null)
    answer = (S) callOpt(bot, "answer", s);
  return answer;
}

static Responder makeResponder(final O bot) {
  if (bot instanceof Responder) ret (Responder) bot;
  
  if (bot instanceof S) {
    S f = cast bot;
    ret new Responder {
      public S answer(S s, L<S> history) {
        S answer = (S) callOptMC((S) bot, s, history);
        if (answer == null)
          answer = (S) callOptMC((S) bot, s);
        return answer;
      }
    };
  }
  
  ret new Responder {
    public S answer(S s, L<S> history) {
      return makeResponder_callAnswerMethod(bot, s, history);
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001701
Snippet name: makeResponder
Eternal ID of this version: #1001701/3
Text MD5: 0480dd2bb6c2ef495e4d9fe1de507562
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-01 15:53:58
Source code size: 760 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 712 / 1027
Version history: 2 change(s)
Referenced in: [show references]