@VadimPushtaev/

single_dispatch

Java

No description

fork
loading
Files
  • Main.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6129028147460176","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"Y2xhc3MgVXNlciB7CiAgLy8gLi4uCn0KCmNsYXNzIEFkbWluVXNlciBleHRlbmRzIFVzZXIgewogIC8vIC4uLgp9CgpjbGFzcyBUcmlhbFVzZXIgZXh0ZW5kcyBVc2VyIHsKICAvLyAuLi4KfQoKaW50ZXJmYWNlIFJlcHJlc2VudGVyIHsKICBwdWJsaWMgU3RyaW5nIHJlcHJlc2VudChBZG1pblVzZXIgdXNlcik7CiAgcHVibGljIFN0cmluZyByZXByZXNlbnQoVHJpYWxVc2VyIHVzZXIpOwp9CgpjbGFzcyBKc29uUmVwcmVzZW50ZXIgaW1wbGVtZW50cyBSZXByZXNlbnRlciB7CiAgcHVibGljIFN0cmluZyByZXByZXNlbnQoQWRtaW5Vc2VyIHVzZXIpIHsKICAgIHJldHVybiAiYSI7CiAgfQoKICBwdWJsaWMgU3RyaW5nIHJlcHJlc2VudChUcmlhbFVzZXIgdXNlcikgewogICAgcmV0dXJuICJiIjsKICB9Cn0KCmNsYXNzIFN0cmluZ1JlcHJlc2VudGVyIGltcGxlbWVudHMgUmVwcmVzZW50ZXIgewogIHB1YmxpYyBTdHJpbmcgcmVwcmVzZW50KEFkbWluVXNlciB1c2VyKSB7CiAgICByZXR1cm4gImMiOwogIH0KCiAgcHVibGljIFN0cmluZyByZXByZXNlbnQoVHJpYWxVc2VyIHVzZXIpIHsKICAgIHJldHVybiAiZCI7CiAgfQp9CgpjbGFzcyBNYWluIHsKICB2b2lkIG1haW4oc3RyaW5nW10gYXJncykgewogICAgVXNlciB1c2VyID0gbmV3IEFkbWluVXNlcigpOwogICAgUmVwcmVzZW50ZXIgcmVwcmVzZW50ZXIgPSBuZXcgSnNvblJlcHJlc2VudGVyKCk7CiAgICAKICAgIHJlcHJlc2VudGVyLnJlcHJlc2VudCh1c2VyKTsKICB9Cn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class User {
  // ...
}

class AdminUser extends User {
  // ...
}

class TrialUser extends User {
  // ...
}

interface Representer {
  public String represent(AdminUser user);
  public String represent(TrialUser user);
}

class JsonRepresenter implements Representer {
  public String represent(AdminUser user) {
    return "a";
  }

  public String represent(TrialUser user) {
    return "b";
  }
}

class StringRepresenter implements Representer {
  public String represent(AdminUser user) {
    return "c";
  }

  public String represent(TrialUser user) {
    return "d";
  }
}

class Main {
  void main(string[] args) {
    User user = new AdminUser();
    Representer representer = new JsonRepresenter();
    
    representer.represent(user);
  }
}