|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | +// Autogenerated from Pigeon (v9.2.4), do not edit directly. |
| 5 | +// See also: https://pub.dev/packages/pigeon |
| 6 | + |
| 7 | +package io.flutter.plugins.sharedpreferences; |
| 8 | + |
| 9 | +import android.util.Log; |
| 10 | +import androidx.annotation.NonNull; |
| 11 | +import androidx.annotation.Nullable; |
| 12 | +import io.flutter.plugin.common.BasicMessageChannel; |
| 13 | +import io.flutter.plugin.common.BinaryMessenger; |
| 14 | +import io.flutter.plugin.common.MessageCodec; |
| 15 | +import io.flutter.plugin.common.StandardMessageCodec; |
| 16 | +import java.util.ArrayList; |
| 17 | +import java.util.List; |
| 18 | +import java.util.Map; |
| 19 | + |
| 20 | +/** Generated class from Pigeon. */ |
| 21 | +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) |
| 22 | +public class Messages { |
| 23 | + |
| 24 | + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ |
| 25 | + public static class FlutterError extends RuntimeException { |
| 26 | + |
| 27 | + /** The error code. */ |
| 28 | + public final String code; |
| 29 | + |
| 30 | + /** The error details. Must be a datatype supported by the api codec. */ |
| 31 | + public final Object details; |
| 32 | + |
| 33 | + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { |
| 34 | + super(message); |
| 35 | + this.code = code; |
| 36 | + this.details = details; |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + @NonNull |
| 41 | + protected static ArrayList<Object> wrapError(@NonNull Throwable exception) { |
| 42 | + ArrayList<Object> errorList = new ArrayList<Object>(3); |
| 43 | + if (exception instanceof FlutterError) { |
| 44 | + FlutterError error = (FlutterError) exception; |
| 45 | + errorList.add(error.code); |
| 46 | + errorList.add(error.getMessage()); |
| 47 | + errorList.add(error.details); |
| 48 | + } else { |
| 49 | + errorList.add(exception.toString()); |
| 50 | + errorList.add(exception.getClass().getSimpleName()); |
| 51 | + errorList.add( |
| 52 | + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); |
| 53 | + } |
| 54 | + return errorList; |
| 55 | + } |
| 56 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 57 | + public interface SharedPreferencesApi { |
| 58 | + /** Removes property from shared preferences data set. */ |
| 59 | + @NonNull |
| 60 | + Boolean remove(@NonNull String key); |
| 61 | + /** Adds property to shared preferences data set of type bool. */ |
| 62 | + @NonNull |
| 63 | + Boolean setBool(@NonNull String key, @NonNull Boolean value); |
| 64 | + /** Adds property to shared preferences data set of type String. */ |
| 65 | + @NonNull |
| 66 | + Boolean setString(@NonNull String key, @NonNull String value); |
| 67 | + /** Adds property to shared preferences data set of type int. */ |
| 68 | + @NonNull |
| 69 | + Boolean setInt(@NonNull String key, @NonNull Long value); |
| 70 | + /** Adds property to shared preferences data set of type double. */ |
| 71 | + @NonNull |
| 72 | + Boolean setDouble(@NonNull String key, @NonNull Double value); |
| 73 | + /** Adds property to shared preferences data set of type List<String>. */ |
| 74 | + @NonNull |
| 75 | + Boolean setStringList(@NonNull String key, @NonNull List<String> value); |
| 76 | + /** Removes all properties from shared preferences data set with matching prefix. */ |
| 77 | + @NonNull |
| 78 | + Boolean clearWithPrefix(@NonNull String prefix); |
| 79 | + /** Gets all properties from shared preferences data set with matching prefix. */ |
| 80 | + @NonNull |
| 81 | + Map<String, Object> getAllWithPrefix(@NonNull String prefix); |
| 82 | + |
| 83 | + /** The codec used by SharedPreferencesApi. */ |
| 84 | + static @NonNull MessageCodec<Object> getCodec() { |
| 85 | + return new StandardMessageCodec(); |
| 86 | + } |
| 87 | + /** |
| 88 | + * Sets up an instance of `SharedPreferencesApi` to handle messages through the |
| 89 | + * `binaryMessenger`. |
| 90 | + */ |
| 91 | + static void setup( |
| 92 | + @NonNull BinaryMessenger binaryMessenger, @Nullable SharedPreferencesApi api) { |
| 93 | + { |
| 94 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 95 | + BasicMessageChannel<Object> channel = |
| 96 | + new BasicMessageChannel<>( |
| 97 | + binaryMessenger, |
| 98 | + "dev.flutter.pigeon.SharedPreferencesApi.remove", |
| 99 | + getCodec(), |
| 100 | + taskQueue); |
| 101 | + if (api != null) { |
| 102 | + channel.setMessageHandler( |
| 103 | + (message, reply) -> { |
| 104 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 105 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 106 | + String keyArg = (String) args.get(0); |
| 107 | + try { |
| 108 | + Boolean output = api.remove(keyArg); |
| 109 | + wrapped.add(0, output); |
| 110 | + } catch (Throwable exception) { |
| 111 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 112 | + wrapped = wrappedError; |
| 113 | + } |
| 114 | + reply.reply(wrapped); |
| 115 | + }); |
| 116 | + } else { |
| 117 | + channel.setMessageHandler(null); |
| 118 | + } |
| 119 | + } |
| 120 | + { |
| 121 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 122 | + BasicMessageChannel<Object> channel = |
| 123 | + new BasicMessageChannel<>( |
| 124 | + binaryMessenger, |
| 125 | + "dev.flutter.pigeon.SharedPreferencesApi.setBool", |
| 126 | + getCodec(), |
| 127 | + taskQueue); |
| 128 | + if (api != null) { |
| 129 | + channel.setMessageHandler( |
| 130 | + (message, reply) -> { |
| 131 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 132 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 133 | + String keyArg = (String) args.get(0); |
| 134 | + Boolean valueArg = (Boolean) args.get(1); |
| 135 | + try { |
| 136 | + Boolean output = api.setBool(keyArg, valueArg); |
| 137 | + wrapped.add(0, output); |
| 138 | + } catch (Throwable exception) { |
| 139 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 140 | + wrapped = wrappedError; |
| 141 | + } |
| 142 | + reply.reply(wrapped); |
| 143 | + }); |
| 144 | + } else { |
| 145 | + channel.setMessageHandler(null); |
| 146 | + } |
| 147 | + } |
| 148 | + { |
| 149 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 150 | + BasicMessageChannel<Object> channel = |
| 151 | + new BasicMessageChannel<>( |
| 152 | + binaryMessenger, |
| 153 | + "dev.flutter.pigeon.SharedPreferencesApi.setString", |
| 154 | + getCodec(), |
| 155 | + taskQueue); |
| 156 | + if (api != null) { |
| 157 | + channel.setMessageHandler( |
| 158 | + (message, reply) -> { |
| 159 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 160 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 161 | + String keyArg = (String) args.get(0); |
| 162 | + String valueArg = (String) args.get(1); |
| 163 | + try { |
| 164 | + Boolean output = api.setString(keyArg, valueArg); |
| 165 | + wrapped.add(0, output); |
| 166 | + } catch (Throwable exception) { |
| 167 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 168 | + wrapped = wrappedError; |
| 169 | + } |
| 170 | + reply.reply(wrapped); |
| 171 | + }); |
| 172 | + } else { |
| 173 | + channel.setMessageHandler(null); |
| 174 | + } |
| 175 | + } |
| 176 | + { |
| 177 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 178 | + BasicMessageChannel<Object> channel = |
| 179 | + new BasicMessageChannel<>( |
| 180 | + binaryMessenger, |
| 181 | + "dev.flutter.pigeon.SharedPreferencesApi.setInt", |
| 182 | + getCodec(), |
| 183 | + taskQueue); |
| 184 | + if (api != null) { |
| 185 | + channel.setMessageHandler( |
| 186 | + (message, reply) -> { |
| 187 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 188 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 189 | + String keyArg = (String) args.get(0); |
| 190 | + Number valueArg = (Number) args.get(1); |
| 191 | + try { |
| 192 | + Boolean output = |
| 193 | + api.setInt(keyArg, (valueArg == null) ? null : valueArg.longValue()); |
| 194 | + wrapped.add(0, output); |
| 195 | + } catch (Throwable exception) { |
| 196 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 197 | + wrapped = wrappedError; |
| 198 | + } |
| 199 | + reply.reply(wrapped); |
| 200 | + }); |
| 201 | + } else { |
| 202 | + channel.setMessageHandler(null); |
| 203 | + } |
| 204 | + } |
| 205 | + { |
| 206 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 207 | + BasicMessageChannel<Object> channel = |
| 208 | + new BasicMessageChannel<>( |
| 209 | + binaryMessenger, |
| 210 | + "dev.flutter.pigeon.SharedPreferencesApi.setDouble", |
| 211 | + getCodec(), |
| 212 | + taskQueue); |
| 213 | + if (api != null) { |
| 214 | + channel.setMessageHandler( |
| 215 | + (message, reply) -> { |
| 216 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 217 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 218 | + String keyArg = (String) args.get(0); |
| 219 | + Double valueArg = (Double) args.get(1); |
| 220 | + try { |
| 221 | + Boolean output = api.setDouble(keyArg, valueArg); |
| 222 | + wrapped.add(0, output); |
| 223 | + } catch (Throwable exception) { |
| 224 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 225 | + wrapped = wrappedError; |
| 226 | + } |
| 227 | + reply.reply(wrapped); |
| 228 | + }); |
| 229 | + } else { |
| 230 | + channel.setMessageHandler(null); |
| 231 | + } |
| 232 | + } |
| 233 | + { |
| 234 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 235 | + BasicMessageChannel<Object> channel = |
| 236 | + new BasicMessageChannel<>( |
| 237 | + binaryMessenger, |
| 238 | + "dev.flutter.pigeon.SharedPreferencesApi.setStringList", |
| 239 | + getCodec(), |
| 240 | + taskQueue); |
| 241 | + if (api != null) { |
| 242 | + channel.setMessageHandler( |
| 243 | + (message, reply) -> { |
| 244 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 245 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 246 | + String keyArg = (String) args.get(0); |
| 247 | + List<String> valueArg = (List<String>) args.get(1); |
| 248 | + try { |
| 249 | + Boolean output = api.setStringList(keyArg, valueArg); |
| 250 | + wrapped.add(0, output); |
| 251 | + } catch (Throwable exception) { |
| 252 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 253 | + wrapped = wrappedError; |
| 254 | + } |
| 255 | + reply.reply(wrapped); |
| 256 | + }); |
| 257 | + } else { |
| 258 | + channel.setMessageHandler(null); |
| 259 | + } |
| 260 | + } |
| 261 | + { |
| 262 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 263 | + BasicMessageChannel<Object> channel = |
| 264 | + new BasicMessageChannel<>( |
| 265 | + binaryMessenger, |
| 266 | + "dev.flutter.pigeon.SharedPreferencesApi.clearWithPrefix", |
| 267 | + getCodec(), |
| 268 | + taskQueue); |
| 269 | + if (api != null) { |
| 270 | + channel.setMessageHandler( |
| 271 | + (message, reply) -> { |
| 272 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 273 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 274 | + String prefixArg = (String) args.get(0); |
| 275 | + try { |
| 276 | + Boolean output = api.clearWithPrefix(prefixArg); |
| 277 | + wrapped.add(0, output); |
| 278 | + } catch (Throwable exception) { |
| 279 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 280 | + wrapped = wrappedError; |
| 281 | + } |
| 282 | + reply.reply(wrapped); |
| 283 | + }); |
| 284 | + } else { |
| 285 | + channel.setMessageHandler(null); |
| 286 | + } |
| 287 | + } |
| 288 | + { |
| 289 | + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); |
| 290 | + BasicMessageChannel<Object> channel = |
| 291 | + new BasicMessageChannel<>( |
| 292 | + binaryMessenger, |
| 293 | + "dev.flutter.pigeon.SharedPreferencesApi.getAllWithPrefix", |
| 294 | + getCodec(), |
| 295 | + taskQueue); |
| 296 | + if (api != null) { |
| 297 | + channel.setMessageHandler( |
| 298 | + (message, reply) -> { |
| 299 | + ArrayList<Object> wrapped = new ArrayList<Object>(); |
| 300 | + ArrayList<Object> args = (ArrayList<Object>) message; |
| 301 | + String prefixArg = (String) args.get(0); |
| 302 | + try { |
| 303 | + Map<String, Object> output = api.getAllWithPrefix(prefixArg); |
| 304 | + wrapped.add(0, output); |
| 305 | + } catch (Throwable exception) { |
| 306 | + ArrayList<Object> wrappedError = wrapError(exception); |
| 307 | + wrapped = wrappedError; |
| 308 | + } |
| 309 | + reply.reply(wrapped); |
| 310 | + }); |
| 311 | + } else { |
| 312 | + channel.setMessageHandler(null); |
| 313 | + } |
| 314 | + } |
| 315 | + } |
| 316 | + } |
| 317 | +} |
0 commit comments