Skip to content

Commit 2110cd1

Browse files
author
Varun Rathore
committed
fix build
1 parent 095b467 commit 2110cd1

File tree

1 file changed

+52
-59
lines changed

1 file changed

+52
-59
lines changed

src/main/java/com/google/firebase/remoteconfig/ParameterValue.java

Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
import com.google.firebase.remoteconfig.internal.TemplateResponse.ParameterValueResponse;
2727
import com.google.firebase.remoteconfig.internal.TemplateResponse.PersonalizationValueResponse;
2828
import com.google.firebase.remoteconfig.internal.TemplateResponse.RolloutValueResponse;
29-
3029
import java.util.List;
3130
import java.util.Objects;
3231

33-
/**
34-
* Represents a Remote Config parameter value that can be used in a {@link Template}.
35-
*/
32+
/** Represents a Remote Config parameter value that can be used in a {@link Template}. */
3633
public abstract class ParameterValue {
3734

3835
/**
@@ -83,15 +80,15 @@ public static PersonalizationValue ofPersonalization(String personalizationId) {
8380
* @param variantValues The list of experiment variant values.
8481
* @return A {@link ParameterValue.ExperimentValue} instance.
8582
*/
86-
public static ExperimentValue ofExperiment(String experimentId,
87-
List<ExperimentVariantValue> variantValues, double exposurePercent) {
83+
public static ExperimentValue ofExperiment(
84+
String experimentId, List<ExperimentVariantValue> variantValues, double exposurePercent) {
8885
return new ExperimentValue(experimentId, variantValues, exposurePercent);
8986
}
9087

9188
abstract ParameterValueResponse toParameterValueResponse();
9289

9390
static ParameterValue fromParameterValueResponse(
94-
@NonNull ParameterValueResponse parameterValueResponse) {
91+
@NonNull ParameterValueResponse parameterValueResponse) {
9592
checkNotNull(parameterValueResponse);
9693
if (parameterValueResponse.isUseInAppDefault()) {
9794
return ParameterValue.inAppDefault();
@@ -101,7 +98,7 @@ static ParameterValue fromParameterValueResponse(
10198
// Protobuf serialization does not set values for fields on the wire when
10299
// they are equal to the default value for the field type. When deserializing,
103100
// can appear as the value not being set. Explicitly handle default value for
104-
// the percent field since 0 is a valid value.
101+
// the percent field since 0 is a valid value.
105102
double percent = 0;
106103
if (rv.getPercent() != null) {
107104
percent = rv.getPercent();
@@ -114,18 +111,21 @@ static ParameterValue fromParameterValueResponse(
114111
}
115112
if (parameterValueResponse.getExperimentValue() != null) {
116113
ExperimentValueResponse ev = parameterValueResponse.getExperimentValue();
117-
List<ExperimentVariantValue> variantValues = ev.getExperimentVariantValues().stream()
118-
.map(evv -> new ExperimentVariantValue(
119-
evv.getVariantId(), evv.getValue(), evv.getNoChange()))
120-
.collect(toList());
121-
return ParameterValue.ofExperiment(ev.getExperimentId(), variantValues, ev.getExposurePercent());
114+
List<ExperimentVariantValue> variantValues =
115+
ev.getExperimentVariantValues().stream()
116+
.map(
117+
evv ->
118+
new ExperimentVariantValue(
119+
evv.getVariantId(), evv.getValue(), evv.getNoChange()))
120+
.collect(toList());
121+
return ParameterValue.ofExperiment(
122+
ev.getExperimentId(), variantValues, ev.getExposurePercent());
122123
}
123124
return ParameterValue.of(parameterValueResponse.getValue());
124125
}
125126

126127
/**
127-
* Represents an explicit Remote Config parameter value with a value that the
128-
* parameter is set to.
128+
* Represents an explicit Remote Config parameter value with a value that the parameter is set to.
129129
*/
130130
public static final class Explicit extends ParameterValue {
131131

@@ -146,8 +146,7 @@ public String getValue() {
146146

147147
@Override
148148
ParameterValueResponse toParameterValueResponse() {
149-
return new ParameterValueResponse()
150-
.setValue(this.value);
149+
return new ParameterValueResponse().setValue(this.value);
151150
}
152151

153152
@Override
@@ -168,9 +167,7 @@ public int hashCode() {
168167
}
169168
}
170169

171-
/**
172-
* Represents an in app default parameter value.
173-
*/
170+
/** Represents an in app default parameter value. */
174171
public static final class InAppDefault extends ParameterValue {
175172

176173
@Override
@@ -190,9 +187,7 @@ public boolean equals(Object o) {
190187
}
191188
}
192189

193-
/**
194-
* Represents a Rollout value.
195-
*/
190+
/** Represents a Rollout value. */
196191
public static final class RolloutValue extends ParameterValue {
197192
private final String rolloutId;
198193
private final String value;
@@ -223,8 +218,8 @@ public String getValue() {
223218
}
224219

225220
/**
226-
* Gets the rollout percentage representing the exposure of rollout value
227-
* in the target audience.
221+
* Gets the rollout percentage representing the exposure of rollout value in the target
222+
* audience.
228223
*
229224
* @return Percentage of audience exposed to the rollout
230225
*/
@@ -234,11 +229,12 @@ public double getPercent() {
234229

235230
@Override
236231
ParameterValueResponse toParameterValueResponse() {
237-
return new ParameterValueResponse().setRolloutValue(
232+
return new ParameterValueResponse()
233+
.setRolloutValue(
238234
new RolloutValueResponse()
239-
.setRolloutId(this.rolloutId)
240-
.setValue(this.value)
241-
.setPercent(this.percent));
235+
.setRolloutId(this.rolloutId)
236+
.setValue(this.value)
237+
.setPercent(this.percent));
242238
}
243239

244240
@Override
@@ -251,8 +247,8 @@ public boolean equals(Object o) {
251247
}
252248
RolloutValue that = (RolloutValue) o;
253249
return Double.compare(that.percent, percent) == 0
254-
&& Objects.equals(rolloutId, that.rolloutId)
255-
&& Objects.equals(value, that.value);
250+
&& Objects.equals(rolloutId, that.rolloutId)
251+
&& Objects.equals(value, that.value);
256252
}
257253

258254
@Override
@@ -261,9 +257,7 @@ public int hashCode() {
261257
}
262258
}
263259

264-
/**
265-
* Represents a Personalization value.
266-
*/
260+
/** Represents a Personalization value. */
267261
public static final class PersonalizationValue extends ParameterValue {
268262
private final String personalizationId;
269263

@@ -282,9 +276,9 @@ public String getPersonalizationId() {
282276

283277
@Override
284278
ParameterValueResponse toParameterValueResponse() {
285-
return new ParameterValueResponse().setPersonalizationValue(
286-
new PersonalizationValueResponse()
287-
.setPersonalizationId(this.personalizationId));
279+
return new ParameterValueResponse()
280+
.setPersonalizationValue(
281+
new PersonalizationValueResponse().setPersonalizationId(this.personalizationId));
288282
}
289283

290284
@Override
@@ -305,9 +299,7 @@ public int hashCode() {
305299
}
306300
}
307301

308-
/**
309-
* Represents a specific variant within an Experiment.
310-
*/
302+
/** Represents a specific variant within an Experiment. */
311303
public static final class ExperimentVariantValue {
312304
private final String variantId;
313305
private final String value;
@@ -383,8 +375,8 @@ public boolean equals(Object o) {
383375
}
384376
ExperimentVariantValue that = (ExperimentVariantValue) o;
385377
return noChange == that.noChange
386-
&& Objects.equals(variantId, that.variantId)
387-
&& Objects.equals(value, that.value);
378+
&& Objects.equals(variantId, that.variantId)
379+
&& Objects.equals(value, that.value);
388380
}
389381

390382
@Override
@@ -393,16 +385,14 @@ public int hashCode() {
393385
}
394386
}
395387

396-
/**
397-
* Represents an Experiment value.
398-
*/
388+
/** Represents an Experiment value. */
399389
public static final class ExperimentValue extends ParameterValue {
400390
private final String experimentId;
401391
private final List<ExperimentVariantValue> variantValues;
402392
private final double exposurePercent;
403393

404-
405-
private ExperimentValue(String experimentId, List<ExperimentVariantValue> variantValues, double exposurePercent) {
394+
private ExperimentValue(
395+
String experimentId, List<ExperimentVariantValue> variantValues, double exposurePercent) {
406396
this.experimentId = experimentId;
407397
this.variantValues = variantValues;
408398
this.exposurePercent = exposurePercent;
@@ -426,7 +416,6 @@ public double getExposurePercent() {
426416
return exposurePercent;
427417
}
428418

429-
430419
/**
431420
* Gets a collection of variant values served by the experiment.
432421
*
@@ -438,16 +427,20 @@ public List<ExperimentVariantValue> getExperimentVariantValues() {
438427

439428
@Override
440429
ParameterValueResponse toParameterValueResponse() {
441-
List<ExperimentVariantValueResponse> variantValueResponses = variantValues.stream()
442-
.map(variantValue -> new ExperimentVariantValueResponse()
443-
.setVariantId(variantValue.getVariantId())
444-
.setValue(variantValue.getValue())
445-
.setNoChange(variantValue.getNoChange()))
446-
.collect(toList());
447-
return new ParameterValueResponse().setExperimentValue(
430+
List<ExperimentVariantValueResponse> variantValueResponses =
431+
variantValues.stream()
432+
.map(
433+
variantValue ->
434+
new ExperimentVariantValueResponse()
435+
.setVariantId(variantValue.getVariantId())
436+
.setValue(variantValue.getValue())
437+
.setNoChange(variantValue.getNoChange()))
438+
.collect(toList());
439+
return new ParameterValueResponse()
440+
.setExperimentValue(
448441
new ExperimentValueResponse()
449-
.setExperimentId(this.experimentId)
450-
.setExperimentVariantValues(variantValueResponses));
442+
.setExperimentId(this.experimentId)
443+
.setExperimentVariantValues(variantValueResponses));
451444
}
452445

453446
@Override
@@ -460,8 +453,8 @@ public boolean equals(Object o) {
460453
}
461454
ExperimentValue that = (ExperimentValue) o;
462455
return Objects.equals(experimentId, that.experimentId)
463-
&& Objects.equals(variantValues, that.variantValues)
464-
&& Double.compare(that.exposurePercent, exposurePercent) == 0;
456+
&& Objects.equals(variantValues, that.variantValues)
457+
&& Double.compare(that.exposurePercent, exposurePercent) == 0;
465458
}
466459

467460
@Override

0 commit comments

Comments
 (0)