254 arrayField(key, value.get());
255 }
256
257 private static <A> JsonNode encode(JsonCodec<A> codec, A obj, String key) {258 try {259 return codec.encode(obj);260 } catch (JsonException exc) {261 throw new JsonCodecException(key + " > " + exc.getMessage(), exc);262 }263 }264
265 @Override
266 public <A> void field(String key, JsonCodec<A> codec, A value) {
221 return json;
222 }
223
224 private static <A extends JsonRepresentable> JsonNode encode(A obj, String key) {225 try {226 return obj.toJson();227 } catch (JsonException exc) {228 throw new JsonCodecException(key + " > " + exc.getMessage(), exc);229 }230 }231
232 @Override
233 public void field(String key, JsonRepresentable value) {
167 applyField(key, json -> applier.accept(decode(codec, json, key)));
168 }
169
170 private static <A extends JsonEncodable> A decode(Function<JsonNode, A> factory, JsonNode node, String key) {171 try {172 A obj = factory.apply(node);173 obj.fromJson(node);174 return obj;175 } catch (JsonException exc) {176 throw new JsonCodecException(key + " > " + exc.getMessage(), exc);177 }178 }179
180 @Override
181 public <A extends JsonEncodable> A field(String key, Function<JsonNode, A> factory) {
143 }
144 }
145
146 private static <A> A decode(JsonCodec<A> codec, JsonNode node, String key) {147 try {148 return codec.decode(node);149 } catch (JsonException exc) {150 throw new JsonCodecException(key + " > " + exc.getMessage(), exc);151 }152 }153
154 @Override
155 public <A> A field(String key, JsonCodec<A> codec) {
This private method is never called. Although it is possible that the method will be invoked through reflection, it is more likely that the method is never used, and should be removed.
Unless this method is intended to be used with reflection, it is recommended to remove it to increase code clarity.
If this method is intended to be called through reflection, ensure that the reflective access is implemented correctly.