}
@Override
- public final T parseValue(final Object ctx, final String str) {
+ public final T parseValue(final String str) {
return codec.deserialize(str);
}
import org.opendaylight.yangtools.yang.common.Empty;
final class EmptyJSONCodec implements JSONCodec<Empty> {
-
static final EmptyJSONCodec INSTANCE = new EmptyJSONCodec();
private EmptyJSONCodec() {
-
+ // Hidden on purpose
}
@Override
}
@Override
- public Empty parseValue(final Object ctx, final String input) {
+ public Empty parseValue(final String input) {
return Empty.value();
}
}
@Override
- public QName parseValue(final Object ctx, final String value) {
+ public QName parseValue(final String value) {
return IdentityCodecUtil.parseIdentity(value, context, prefix -> {
if (prefix.isEmpty()) {
return parentModule;
*/
@Override
void writeValue(JsonWriter ctx, T value) throws IOException;
-}
+
+ /**
+ * {@inheritDoc}.
+ *
+ * @deprecated Use {@link #parseValue(String)} instead.
+ */
+ @Override
+ @Deprecated
+ default T parseValue(final Object ctx, final String str) {
+ return parseValue(str);
+ }
+
+ /**
+ * Parse a String representation into its native format.
+ *
+ * @param str String representation
+ * @return Value in native format
+ * @throws IllegalArgumentException if the value does not parse or pass type validation
+ */
+ T parseValue(String str);
+}
\ No newline at end of file
final String value) {
requireNonNull(schemaNode, "schemaNode cannot be null");
if (schemaNode instanceof LeafSchemaNode leafSchemaNode) {
- return codecFactory.codecFor(leafSchemaNode, resolver).parseValue(null, value);
+ return codecFactory.codecFor(leafSchemaNode, resolver).parseValue(value);
} else if (schemaNode instanceof LeafListSchemaNode leafListSchemaNode) {
- return codecFactory.codecFor(leafListSchemaNode, resolver).parseValue(null, value);
+ return codecFactory.codecFor(leafListSchemaNode, resolver).parseValue(value);
}
throw new IllegalArgumentException("schemaNode " + schemaNode
+ " must be of type LeafSchemaNode or LeafListSchemaNode");
}
@Override
- public final YangInstanceIdentifier parseValue(final Object ctx, final String str) {
+ public final YangInstanceIdentifier parseValue(final String str) {
return deserialize(str);
}
private Object translateValueByType(final String value, final DataSchemaNode node) {
if (node instanceof TypedDataSchemaNode typedNode) {
- return codecs.codecFor(typedNode, stack).parseValue(null, value);
+ return codecs.codecFor(typedNode, stack).parseValue(value);
}
throw new IllegalArgumentException("Unexpected node " + node);
}
}
@Override
- public Object parseValue(final Object ctx, final String str) {
+ public Object parseValue(final String str) {
LOG.warn("Call of the deserializeString method on null codec. No operation performed.");
return null;
}
@Override
@SuppressWarnings("checkstyle:illegalCatch")
- public final T parseValue(final Object ctx, final String str) {
- for (JSONCodec<?> codec : codecs) {
+ public final T parseValue(final String str) {
+ for (var codec : codecs) {
final Object ret;
try {
- ret = codec.parseValue(ctx, str);
+ ret = codec.parseValue(str);
} catch (RuntimeException e) {
LOG.debug("Codec {} did not accept input '{}'", codec, str, e);
continue;
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public final void writeValue(final JsonWriter ctx, final T value) throws IOException {
- for (JSONCodec<?> codec : codecs) {
+ for (var codec : codecs) {
if (!codec.getDataType().isInstance(value)) {
LOG.debug("Codec {} cannot accept input {}, skipping it", codec, value);
continue;
}
@SuppressWarnings("unchecked")
- final JSONCodec<Object> objCodec = (JSONCodec<Object>) codec;
+ final var objCodec = (JSONCodec<Object>) codec;
try {
objCodec.writeValue(ctx, value);
return;
verify(writer).value(captor.capture());
assertEquals(expected, captor.getValue());
- assertEquals(id, CODEC.parseValue(null, expected));
+ assertEquals(id, CODEC.parseValue(expected));
}
private static YangInstanceIdentifier buildYangInstanceIdentifier(final QName node, final QName key,