Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/main/java/com/google/firebase/remoteconfig/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class Template {
private Map<String, Parameter> parameters;
private List<Condition> conditions;
private Map<String, ParameterGroup> parameterGroups;
private Version version;

/**
* Creates a new {@link Template}.
Expand Down Expand Up @@ -69,6 +70,9 @@ public Template() {
this.parameterGroups.put(entry.getKey(), new ParameterGroup(entry.getValue()));
}
}
if (templateResponse.getVersion() != null) {
this.version = new Version(templateResponse.getVersion());
}
}

/**
Expand Down Expand Up @@ -111,6 +115,15 @@ public Map<String, ParameterGroup> getParameterGroups() {
return parameterGroups;
}

/**
* Gets the version information of the template.
*
* @return The version information of the template.
*/
public Version getVersion() {
return version;
}

/**
* Sets the map of parameters of the template.
*
Expand Down Expand Up @@ -152,6 +165,18 @@ public Template setParameterGroups(
return this;
}

/**
* Sets the version information of the template.
* Only the version's description field can be specified here.
*
* @param version A {@link Version} instance.
* @return This {@link Template} instance.
*/
public Template setVersion(Version version) {
this.version = version;
return this;
}

Template setETag(String etag) {
this.etag = etag;
return this;
Expand All @@ -170,10 +195,13 @@ TemplateResponse toTemplateResponse() {
for (Map.Entry<String, ParameterGroup> entry : this.parameterGroups.entrySet()) {
parameterGroupResponse.put(entry.getKey(), entry.getValue().toParameterGroupResponse());
}
TemplateResponse.VersionResponse versionResponse = (this.version == null) ? null
: this.version.toVersionResponse();
return new TemplateResponse()
.setParameters(parameterResponses)
.setConditions(conditionResponses)
.setParameterGroups(parameterGroupResponse);
.setParameterGroups(parameterGroupResponse)
.setVersion(versionResponse);
}

@Override
Expand All @@ -188,11 +216,12 @@ public boolean equals(Object o) {
return Objects.equals(etag, template.etag)
&& Objects.equals(parameters, template.parameters)
&& Objects.equals(conditions, template.conditions)
&& Objects.equals(parameterGroups, template.parameterGroups);
&& Objects.equals(parameterGroups, template.parameterGroups)
&& Objects.equals(version, template.version);
}

@Override
public int hashCode() {
return Objects.hash(etag, parameters, conditions, parameterGroups);
return Objects.hash(etag, parameters, conditions, parameterGroups, version);
}
}
91 changes: 91 additions & 0 deletions src/main/java/com/google/firebase/remoteconfig/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.firebase.remoteconfig;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.firebase.internal.NonNull;
import com.google.firebase.internal.Nullable;
import com.google.firebase.remoteconfig.internal.TemplateResponse.UserResponse;

import java.util.Objects;

/**
* Represents a Remote Config user. Output only.
*/
public class User {

private final String email;
private final String name;
private final String imageUrl;

User(@NonNull UserResponse userResponse) {
checkNotNull(userResponse);
this.email = userResponse.getEmail();
this.name = userResponse.getName();
this.imageUrl = userResponse.getImageUrl();
}

/**
* Gets the email of the user.
*
* @return The email of the user or null.
*/
@Nullable
public String getEmail() {
return email;
}

/**
* Gets the name of the user.
*
* @return The name of the user or null.
*/
@Nullable
public String getName() {
return name;
}

/**
* Gets the image URL of the user.
*
* @return The image URL of the user or null.
*/
@Nullable
public String getImageUrl() {
return imageUrl;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
return Objects.equals(email, user.email)
&& Objects.equals(name, user.name)
&& Objects.equals(imageUrl, user.imageUrl);
}

@Override
public int hashCode() {
return Objects.hash(email, name, imageUrl);
}
}
Loading