1 | /*- | |
2 | * #%L | |
3 | * io.earcam.utilitarian.site.deploy.netlify | |
4 | * %% | |
5 | * Copyright (C) 2017 earcam | |
6 | * %% | |
7 | * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT) | |
8 | * | |
9 | * You <b>must</b> choose to accept, in full - any individual or combination of | |
10 | * the following licenses: | |
11 | * <ul> | |
12 | * <li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li> | |
13 | * <li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li> | |
14 | * <li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li> | |
15 | * <li><a href="https://opensource.org/licenses/MIT">MIT</a></li> | |
16 | * </ul> | |
17 | * #L% | |
18 | */ | |
19 | package io.earcam.utilitarian.site.deploy.netlify; | |
20 | ||
21 | import static io.earcam.unexceptional.Closing.closeAfterAccepting; | |
22 | ||
23 | import java.io.OutputStream; | |
24 | ||
25 | import javax.annotation.WillClose; | |
26 | import javax.json.Json; | |
27 | import javax.json.JsonObject; | |
28 | import javax.json.JsonObjectBuilder; | |
29 | import javax.json.JsonWriter; | |
30 | ||
31 | public class Site { | |
32 | ||
33 | private static final String FIELD_NAME = "name"; | |
34 | private static final String FIELD_CUSTOM_DOMAIN = "custom_domain"; | |
35 | private static final String FIELD_FORCE_SSL = "force_ssl"; | |
36 | private static final String FIELD_SSL = "ssl"; | |
37 | private static final String FIELD_MANAGED_DNS = "managed_dns"; | |
38 | private static final String FIELD_ID = "id"; | |
39 | ||
40 | // all params are optional | |
41 | private String name; | |
42 | private String customDomain; | |
43 | private boolean forceSsl; | |
44 | private boolean ssl; | |
45 | private boolean managedDns; | |
46 | private String id; | |
47 | ||
48 | ||
49 | public void writeJson(@WillClose OutputStream output) | |
50 | { | |
51 |
1
1. writeJson : removed call to io/earcam/unexceptional/Closing::closeAfterAccepting → KILLED |
closeAfterAccepting(Json::createWriter, output, toJsonObject(), JsonWriter::write); |
52 | } | |
53 | ||
54 | ||
55 | public JsonObject toJsonObject() | |
56 | { | |
57 | JsonObjectBuilder builder = Json.createObjectBuilder(); | |
58 |
1
1. toJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::addNotNullable → KILLED |
addNotNullable(builder, FIELD_NAME, name()); |
59 |
1
1. toJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::addNotNullable → SURVIVED |
addNotNullable(builder, FIELD_ID, id()); |
60 |
1
1. toJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::addNotNullable → KILLED |
addNotNullable(builder, FIELD_CUSTOM_DOMAIN, customDomain()); |
61 | builder.add(FIELD_FORCE_SSL, forceSsl()); | |
62 | builder.add(FIELD_SSL, ssl()); | |
63 | builder.add(FIELD_MANAGED_DNS, managedDns()); | |
64 |
1
1. toJsonObject : mutated return of Object value for io/earcam/utilitarian/site/deploy/netlify/Site::toJsonObject to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return builder.build(); |
65 | } | |
66 | ||
67 | ||
68 | private static void addNotNullable(JsonObjectBuilder builder, String field, String value) | |
69 | { | |
70 |
1
1. addNotNullable : negated conditional → KILLED |
if(value != null) { |
71 | builder.add(field, value); | |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | public static Site fromJsonObject(JsonObject json) | |
77 | { | |
78 | Site site = new Site(); | |
79 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setName → KILLED |
site.setName(json.getString(FIELD_NAME, null)); |
80 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setId → KILLED |
site.setId(json.getString(FIELD_ID, null)); |
81 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setCustomDomain → SURVIVED |
site.setCustomDomain(json.getString(FIELD_CUSTOM_DOMAIN, null)); |
82 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setForceSsl → SURVIVED |
site.setForceSsl(json.getBoolean(FIELD_FORCE_SSL, false)); |
83 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setSsl → SURVIVED |
site.setSsl(json.getBoolean(FIELD_SSL, false)); |
84 |
1
1. fromJsonObject : removed call to io/earcam/utilitarian/site/deploy/netlify/Site::setManagedDns → SURVIVED |
site.setManagedDns(json.getBoolean(FIELD_MANAGED_DNS, false)); |
85 |
1
1. fromJsonObject : mutated return of Object value for io/earcam/utilitarian/site/deploy/netlify/Site::fromJsonObject to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return site; |
86 | } | |
87 | ||
88 | ||
89 | public void setName(String name) | |
90 | { | |
91 | this.name = name; | |
92 | } | |
93 | ||
94 | ||
95 | public void setCustomDomain(String customDomain) | |
96 | { | |
97 | this.customDomain = customDomain; | |
98 | } | |
99 | ||
100 | ||
101 | public void setForceSsl(boolean forceSsl) | |
102 | { | |
103 | this.forceSsl = forceSsl; | |
104 | } | |
105 | ||
106 | ||
107 | public void setSsl(boolean ssl) | |
108 | { | |
109 | this.ssl = ssl; | |
110 | } | |
111 | ||
112 | ||
113 | public void setManagedDns(boolean managedDns) | |
114 | { | |
115 | this.managedDns = managedDns; | |
116 | } | |
117 | ||
118 | ||
119 | public void setId(String id) | |
120 | { | |
121 | this.id = id; | |
122 | } | |
123 | ||
124 | ||
125 | public String name() | |
126 | { | |
127 |
1
1. name : mutated return of Object value for io/earcam/utilitarian/site/deploy/netlify/Site::name to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return name; |
128 | } | |
129 | ||
130 | ||
131 | public String customDomain() | |
132 | { | |
133 |
1
1. customDomain : mutated return of Object value for io/earcam/utilitarian/site/deploy/netlify/Site::customDomain to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return customDomain; |
134 | } | |
135 | ||
136 | ||
137 | public boolean forceSsl() | |
138 | { | |
139 |
1
1. forceSsl : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return forceSsl; |
140 | } | |
141 | ||
142 | ||
143 | public boolean ssl() | |
144 | { | |
145 |
1
1. ssl : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return ssl; |
146 | } | |
147 | ||
148 | ||
149 | public boolean managedDns() | |
150 | { | |
151 |
1
1. managedDns : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return managedDns; |
152 | } | |
153 | ||
154 | ||
155 | public String id() | |
156 | { | |
157 |
1
1. id : mutated return of Object value for io/earcam/utilitarian/site/deploy/netlify/Site::id to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return id; |
158 | } | |
159 | } | |
Mutations | ||
51 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
64 |
1.1 |
|
70 |
1.1 |
|
79 |
1.1 |
|
80 |
1.1 |
|
81 |
1.1 |
|
82 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
85 |
1.1 |
|
127 |
1.1 |
|
133 |
1.1 |
|
139 |
1.1 |
|
145 |
1.1 |
|
151 |
1.1 |
|
157 |
1.1 |