|
| 1 | +/** |
| 2 | + * |
| 3 | + * Copyright 2017, Optimizely and contributors |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package com.optimizely.ab.config; |
| 18 | + |
| 19 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 20 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 21 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 22 | + |
| 23 | +import java.util.List; |
| 24 | + |
| 25 | +import javax.annotation.concurrent.Immutable; |
| 26 | + |
| 27 | +/** |
| 28 | + * Represents a Optimizely Layer configuration |
| 29 | + * |
| 30 | + * @see <a href="http://developers.optimizely.com/server/reference/index.html#json">Project JSON</a> |
| 31 | + */ |
| 32 | +@Immutable |
| 33 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 34 | +public class Layer implements IdMapped { |
| 35 | + |
| 36 | + protected final String id; |
| 37 | + protected final String policy; |
| 38 | + protected final List<Experiment> experiments; |
| 39 | + |
| 40 | + public static final String SINGLE_EXPERIMENT_POLICY = "single_experiment"; |
| 41 | + |
| 42 | + @JsonCreator |
| 43 | + public Layer(@JsonProperty("id") String id, |
| 44 | + @JsonProperty("policy") String policy, |
| 45 | + @JsonProperty("experiments") List<Experiment> experiments) { |
| 46 | + this.id = id; |
| 47 | + this.policy = policy; |
| 48 | + this.experiments = experiments; |
| 49 | + } |
| 50 | + |
| 51 | + public String getId() { |
| 52 | + return id; |
| 53 | + } |
| 54 | + |
| 55 | + public String getPolicy() { |
| 56 | + return policy; |
| 57 | + } |
| 58 | + |
| 59 | + public List<Experiment> getExperiments() { |
| 60 | + return experiments; |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public String toString() { |
| 65 | + return "Layer{" + |
| 66 | + "id='" + id + '\'' + |
| 67 | + ", policy='" + policy + '\'' + |
| 68 | + ", experiments=" + experiments + |
| 69 | + '}'; |
| 70 | + } |
| 71 | +} |
0 commit comments