|
| 1 | +// Autogenerated from Pigeon (v0.1.0-experimental.9), do not edit directly. |
| 2 | +// See also: https://pub.dev/packages/pigeon |
| 3 | + |
| 4 | +package dev.flutter.aaclarke.pigeon; |
| 5 | + |
| 6 | +import io.flutter.plugin.common.BasicMessageChannel; |
| 7 | +import io.flutter.plugin.common.BinaryMessenger; |
| 8 | +import io.flutter.plugin.common.StandardMessageCodec; |
| 9 | +import java.util.HashMap; |
| 10 | + |
| 11 | +/** Generated class from Pigeon. */ |
| 12 | +public class Dartle { |
| 13 | + |
| 14 | + /** Generated class from Pigeon that represents data sent in messages. */ |
| 15 | + public static class SearchReply { |
| 16 | + private String result; |
| 17 | + |
| 18 | + public String getResult() { |
| 19 | + return result; |
| 20 | + } |
| 21 | + |
| 22 | + public void setResult(String setterArg) { |
| 23 | + this.result = setterArg; |
| 24 | + } |
| 25 | + |
| 26 | + private String error; |
| 27 | + |
| 28 | + public String getError() { |
| 29 | + return error; |
| 30 | + } |
| 31 | + |
| 32 | + public void setError(String setterArg) { |
| 33 | + this.error = setterArg; |
| 34 | + } |
| 35 | + |
| 36 | + HashMap toMap() { |
| 37 | + HashMap<String, Object> toMapResult = new HashMap<String, Object>(); |
| 38 | + toMapResult.put("result", result); |
| 39 | + toMapResult.put("error", error); |
| 40 | + return toMapResult; |
| 41 | + } |
| 42 | + |
| 43 | + static SearchReply fromMap(HashMap map) { |
| 44 | + SearchReply fromMapResult = new SearchReply(); |
| 45 | + fromMapResult.result = (String) map.get("result"); |
| 46 | + fromMapResult.error = (String) map.get("error"); |
| 47 | + return fromMapResult; |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + /** Generated class from Pigeon that represents data sent in messages. */ |
| 52 | + public static class SearchRequest { |
| 53 | + private String query; |
| 54 | + |
| 55 | + public String getQuery() { |
| 56 | + return query; |
| 57 | + } |
| 58 | + |
| 59 | + public void setQuery(String setterArg) { |
| 60 | + this.query = setterArg; |
| 61 | + } |
| 62 | + |
| 63 | + private Long anInt; |
| 64 | + |
| 65 | + public Long getAnInt() { |
| 66 | + return anInt; |
| 67 | + } |
| 68 | + |
| 69 | + public void setAnInt(Long setterArg) { |
| 70 | + this.anInt = setterArg; |
| 71 | + } |
| 72 | + |
| 73 | + private Boolean aBool; |
| 74 | + |
| 75 | + public Boolean getABool() { |
| 76 | + return aBool; |
| 77 | + } |
| 78 | + |
| 79 | + public void setABool(Boolean setterArg) { |
| 80 | + this.aBool = setterArg; |
| 81 | + } |
| 82 | + |
| 83 | + HashMap toMap() { |
| 84 | + HashMap<String, Object> toMapResult = new HashMap<String, Object>(); |
| 85 | + toMapResult.put("query", query); |
| 86 | + toMapResult.put("anInt", anInt); |
| 87 | + toMapResult.put("aBool", aBool); |
| 88 | + return toMapResult; |
| 89 | + } |
| 90 | + |
| 91 | + static SearchRequest fromMap(HashMap map) { |
| 92 | + SearchRequest fromMapResult = new SearchRequest(); |
| 93 | + fromMapResult.query = (String) map.get("query"); |
| 94 | + fromMapResult.anInt = |
| 95 | + (map.get("anInt") instanceof Integer) |
| 96 | + ? (Integer) map.get("anInt") |
| 97 | + : (Long) map.get("anInt"); |
| 98 | + fromMapResult.aBool = (Boolean) map.get("aBool"); |
| 99 | + return fromMapResult; |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + /** Generated class from Pigeon that represents data sent in messages. */ |
| 104 | + public static class Nested { |
| 105 | + private SearchRequest request; |
| 106 | + |
| 107 | + public SearchRequest getRequest() { |
| 108 | + return request; |
| 109 | + } |
| 110 | + |
| 111 | + public void setRequest(SearchRequest setterArg) { |
| 112 | + this.request = setterArg; |
| 113 | + } |
| 114 | + |
| 115 | + HashMap toMap() { |
| 116 | + HashMap<String, Object> toMapResult = new HashMap<String, Object>(); |
| 117 | + toMapResult.put("request", request); |
| 118 | + return toMapResult; |
| 119 | + } |
| 120 | + |
| 121 | + static Nested fromMap(HashMap map) { |
| 122 | + Nested fromMapResult = new Nested(); |
| 123 | + fromMapResult.request = (SearchRequest) map.get("request"); |
| 124 | + return fromMapResult; |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ |
| 129 | + public static class FlutterSearchApi { |
| 130 | + private BinaryMessenger binaryMessenger; |
| 131 | + |
| 132 | + public FlutterSearchApi(BinaryMessenger argBinaryMessenger) { |
| 133 | + this.binaryMessenger = argBinaryMessenger; |
| 134 | + } |
| 135 | + |
| 136 | + public interface Reply<T> { |
| 137 | + void reply(T reply); |
| 138 | + } |
| 139 | + |
| 140 | + public void search(SearchRequest argInput, Reply<SearchReply> callback) { |
| 141 | + BasicMessageChannel<Object> channel = |
| 142 | + new BasicMessageChannel<Object>( |
| 143 | + binaryMessenger, |
| 144 | + "dev.flutter.pigeon.FlutterSearchApi.search", |
| 145 | + new StandardMessageCodec()); |
| 146 | + HashMap inputMap = argInput.toMap(); |
| 147 | + channel.send( |
| 148 | + inputMap, |
| 149 | + new BasicMessageChannel.Reply<Object>() { |
| 150 | + public void reply(Object channelReply) { |
| 151 | + HashMap outputMap = (HashMap) channelReply; |
| 152 | + SearchReply output = SearchReply.fromMap(outputMap); |
| 153 | + callback.reply(output); |
| 154 | + } |
| 155 | + }); |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 160 | + public interface NestedApi { |
| 161 | + SearchReply search(Nested arg); |
| 162 | + |
| 163 | + /** Sets up an instance of `NestedApi` to handle messages through the `binaryMessenger` */ |
| 164 | + public static void setup(BinaryMessenger binaryMessenger, NestedApi api) { |
| 165 | + { |
| 166 | + BasicMessageChannel<Object> channel = |
| 167 | + new BasicMessageChannel<Object>( |
| 168 | + binaryMessenger, "dev.flutter.pigeon.NestedApi.search", new StandardMessageCodec()); |
| 169 | + channel.setMessageHandler( |
| 170 | + new BasicMessageChannel.MessageHandler<Object>() { |
| 171 | + public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) { |
| 172 | + Nested input = Nested.fromMap((HashMap) message); |
| 173 | + HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>(); |
| 174 | + try { |
| 175 | + SearchReply output = api.search(input); |
| 176 | + wrapped.put("result", output.toMap()); |
| 177 | + } catch (Exception exception) { |
| 178 | + wrapped.put("error", wrapError(exception)); |
| 179 | + } |
| 180 | + reply.reply(wrapped); |
| 181 | + } |
| 182 | + }); |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 188 | + public interface Api { |
| 189 | + SearchReply search(SearchRequest arg); |
| 190 | + |
| 191 | + /** Sets up an instance of `Api` to handle messages through the `binaryMessenger` */ |
| 192 | + public static void setup(BinaryMessenger binaryMessenger, Api api) { |
| 193 | + { |
| 194 | + BasicMessageChannel<Object> channel = |
| 195 | + new BasicMessageChannel<Object>( |
| 196 | + binaryMessenger, "dev.flutter.pigeon.Api.search", new StandardMessageCodec()); |
| 197 | + channel.setMessageHandler( |
| 198 | + new BasicMessageChannel.MessageHandler<Object>() { |
| 199 | + public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) { |
| 200 | + SearchRequest input = SearchRequest.fromMap((HashMap) message); |
| 201 | + HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>(); |
| 202 | + try { |
| 203 | + SearchReply output = api.search(input); |
| 204 | + wrapped.put("result", output.toMap()); |
| 205 | + } catch (Exception exception) { |
| 206 | + wrapped.put("error", wrapError(exception)); |
| 207 | + } |
| 208 | + reply.reply(wrapped); |
| 209 | + } |
| 210 | + }); |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + private static HashMap wrapError(Exception exception) { |
| 216 | + HashMap<String, Object> errorMap = new HashMap<String, Object>(); |
| 217 | + errorMap.put("message", exception.toString()); |
| 218 | + errorMap.put("code", null); |
| 219 | + errorMap.put("details", null); |
| 220 | + return errorMap; |
| 221 | + } |
| 222 | +} |
0 commit comments