Skip to content

Commit a18812d

Browse files
authored
add layers and rollouts (#115)
* create layer model in SDK * create rollout model
1 parent 8ecbcd1 commit a18812d

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 javax.annotation.concurrent.Immutable;
20+
import java.util.List;
21+
22+
/**
23+
* Represents a Optimizely Rollout configuration
24+
*
25+
* @see <a href="http://developers.optimizely.com/server/reference/index.html#json">Project JSON</a>
26+
*/
27+
@Immutable
28+
public class Rollout extends Layer implements IdMapped {
29+
30+
public Rollout(String id,
31+
String policy,
32+
List<Experiment> experiments) {
33+
super(id, policy, experiments);
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return "Rollout{" +
39+
"id='" + id + '\'' +
40+
", policy='" + policy + '\'' +
41+
", experiments=" + experiments +
42+
'}';
43+
}
44+
}

0 commit comments

Comments
 (0)