// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

package com.dropbox.djinni.test;

import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

public abstract class TestHelpers {
    @Nonnull
    public static native SetRecord getSetRecord();

    public static native boolean checkSetRecord(SetRecord rec);

    @Nonnull
    public static native PrimitiveList getPrimitiveList();

    public static native boolean checkPrimitiveList(PrimitiveList pl);

    @Nonnull
    public static native NestedCollection getNestedCollection();

    public static native boolean checkNestedCollection(NestedCollection nc);

    @Nonnull
    public static native HashMap<String, Long> getMap();

    public static native boolean checkMap(HashMap<String, Long> m);

    @Nonnull
    public static native HashMap<String, Long> getEmptyMap();

    public static native boolean checkEmptyMap(HashMap<String, Long> m);

    @Nonnull
    public static native MapListRecord getMapListRecord();

    public static native boolean checkMapListRecord(MapListRecord m);

    public static native void checkClientInterfaceAscii(ClientInterface i);

    public static native void checkClientInterfaceNonascii(ClientInterface i);

    public static native void checkEnumMap(HashMap<Color, String> m);

    public static native void checkEnum(Color c);

    @Nonnull
    public static native Token tokenId(Token t);

    @Nonnull
    public static native Token createCppToken();

    public static native void checkCppToken(Token t);

    public static native long cppTokenId(Token t);

    public static native void checkTokenType(Token t, String type);

    @CheckForNull
    public static native Integer returnNone();

    /** Ensures that we generate integer translation code */
    @Nonnull
    public static native AssortedPrimitives assortedPrimitivesId(AssortedPrimitives i);

    @Nonnull
    public static native byte[] idBinary(byte[] b);

    public static final class CppProxy extends TestHelpers
    {
        private final long nativeRef;
        private final AtomicBoolean destroyed = new AtomicBoolean(false);

        private CppProxy(long nativeRef)
        {
            if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
            this.nativeRef = nativeRef;
        }

        private native void nativeDestroy(long nativeRef);
        public void destroy()
        {
            boolean destroyed = this.destroyed.getAndSet(true);
            if (!destroyed) nativeDestroy(this.nativeRef);
        }
        protected void finalize() throws java.lang.Throwable
        {
            destroy();
            super.finalize();
        }
    }
}
