no.finn.unleash.UnleashContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unleash-client-java Show documentation
Show all versions of unleash-client-java Show documentation
A client library for Unleash
package no.finn.unleash;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class UnleashContext {
private final Optional userId;
private final Optional sessionId;
private final Optional remoteAddress;
private final Map properties;
public UnleashContext(String userId, String sessionId, String remoteAddress, Map properties) {
this.userId = Optional.ofNullable(userId);
this.sessionId = Optional.ofNullable(sessionId);
this.remoteAddress = Optional.ofNullable(remoteAddress);
this.properties = properties;
}
public Optional getUserId() {
return userId;
}
public Optional getSessionId() {
return sessionId;
}
public Optional getRemoteAddress() {
return remoteAddress;
}
public Map getProperties() {
return properties;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private String userId;
private String sessionId;
private String remoteAddress;
private final Map properties = new HashMap<>();
public Builder userId(String userId) {
this.userId = userId;
return this;
}
public Builder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}
public Builder remoteAddress(String remoteAddress) {
this.remoteAddress = remoteAddress;
return this;
}
public Builder addProperty(String name, String value) {
properties.put(name, value);
return this;
}
public UnleashContext build() {
return new UnleashContext(userId, sessionId, remoteAddress, properties);
}
}
}