16
16
17
17
package com .google .firebase .remoteconfig .internal ;
18
18
19
- import static com .google .common .base .Preconditions .checkArgument ;
20
- import static com .google .common .base .Preconditions .checkNotNull ;
21
-
22
19
import com .google .api .client .util .Key ;
23
- import com .google .firebase .database .annotations .Nullable ;
24
- import com .google .firebase .internal .NonNull ;
25
- import com .google .firebase .remoteconfig .RemoteConfigParameter ;
26
- import com .google .firebase .remoteconfig .RemoteConfigParameterValue ;
27
- import com .google .firebase .remoteconfig .RemoteConfigTemplate ;
28
-
29
- import java .util .Collections ;
30
- import java .util .HashMap ;
20
+
31
21
import java .util .Map ;
32
22
33
23
/**
@@ -39,21 +29,14 @@ public final class TemplateResponse {
39
29
@ Key ("parameters" )
40
30
private Map <String , ParameterResponse > parameters ;
41
31
42
- public TemplateResponse () {
43
- parameters = Collections . emptyMap () ;
32
+ public Map < String , ParameterResponse > getParameters () {
33
+ return parameters ;
44
34
}
45
35
46
- public TemplateResponse ( @ NonNull Map < String , ParameterResponse > parameters ) {
47
- checkNotNull ( parameters , "parameters must not be null." );
36
+ public TemplateResponse setParameters (
37
+ Map < String , ParameterResponse > parameters ) {
48
38
this .parameters = parameters ;
49
- }
50
-
51
- public RemoteConfigTemplate toRemoteConfigTemplate () {
52
- Map <String , RemoteConfigParameter > parameterPublicTypes = new HashMap <>();
53
- for (Map .Entry <String , ParameterResponse > entry : parameters .entrySet ()) {
54
- parameterPublicTypes .put (entry .getKey (), entry .getValue ().toRemoteConfigParameter ());
55
- }
56
- return new RemoteConfigTemplate ().setParameters (parameterPublicTypes );
39
+ return this ;
57
40
}
58
41
59
42
/**
@@ -71,30 +54,33 @@ public static final class ParameterResponse {
71
54
@ Key ("conditionalValues" )
72
55
private Map <String , ParameterValueResponse > conditionalValues ;
73
56
74
- public ParameterResponse () {
75
- conditionalValues = Collections .emptyMap ();
57
+ public ParameterValueResponse getDefaultValue () {
58
+ return defaultValue ;
59
+ }
60
+
61
+ public String getDescription () {
62
+ return description ;
76
63
}
77
64
78
- public ParameterResponse (@ Nullable ParameterValueResponse defaultValue ,
79
- @ Nullable String description ,
80
- @ NonNull Map <String , ParameterValueResponse > conditionalValues ) {
65
+ public Map <String , ParameterValueResponse > getConditionalValues () {
66
+ return conditionalValues ;
67
+ }
68
+
69
+ public ParameterResponse setDefaultValue (
70
+ ParameterValueResponse defaultValue ) {
81
71
this .defaultValue = defaultValue ;
72
+ return this ;
73
+ }
74
+
75
+ public ParameterResponse setDescription (String description ) {
82
76
this .description = description ;
83
- this . conditionalValues = checkNotNull ( conditionalValues ) ;
77
+ return this ;
84
78
}
85
79
86
- public RemoteConfigParameter toRemoteConfigParameter () {
87
- Map <String , RemoteConfigParameterValue > conditionalPublicValues = new HashMap <>();
88
- for (Map .Entry <String , ParameterValueResponse > entry : conditionalValues .entrySet ()) {
89
- conditionalPublicValues
90
- .put (entry .getKey (), entry .getValue ().toRemoteConfigParameterValue ());
91
- }
92
- RemoteConfigParameterValue remoteConfigParameterValue =
93
- (defaultValue == null ) ? null : defaultValue .toRemoteConfigParameterValue ();
94
- return new RemoteConfigParameter ()
95
- .setDefaultValue (remoteConfigParameterValue )
96
- .setDescription (description )
97
- .setConditionalValues (conditionalPublicValues );
80
+ public ParameterResponse setConditionalValues (
81
+ Map <String , ParameterValueResponse > conditionalValues ) {
82
+ this .conditionalValues = conditionalValues ;
83
+ return this ;
98
84
}
99
85
}
100
86
@@ -108,29 +94,24 @@ public static final class ParameterValueResponse {
108
94
private String value ;
109
95
110
96
@ Key ("useInAppDefault" )
111
- private Boolean inAppDefaultValue ;
97
+ private Boolean useInAppDefault ;
112
98
113
- public ParameterValueResponse () {
99
+ public String getValue () {
100
+ return value ;
114
101
}
115
102
116
- private ParameterValueResponse (String value , Boolean inAppDefaultValue ) {
117
- this .value = value ;
118
- this .inAppDefaultValue = inAppDefaultValue ;
103
+ public boolean isUseInAppDefault () {
104
+ return Boolean .TRUE .equals (this .useInAppDefault );
119
105
}
120
106
121
- public static ParameterValueResponse ofValue (String value ) {
122
- return new ParameterValueResponse (value , null );
123
- }
124
-
125
- public static ParameterValueResponse ofInAppDefaultValue () {
126
- return new ParameterValueResponse (null , true );
107
+ public ParameterValueResponse setValue (String value ) {
108
+ this .value = value ;
109
+ return this ;
127
110
}
128
111
129
- public RemoteConfigParameterValue toRemoteConfigParameterValue () {
130
- if (this .inAppDefaultValue != null && this .inAppDefaultValue ) {
131
- return RemoteConfigParameterValue .inAppDefault ();
132
- }
133
- return RemoteConfigParameterValue .of (this .value );
112
+ public ParameterValueResponse setUseInAppDefault (boolean useInAppDefault ) {
113
+ this .useInAppDefault = useInAppDefault ;
114
+ return this ;
134
115
}
135
116
}
136
117
}
0 commit comments