private ObjectCodec(final TypeDefinition<?> typeDefinition, final DOMMountPoint mountPoint,
final EffectiveModelContext schemaContext) {
this.schemaContext = schemaContext;
- this.type = RestUtil.resolveBaseTypeFrom(typeDefinition);
- if (this.type instanceof IdentityrefTypeDefinition) {
- this.identityrefCodec = new IdentityrefCodecImpl(mountPoint, schemaContext);
+ type = RestUtil.resolveBaseTypeFrom(typeDefinition);
+ if (type instanceof IdentityrefTypeDefinition) {
+ identityrefCodec = new IdentityrefCodecImpl(mountPoint, schemaContext);
} else {
- this.identityrefCodec = null;
+ identityrefCodec = null;
}
- if (this.type instanceof InstanceIdentifierTypeDefinition) {
- this.instanceIdentifier = new InstanceIdentifierCodecImpl(mountPoint, schemaContext);
+ if (type instanceof InstanceIdentifierTypeDefinition) {
+ instanceIdentifier = new InstanceIdentifierCodecImpl(mountPoint, schemaContext);
} else {
- this.instanceIdentifier = null;
+ instanceIdentifier = null;
}
}
@SuppressWarnings("unchecked")
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "Legacy returns")
public Object deserialize(final Object input) {
try {
if (type instanceof IdentityrefTypeDefinition) {
+ "Therefore NULL is used as translation of - {}",
input == null ? "null" : input.getClass(), String.valueOf(input));
}
+ // FIXME: this should be a hard error
return null;
} else if (type instanceof InstanceIdentifierTypeDefinition) {
return input instanceof IdentityValuesDTO ? instanceIdentifier.deserialize(input)
: new StringModuleInstanceIdentifierCodec(schemaContext).deserialize((String) input);
} else {
final TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> typeAwarecodec =
- TypeDefinitionAwareCodec.from(this.type);
+ TypeDefinitionAwareCodec.from(type);
if (typeAwarecodec != null) {
if (input instanceof IdentityValuesDTO) {
return typeAwarecodec.deserialize(((IdentityValuesDTO) input).getOriginValue());
}
return typeAwarecodec.deserialize(String.valueOf(input));
} else {
+ // FIXME: this should be a hard error
LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
return null;
}
}
- } catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
+ } catch (final ClassCastException e) {
+ // FIXME: remove this catch when everyone use codecs
+ // FIXME: this should be a hard error
LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return null;
}
@SuppressWarnings("unchecked")
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "Legacy returns")
public Object serialize(final Object input) {
try {
- if (this.type instanceof IdentityrefTypeDefinition) {
- return this.identityrefCodec.serialize(input);
- } else if (this.type instanceof LeafrefTypeDefinition) {
+ if (type instanceof IdentityrefTypeDefinition) {
+ return identityrefCodec.serialize(input);
+ } else if (type instanceof LeafrefTypeDefinition) {
return LEAFREF_DEFAULT_CODEC.serialize(input);
- } else if (this.type instanceof InstanceIdentifierTypeDefinition) {
- return this.instanceIdentifier.serialize(input);
+ } else if (type instanceof InstanceIdentifierTypeDefinition) {
+ return instanceIdentifier.serialize(input);
} else {
final TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> typeAwarecodec =
- TypeDefinitionAwareCodec.from(this.type);
+ TypeDefinitionAwareCodec.from(type);
if (typeAwarecodec != null) {
return typeAwarecodec.serialize(input);
} else {
+ // FIXME: this needs to be a hard error
if (LOG.isDebugEnabled()) {
LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
}
return null;
}
}
- } catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
+ } catch (final ClassCastException e) {
+ // FIXME: remove this catch when everyone use codecs
+ // FIXME: this needs to be a hard error
LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
return input;
}
}
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "Legacy return")
public QName deserialize(final IdentityValuesDTO data) {
final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0);
- final Module module =
- getModuleByNamespace(valueWithNamespace.getNamespace(), this.mountPoint, schemaContext);
+ final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint, schemaContext);
+ // FIXME: this needs to be a hard error
if (module == null) {
LOG.info("Module was not found for namespace {}", valueWithNamespace.getNamespace());
LOG.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace));
@SuppressFBWarnings(value = {
"NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
- "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"
+ "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
+ "NP_NONNULL_RETURN_VIOLATION"
}, justification = "Unrecognised NullableDecl")
@Override
public YangInstanceIdentifier deserialize(final IdentityValuesDTO data) {
final List<PathArgument> result = new ArrayList<>();
final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0);
- final Module module =
- getModuleByNamespace(valueWithNamespace.getNamespace(), this.mountPoint, schemaContext);
+ final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint, schemaContext);
+ // FIXME: this needs to be a hard error
if (module == null) {
LOG.info("Module by namespace '{}' of first node in instance-identifier was not found.",
valueWithNamespace.getNamespace());
for (int i = 0; i < identities.size(); i++) {
final IdentityValue identityValue = identities.get(i);
XMLNamespace validNamespace =
- resolveValidNamespace(identityValue.getNamespace(), this.mountPoint, schemaContext);
+ resolveValidNamespace(identityValue.getNamespace(), mountPoint, schemaContext);
final DataSchemaNode node = findInstanceDataChildByNameAndNamespace(
parentContainer, identityValue.getValue(), validNamespace);
+ // FIXME: this needs to be a hard error
if (node == null) {
LOG.info("'{}' node was not found in {}", identityValue, parentContainer.getChildNodes());
LOG.info("Instance-identifier will be translated as NULL for data - {}",
} else {
if (node instanceof LeafListSchemaNode) { // predicate is value of leaf-list entry
final Predicate leafListPredicate = identityValue.getPredicates().get(0);
+ // FIXME: this needs to be a hard error
if (!leafListPredicate.isLeafList()) {
LOG.info("Predicate's data is not type of leaf-list. It should be in format \".='value'\"");
LOG.info("Instance-identifier will be translated as NULL for data - {}",
final DataNodeContainer listNode = (DataNodeContainer) node;
final Map<QName, Object> predicatesMap = new HashMap<>();
for (final Predicate predicate : identityValue.getPredicates()) {
- validNamespace = resolveValidNamespace(predicate.getName().getNamespace(), this.mountPoint,
+ validNamespace = resolveValidNamespace(predicate.getName().getNamespace(), mountPoint,
schemaContext);
final DataSchemaNode listKey = findInstanceDataChildByNameAndNamespace(listNode,
predicate.getName().getValue(), validNamespace);
}
pathArgument = NodeIdentifierWithPredicates.of(qName, predicatesMap);
} else {
+ // FIXME: this needs to be a hard error
LOG.info("Node {} is not List or Leaf-list.", node);
LOG.info("Instance-identifier will be translated as NULL for data - {}",
String.valueOf(identityValue.getValue()));
if (node instanceof DataNodeContainer) {
parentContainer = (DataNodeContainer) node;
} else {
+ // FIXME: this needs to be a hard error
LOG.info("Node {} isn't instance of DataNodeContainer", node);
LOG.info("Instance-identifier will be translated as NULL for data - {}",
String.valueOf(identityValue.getValue()));
}
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static Module getModuleByNamespace(final String namespace, final DOMMountPoint mountPoint,
final SchemaContext schemaContext) {
final XMLNamespace validNamespace = resolveValidNamespace(namespace, mountPoint, schemaContext);
return null;
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container,
final String name, final XMLNamespace namespace) {
requireNonNull(namespace);