Files
react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeMap.java
T
David Vacca 8d5ac8de76 Migration of RN-Android OSS tests to Android X
Summary:
This diff migrates RN to AndroidX.
As part of this diff I disabled few tests in RNAndroid OSS that will be re-enabled this week. As part of the refactor of BUCK files in OSS

Reviewed By: shergin

Differential Revision: D14200097

fbshipit-source-id: 932fcae251d1553e672acd67ecd0e703dcb364aa
2019-03-17 08:13:30 -07:00

74 lines
2.4 KiB
Java

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
import androidx.annotation.NonNull;
import com.facebook.jni.HybridData;
import com.facebook.infer.annotation.Assertions;
import com.facebook.proguard.annotations.DoNotStrip;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Implementation of a write-only map stored in native memory. Use
* {@link Arguments#createMap()} if you need to stub out creating this class in a test.
* TODO(5815532): Check if consumed on read
*/
@DoNotStrip
public class WritableNativeMap extends ReadableNativeMap implements WritableMap {
static {
ReactBridge.staticInit();
}
@Override
public native void putBoolean(@Nonnull String key, boolean value);
@Override
public native void putDouble(@Nonnull String key, double value);
@Override
public native void putInt(@Nonnull String key, int value);
@Override
public native void putString(@Nonnull String key, @Nullable String value);
@Override
public native void putNull(@NonNull String key);
// Note: this consumes the map so do not reuse it.
@Override
public void putMap(@Nonnull String key, @Nullable WritableMap value) {
Assertions.assertCondition(
value == null || value instanceof WritableNativeMap, "Illegal type provided");
putNativeMap(key, (WritableNativeMap) value);
}
// Note: this consumes the map so do not reuse it.
@Override
public void putArray(@Nonnull String key, @Nullable WritableArray value) {
Assertions.assertCondition(
value == null || value instanceof WritableNativeArray, "Illegal type provided");
putNativeArray(key, (WritableNativeArray) value);
}
// Note: this **DOES NOT** consume the source map
@Override
public void merge(@Nonnull ReadableMap source) {
Assertions.assertCondition(source instanceof ReadableNativeMap, "Illegal type provided");
mergeNativeMap((ReadableNativeMap) source);
}
public WritableNativeMap() {
super(initHybrid());
}
private static native HybridData initHybrid();
private native void putNativeMap(String key, WritableNativeMap value);
private native void putNativeArray(String key, WritableNativeArray value);
private native void mergeNativeMap(ReadableNativeMap source);
}