|
| 1 | +// Autogenerated from Pigeon (v0.2.0), do not edit directly. |
| 2 | +// See also: https://pub.dev/packages/pigeon |
| 3 | + |
| 4 | +package com.example.android_unit_tests; |
| 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 | +import java.util.Map; |
| 11 | + |
| 12 | +/** Generated class from Pigeon. */ |
| 13 | +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) |
| 14 | +public class Pigeon { |
| 15 | + |
| 16 | + /** Generated class from Pigeon that represents data sent in messages. */ |
| 17 | + public static class SetRequest { |
| 18 | + private Long value; |
| 19 | + |
| 20 | + public Long getValue() { |
| 21 | + return value; |
| 22 | + } |
| 23 | + |
| 24 | + public void setValue(Long setterArg) { |
| 25 | + this.value = setterArg; |
| 26 | + } |
| 27 | + |
| 28 | + Map<String, Object> toMap() { |
| 29 | + Map<String, Object> toMapResult = new HashMap<>(); |
| 30 | + toMapResult.put("value", value); |
| 31 | + return toMapResult; |
| 32 | + } |
| 33 | + |
| 34 | + static SetRequest fromMap(Map<String, Object> map) { |
| 35 | + SetRequest fromMapResult = new SetRequest(); |
| 36 | + Object value = map.get("value"); |
| 37 | + fromMapResult.value = |
| 38 | + (value == null) ? null : ((value instanceof Integer) ? (Integer) value : (Long) value); |
| 39 | + return fromMapResult; |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 44 | + public interface Api { |
| 45 | + void setValue(SetRequest arg); |
| 46 | + |
| 47 | + /** Sets up an instance of `Api` to handle messages through the `binaryMessenger`. */ |
| 48 | + static void setup(BinaryMessenger binaryMessenger, Api api) { |
| 49 | + { |
| 50 | + BasicMessageChannel<Object> channel = |
| 51 | + new BasicMessageChannel<>( |
| 52 | + binaryMessenger, "dev.flutter.pigeon.Api.setValue", new StandardMessageCodec()); |
| 53 | + if (api != null) { |
| 54 | + channel.setMessageHandler( |
| 55 | + (message, reply) -> { |
| 56 | + Map<String, Object> wrapped = new HashMap<>(); |
| 57 | + try { |
| 58 | + @SuppressWarnings("ConstantConditions") |
| 59 | + SetRequest input = SetRequest.fromMap((Map<String, Object>) message); |
| 60 | + api.setValue(input); |
| 61 | + wrapped.put("result", null); |
| 62 | + } catch (Error | RuntimeException exception) { |
| 63 | + wrapped.put("error", wrapError(exception)); |
| 64 | + } |
| 65 | + reply.reply(wrapped); |
| 66 | + }); |
| 67 | + } else { |
| 68 | + channel.setMessageHandler(null); |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + private static Map<String, Object> wrapError(Throwable exception) { |
| 75 | + Map<String, Object> errorMap = new HashMap<>(); |
| 76 | + errorMap.put("message", exception.toString()); |
| 77 | + errorMap.put("code", exception.getClass().getSimpleName()); |
| 78 | + errorMap.put("details", null); |
| 79 | + return errorMap; |
| 80 | + } |
| 81 | +} |
0 commit comments