package csdk.glucustomersupport.util; import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import csdk.gluads.Consts; import java.util.List; import java.util.Map; /* loaded from: classes4.dex */ public class ConfigUtil { public static boolean getBoolean(@Nullable Object obj, @NonNull String str) { return getBoolean(obj, str, false); } public static boolean getBoolean(@Nullable Object obj, @NonNull String str, boolean z) { Object object = getObject(obj, str, null); if (object == null) { return z; } if (object instanceof Boolean) { return ((Boolean) object).booleanValue(); } if (object instanceof String) { String str2 = (String) object; if (TextUtils.equals(str2, "true")) { return true; } if (TextUtils.equals(str2, "false")) { return false; } throw new IllegalArgumentException("Can't convert string to boolean value: " + str2 + Consts.STRING_PERIOD); } throw new IllegalArgumentException("Unsupported type for boolean value: " + object.getClass()); } public static long getLong(@Nullable Object obj, @NonNull String str) { return getLong(obj, str, 0L); } public static long getLong(@Nullable Object obj, @NonNull String str, long j) { Object object = getObject(obj, str, null); if (object == null) { return j; } if (object instanceof Number) { return ((Number) object).longValue(); } if (object instanceof String) { return Long.parseLong((String) object); } throw new IllegalArgumentException("Unsupported type for long value: " + object.getClass()); } public static double getDouble(@Nullable Object obj, @NonNull String str) { return getDouble(obj, str, 0.0d); } public static double getDouble(@Nullable Object obj, @NonNull String str, double d) { Object object = getObject(obj, str, null); if (object == null) { return d; } if (object instanceof Number) { return ((Number) object).doubleValue(); } if (object instanceof String) { return Double.parseDouble((String) object); } throw new IllegalArgumentException("Unsupported type for double value: " + object.getClass()); } @Nullable public static String getString(@Nullable Object obj, @NonNull String str) { return getString(obj, str, null); } @Nullable public static String getString(@Nullable Object obj, @NonNull String str, @Nullable String str2) { Object object = getObject(obj, str, null); if (object == null) { return str2; } if (object instanceof String) { return (String) object; } if ((object instanceof Number) || (object instanceof Boolean)) { return object.toString(); } throw new IllegalArgumentException("Unsupported type for string value: " + object.getClass()); } @Nullable public static Map getMap(@Nullable Object obj, @NonNull String str) { return getMap(obj, str, null); } @Nullable public static Map getMap(@Nullable Object obj, @NonNull String str, @Nullable Map map) { Object object = getObject(obj, str, null); if (object == null) { return map; } if (object instanceof Map) { return (Map) object; } throw new IllegalArgumentException("Unsupported type for map value: " + object.getClass()); } public static List getList(@Nullable Object obj, @NonNull String str) { return getList(obj, str, null); } @Nullable public static List getList(@Nullable Object obj, @NonNull String str, @Nullable List list) { Object object = getObject(obj, str, null); if (object == null) { return list; } if (object instanceof List) { return (List) object; } throw new IllegalArgumentException("Unsupported type for list value: " + object.getClass()); } public static Object getObject(@Nullable Object obj, @NonNull String str) { return getObject(obj, str, null); } @Nullable public static Object getObject(@Nullable Object obj, @NonNull String str, @Nullable Object obj2) { if (obj == null) { return obj2; } for (String str2 : splitPath(str)) { if (obj == null) { return obj2; } obj = ((Map) obj).get(str2); } return obj; } @NonNull private static String[] splitPath(@NonNull String str) { return str.split("\\."); } }