@Test public void testReadFromFileWhenNull() { final String fileName = "protoUtilsReadFromFileWhenNull"; final Context context = RuntimeEnvironment.application; context.deleteFile(fileName); final SettingsProto.Settings read = ProtoUtils.readFromFile( context, fileName, new SettingsProto.Settings()); assertNull(read); }
@Nullable public static <T extends MessageNano> T readFromFile(@NonNull final Context context, @NonNull final String fileName, @NonNull final T obj) { T message = null; try { final byte[] bytes = FileUtils.readPrivateFile(context, fileName); message = MessageNano.mergeFrom(obj, bytes); } catch (IOException e) { Log.w(TAG, e); } return message; }
ProtoUtils { @Nullable public static <T extends MessageNano> T readFromFile(@NonNull final Context context, @NonNull final String fileName, @NonNull final T obj) { T message = null; try { final byte[] bytes = FileUtils.readPrivateFile(context, fileName); message = MessageNano.mergeFrom(obj, bytes); } catch (IOException e) { Log.w(TAG, e); } return message; } }
ProtoUtils { @Nullable public static <T extends MessageNano> T readFromFile(@NonNull final Context context, @NonNull final String fileName, @NonNull final T obj) { T message = null; try { final byte[] bytes = FileUtils.readPrivateFile(context, fileName); message = MessageNano.mergeFrom(obj, bytes); } catch (IOException e) { Log.w(TAG, e); } return message; } private  ProtoUtils(); }
ProtoUtils { @Nullable public static <T extends MessageNano> T readFromFile(@NonNull final Context context, @NonNull final String fileName, @NonNull final T obj) { T message = null; try { final byte[] bytes = FileUtils.readPrivateFile(context, fileName); message = MessageNano.mergeFrom(obj, bytes); } catch (IOException e) { Log.w(TAG, e); } return message; } private  ProtoUtils(); @NonNull static byte[] toByteArray(@NonNull final MessageNano messageNano); static void writeToFile(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final MessageNano messageNano); @Nullable static T readFromFile(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final T obj); @NonNull static T readFromFileNonNull(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final T obj); }
ProtoUtils { @Nullable public static <T extends MessageNano> T readFromFile(@NonNull final Context context, @NonNull final String fileName, @NonNull final T obj) { T message = null; try { final byte[] bytes = FileUtils.readPrivateFile(context, fileName); message = MessageNano.mergeFrom(obj, bytes); } catch (IOException e) { Log.w(TAG, e); } return message; } private  ProtoUtils(); @NonNull static byte[] toByteArray(@NonNull final MessageNano messageNano); static void writeToFile(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final MessageNano messageNano); @Nullable static T readFromFile(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final T obj); @NonNull static T readFromFileNonNull(@NonNull final Context context,
            @NonNull final String fileName,
            @NonNull final T obj);  }