package com.bytedance.keva;

import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.keva.Keva;
import com.bytedance.keva.KevaImpl;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class KevaPrivateImpl extends KevaImpl {
    static {
        Covode.recordClassIndex(35033);
    }

    public /* bridge */ /* synthetic */ void clear() {
        super.clear();
    }

    public /* bridge */ /* synthetic */ void dump() {
        super.dump();
    }

    public /* bridge */ /* synthetic */ void dumpNative() {
        super.dumpNative();
    }

    public /* bridge */ /* synthetic */ String name() {
        return super.name();
    }

    public Map<String, ?> getAll() {
        HashMap hashMap;
        MethodCollector.i(17138);
        synchronized (this) {
            try {
                hashMap = new HashMap();
                buildNewMap(hashMap);
            } finally {
                MethodCollector.o(17138);
            }
        }
        return hashMap;
    }

    public int count() {
        int i;
        MethodCollector.i(17351);
        synchronized (this) {
            try {
                i = 0;
                for (Map.Entry<String, KevaImpl.KevaValueWrapper> value : this.mValueMap.entrySet()) {
                    if (((KevaImpl.KevaValueWrapper) value.getValue()).offset != 0) {
                        i++;
                    }
                }
            } finally {
                MethodCollector.o(17351);
            }
        }
        return i;
    }

    public /* bridge */ /* synthetic */ Map buildNewMap(Map map) {
        super.buildNewMap(map);
        return map;
    }

    public /* bridge */ /* synthetic */ void erase(String str) {
        super.erase(str);
    }

    public /* bridge */ /* synthetic */ void registerChangeListener(Keva.OnChangeListener onChangeListener) {
        super.registerChangeListener(onChangeListener);
    }

    public /* bridge */ /* synthetic */ void unRegisterChangeListener(Keva.OnChangeListener onChangeListener) {
        super.unRegisterChangeListener(onChangeListener);
    }

    public boolean contains(String str) {
        boolean z;
        MethodCollector.i(17235);
        synchronized (this) {
            try {
                KevaImpl.KevaValueWrapper kevaValueWrapper = this.mValueMap.get(str);
                if (kevaValueWrapper == null || kevaValueWrapper.offset == 0) {
                    z = false;
                } else {
                    z = true;
                }
            } finally {
                MethodCollector.o(17235);
            }
        }
        return z;
    }

    public KevaPrivateImpl(String str, int i) {
        super(str, i);
    }

    public /* bridge */ /* synthetic */ void storeBoolean(String str, boolean z) {
        super.storeBoolean(str, z);
    }

    public /* bridge */ /* synthetic */ void storeBytes(String str, byte[] bArr) {
        super.storeBytes(str, bArr);
    }

    public /* bridge */ /* synthetic */ void storeBytesJustDisk(String str, byte[] bArr) {
        super.storeBytesJustDisk(str, bArr);
    }

    public /* bridge */ /* synthetic */ void storeDouble(String str, double d) {
        super.storeDouble(str, d);
    }

    public /* bridge */ /* synthetic */ void storeFloat(String str, float f) {
        super.storeFloat(str, f);
    }

    public /* bridge */ /* synthetic */ void storeInt(String str, int i) {
        super.storeInt(str, i);
    }

    public /* bridge */ /* synthetic */ void storeLong(String str, long j) {
        super.storeLong(str, j);
    }

    public /* bridge */ /* synthetic */ void storeString(String str, String str2) {
        super.storeString(str, str2);
    }

    public /* bridge */ /* synthetic */ void storeStringArray(String str, String[] strArr) {
        super.storeStringArray(str, strArr);
    }

    public /* bridge */ /* synthetic */ void storeStringArrayJustDisk(String str, String[] strArr) {
        super.storeStringArrayJustDisk(str, strArr);
    }

    public /* bridge */ /* synthetic */ void storeStringJustDisk(String str, String str2) {
        super.storeStringJustDisk(str, str2);
    }

    public /* bridge */ /* synthetic */ void storeStringSet(String str, Set set) {
        super.storeStringSet(str, set);
    }

    public /* bridge */ /* synthetic */ void storeStringSetJustDisk(String str, Set set) {
        super.storeStringSetJustDisk(str, set);
    }

    public /* bridge */ /* synthetic */ boolean getBoolean(String str, boolean z) {
        return super.getBoolean(str, z);
    }

    public /* bridge */ /* synthetic */ byte[] getBytes(String str, byte[] bArr) {
        return super.getBytes(str, bArr);
    }

    public /* bridge */ /* synthetic */ byte[] getBytesJustDisk(String str, byte[] bArr) {
        return super.getBytesJustDisk(str, bArr);
    }

    public /* bridge */ /* synthetic */ double getDouble(String str, double d) {
        return super.getDouble(str, d);
    }

    public /* bridge */ /* synthetic */ float getFloat(String str, float f) {
        return super.getFloat(str, f);
    }

    public /* bridge */ /* synthetic */ int getInt(String str, int i) {
        return super.getInt(str, i);
    }

    public /* bridge */ /* synthetic */ long getLong(String str, long j) {
        return super.getLong(str, j);
    }

    public /* bridge */ /* synthetic */ String getString(String str, String str2) {
        return super.getString(str, str2);
    }

    public /* bridge */ /* synthetic */ String[] getStringArray(String str, String[] strArr) {
        return super.getStringArray(str, strArr);
    }

    public /* bridge */ /* synthetic */ String[] getStringArrayJustDisk(String str, String[] strArr) {
        return super.getStringArrayJustDisk(str, strArr);
    }

    public /* bridge */ /* synthetic */ String getStringJustDisk(String str, String str2) {
        return super.getStringJustDisk(str, str2);
    }

    public /* bridge */ /* synthetic */ Set getStringSet(String str, Set set) {
        return super.getStringSet(str, set);
    }

    public /* bridge */ /* synthetic */ Set getStringSetJustDisk(String str, Set set) {
        return super.getStringSetJustDisk(str, set);
    }

    public boolean fetchBoolean(String str, boolean z) {
        return ((Boolean) fetchObject(str, Boolean.valueOf(z))).booleanValue();
    }

    public double fetchDouble(String str, double d) {
        return ((Double) fetchObject(str, Double.valueOf(d))).doubleValue();
    }

    public float fetchFloat(String str, float f) {
        return ((Float) fetchObject(str, Float.valueOf(f))).floatValue();
    }

    public int fetchInt(String str, int i) {
        return ((Integer) fetchObject(str, Integer.valueOf(i))).intValue();
    }

    public long fetchLong(String str, long j) {
        return ((Long) fetchObject(str, Long.valueOf(j))).longValue();
    }

    private Object fetchObject(String str, Object obj) {
        KevaImpl.KevaValueWrapper kevaValueWrapper = this.mValueMap.get(str);
        if (kevaValueWrapper == null || kevaValueWrapper.offset == 0) {
            return obj;
        }
        return kevaValueWrapper.value;
    }

    public String fetchString(String str, String str2, boolean z) {
        String str3 = str;
        KevaImpl.KevaValueWrapper kevaValueWrapper = this.mValueMap.get(str3);
        String str4 = str2;
        if (kevaValueWrapper == null || kevaValueWrapper.offset == 0) {
            return str4;
        }
        if (kevaValueWrapper.loaded) {
            return (String) kevaValueWrapper.value;
        }
        String fetchString = fetchString(this.mHandle, str3, kevaValueWrapper.offset, str4);
        if (z) {
            kevaValueWrapper.value = null;
            kevaValueWrapper.loaded = false;
        } else if (fetchString != str4) {
            kevaValueWrapper.value = fetchString;
            kevaValueWrapper.loaded = true;
        }
        return fetchString;
    }

    public String[] fetchStringArray(String str, String[] strArr, boolean z) {
        String str2 = str;
        KevaImpl.KevaValueWrapper kevaValueWrapper = this.mValueMap.get(str2);
        String[] strArr2 = strArr;
        if (kevaValueWrapper == null || kevaValueWrapper.offset == 0) {
            return strArr2;
        }
        if (kevaValueWrapper.loaded) {
            return (String[]) kevaValueWrapper.value;
        }
        String[] fetchStringArray = fetchStringArray(this.mHandle, str2, kevaValueWrapper.offset, strArr2, 3);
        if (z) {
            kevaValueWrapper.value = null;
            kevaValueWrapper.loaded = false;
        } else if (fetchStringArray != strArr2) {
            kevaValueWrapper.value = fetchStringArray;
            kevaValueWrapper.loaded = true;
        }
        return fetchStringArray;
    }

    public byte[] fetchBytes(String str, byte[] bArr, int i, boolean z) {
        String str2 = str;
        KevaImpl.KevaValueWrapper kevaValueWrapper = this.mValueMap.get(str2);
        byte[] bArr2 = bArr;
        if (kevaValueWrapper == null || kevaValueWrapper.offset == 0) {
            return bArr2;
        }
        if (kevaValueWrapper.loaded) {
            return (byte[]) kevaValueWrapper.value;
        }
        byte[] fetchBytes = fetchBytes(this.mHandle, str2, kevaValueWrapper.offset, bArr2, i);
        if (z) {
            kevaValueWrapper.value = null;
            kevaValueWrapper.loaded = false;
        } else if (fetchBytes != bArr2) {
            kevaValueWrapper.value = fetchBytes;
            kevaValueWrapper.loaded = true;
        }
        return fetchBytes;
    }
}
