package com.google.firebase.remoteconfig.internal; import C.w; import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; /* loaded from: classes3.dex */ public class FirebaseRemoteConfigValueImpl implements FirebaseRemoteConfigValue { private static final String ILLEGAL_ARGUMENT_STRING_FORMAT = "[Value: %s] cannot be converted to a %s."; private final int source; private final String value; public FirebaseRemoteConfigValueImpl(String str, int i) { this.value = str; this.source = i; } private String asTrimmedString() { return asString().trim(); } private void throwIfNullValue() { if (this.value == null) { throw new IllegalArgumentException("Value is null, and cannot be converted to the desired type."); } } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public boolean asBoolean() throws IllegalArgumentException { if (this.source == 0) { return false; } String asTrimmedString = asTrimmedString(); if (ConfigGetParameterHandler.TRUE_REGEX.matcher(asTrimmedString).matches()) { return true; } if (ConfigGetParameterHandler.FALSE_REGEX.matcher(asTrimmedString).matches()) { return false; } throw new IllegalArgumentException(w.o("[Value: ", asTrimmedString, "] cannot be converted to a boolean.")); } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public byte[] asByteArray() { return this.source == 0 ? FirebaseRemoteConfig.DEFAULT_VALUE_FOR_BYTE_ARRAY : this.value.getBytes(ConfigGetParameterHandler.FRC_BYTE_ARRAY_ENCODING); } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public double asDouble() { if (this.source == 0) { return FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE; } String asTrimmedString = asTrimmedString(); try { return Double.valueOf(asTrimmedString).doubleValue(); } catch (NumberFormatException e4) { throw new IllegalArgumentException(w.o("[Value: ", asTrimmedString, "] cannot be converted to a double."), e4); } } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public long asLong() { if (this.source == 0) { return 0L; } String asTrimmedString = asTrimmedString(); try { return Long.valueOf(asTrimmedString).longValue(); } catch (NumberFormatException e4) { throw new IllegalArgumentException(w.o("[Value: ", asTrimmedString, "] cannot be converted to a long."), e4); } } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public String asString() { if (this.source == 0) { return ""; } throwIfNullValue(); return this.value; } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public int getSource() { return this.source; } }