From 69528ecf92a44963df75ef5bb52af37bc09eb80a Mon Sep 17 00:00:00 2001 From: wangjoshuah Date: Mon, 12 Jun 2017 16:43:31 -0700 Subject: [PATCH] Add Features to SDK --- .../com/optimizely/ab/config/Feature.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 core-api/src/main/java/com/optimizely/ab/config/Feature.java diff --git a/core-api/src/main/java/com/optimizely/ab/config/Feature.java b/core-api/src/main/java/com/optimizely/ab/config/Feature.java new file mode 100644 index 000000000..739c6cbce --- /dev/null +++ b/core-api/src/main/java/com/optimizely/ab/config/Feature.java @@ -0,0 +1,80 @@ +/** + * + * Copyright 2017, Optimizely and contributors + * + * 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.optimizely.ab.config; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Represents a Feature definition at the project level + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Feature implements IdKeyMapped{ + + private final String id; + private final String key; + private final String layerId; + private final List experimentIds; + private final List variables; + + @JsonCreator + public Feature(@JsonProperty("id") String id, + @JsonProperty("key") String key, + @JsonProperty("layerId") String layerId, + @JsonProperty("experimentIds") List experimentIds, + @JsonProperty("variables") List variables) { + this.id = id; + this.key = key; + this.layerId = layerId; + this.experimentIds = experimentIds; + this.variables = variables; + } + + public String getId() { + return id; + } + + public String getKey() { + return key; + } + + public String getLayerId() { + return layerId; + } + + public List getExperimentIds() { + return experimentIds; + } + + public List getVariables() { + return variables; + } + + @Override + public String toString() { + return "Feature{" + + "id='" + id + '\'' + + ", key='" + key + '\'' + + ", layerId='" + layerId + '\'' + + ", experimentIds=" + experimentIds + + ", variables=" + variables + + '}'; + } +}