package com.google.firebase.remoteconfig.internal; import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue; /* loaded from: classes3.dex */ public class FirebaseRemoteConfigValueImpl implements FirebaseRemoteConfigValue { public final int source; public final String value; @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public int getSource() { return this.source; } public FirebaseRemoteConfigValueImpl(String str, int i) { this.value = str; this.source = i; } @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 e) { throw new IllegalArgumentException(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "long"), e); } } @Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue public double asDouble() { if (this.source == 0) { return 0.0d; } String asTrimmedString = asTrimmedString(); try { return Double.valueOf(asTrimmedString).doubleValue(); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "double"), e); } } @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 boolean asBoolean() { 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(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "boolean")); } public final void throwIfNullValue() { if (this.value == null) { throw new IllegalArgumentException("Value is null, and cannot be converted to the desired type."); } } public final String asTrimmedString() { return asString().trim(); } }