|
| 1 | +/* |
| 2 | + * This source file was generated by the Gradle 'init' task |
| 3 | + */ |
| 4 | +package org.example; |
| 5 | + |
| 6 | +import java.util.concurrent.CompletableFuture; |
| 7 | + |
| 8 | + |
| 9 | +public class App { |
| 10 | + |
| 11 | + public String a = "a"; |
| 12 | + public String b = "b"; |
| 13 | + public boolean c = false; |
| 14 | + |
| 15 | + public void aa() |
| 16 | + { |
| 17 | + var a = 1; |
| 18 | + Object b = 2; |
| 19 | + System.out.println("HEREEEE::" + a); |
| 20 | + var data = new java.util.HashMap<String, Object>() {{ |
| 21 | + put( "1", 1 ); |
| 22 | + put( "2", 2 ); |
| 23 | + }}; |
| 24 | + var lista = new java.util.ArrayList<Object>(java.util.Arrays.asList(1, 3, 4, "5")); |
| 25 | + Helpers.GetValue(data, "1"); |
| 26 | + Aux.fix(); |
| 27 | + // System.out.println(a); |
| 28 | + // System.out.println(data["1"]); |
| 29 | + // System.out.println(lista[2]); |
| 30 | + // for (var i = 0; isLessThan(i, getArrayLength(lista)); i++) |
| 31 | + // { |
| 32 | + // System.out.println(lista[i]); |
| 33 | + // } |
| 34 | + } |
| 35 | + |
| 36 | + public void test() { |
| 37 | + System.out.println("test"); |
| 38 | + } |
| 39 | + |
| 40 | + public void retryingTask(int... retries) { |
| 41 | + int n = (retries.length == 0) ? 3 : retries[0]; // default = 3 |
| 42 | + System.out.println("n: " + n); |
| 43 | + // ... |
| 44 | + } |
| 45 | + |
| 46 | + public String getGreeting() { |
| 47 | + var i = 1; |
| 48 | + i += 1; |
| 49 | + var a = "aaa"; |
| 50 | + a += "bbb"; |
| 51 | + // var c = new HashMap<String, String>(); |
| 52 | + return "Hello World222!" + String.valueOf(i) + a; |
| 53 | + } |
| 54 | + |
| 55 | + public CompletableFuture<Object> testAsync() { |
| 56 | + return CompletableFuture.supplyAsync(() -> { |
| 57 | + try { |
| 58 | + Thread.sleep(1000); // Simulate a delay |
| 59 | + throw new RuntimeException("Simulated exception"); |
| 60 | + } catch (InterruptedException e) { |
| 61 | + Thread.currentThread().interrupt(); |
| 62 | + } |
| 63 | + return "Async Result"; |
| 64 | + }); |
| 65 | + } |
| 66 | + |
| 67 | + public void teste() |
| 68 | + { |
| 69 | + Object aaa = (this.fWithParams(3)).join(); |
| 70 | + System.out.println(aaa); |
| 71 | + var c = this.fWithParams(5); |
| 72 | + } |
| 73 | + |
| 74 | + public java.util.concurrent.CompletableFuture<Object> fWithParams(Object a) |
| 75 | + { |
| 76 | + return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 77 | + return 42; |
| 78 | + }); |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + public java.util.concurrent.CompletableFuture teste(Object a) |
| 83 | + { |
| 84 | + return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 85 | + System.out.println(a); |
| 86 | + throw new Error("test") ; |
| 87 | + }); |
| 88 | + |
| 89 | + } |
| 90 | + |
| 91 | + public Object getVar(Object v) { |
| 92 | + return v; |
| 93 | + } |
| 94 | + |
| 95 | + public void teste33(String a) |
| 96 | + { |
| 97 | + var x = 1; |
| 98 | + x = 2; |
| 99 | + Object newObj = new java.util.HashMap<String, Object>() {{ |
| 100 | + put( "a", App.this.getVar(x) ); |
| 101 | + put( "a", a ); |
| 102 | + // put( "b", this.getValue(this.getValue(this.getValue(2))) ); |
| 103 | + }}; |
| 104 | + throw new Error("test") ; |
| 105 | + } |
| 106 | + |
| 107 | + public java.util.concurrent.CompletableFuture<Object> fetchData(Object input3) |
| 108 | + { |
| 109 | + final Object input2 = input3; |
| 110 | + return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 111 | + Object input = input2; |
| 112 | + input = 3; |
| 113 | + return Helpers.add(input, 2); |
| 114 | + }); |
| 115 | + |
| 116 | + } |
| 117 | + |
| 118 | + public java.util.concurrent.CompletableFuture<Object> fetchData(Object input2, Object... optionalArgs) |
| 119 | + { |
| 120 | + final Object input3 = input2; |
| 121 | + return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 122 | + Object input = input3; |
| 123 | + System.out.println(input); |
| 124 | + return null; |
| 125 | + }); |
| 126 | + |
| 127 | + } |
| 128 | + |
| 129 | + public static void main(String[] args) { |
| 130 | + // this.retryingTask(); |
| 131 | + |
| 132 | + var base = 3; |
| 133 | + System.out.println(new App().getGreeting()); |
| 134 | + var app = new App(); |
| 135 | + app.teste33("example"); |
| 136 | + // app.retryingTask(); |
| 137 | + try { |
| 138 | + var res = app.testAsync().join(); |
| 139 | + System.out.println("res: " + res); |
| 140 | + } catch (Exception e) { |
| 141 | + System.out.println("Error: " + e.getMessage()); |
| 142 | + } |
| 143 | + |
| 144 | + // System.out.println(app.getGreeting()); |
| 145 | + // app.test(); |
| 146 | + // app.aa(); |
| 147 | + // for (var i = 0; i < 5; ((int) i)++) { |
| 148 | + // System.out.println("i: " + i); |
| 149 | + // } |
| 150 | + } |
| 151 | +} |
0 commit comments