@SuppressWarnings("unchecked")
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "Legacy code")
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) {
if (input instanceof IdentityValuesDTO) {
return typeAwarecodec.deserialize(String.valueOf(input));
} else {
LOG.debug("Codec for type \"{}\" is not implemented yet.", type.getQName().getLocalName());
+ // FIXME: this should be a hard error
return null;
}
}
} catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs
LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
+ // FIXME: this should be a hard error
return null;
}
}
@SuppressWarnings("unchecked")
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "legacy code")
public Object serialize(final Object input) {
try {
if (type instanceof IdentityrefTypeDefinition) {
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
LOG.error("ClassCastException was thrown when codec is invoked with parameter {}", input, e);
+ // FIXME: this should be a hard error
return input;
}
}
}
public static class IdentityrefCodecImpl implements IdentityrefCodec<IdentityValuesDTO> {
-
private static final Logger LOG = LoggerFactory.getLogger(IdentityrefCodecImpl.class);
private final DOMMountPoint mountPoint;
}
@Override
+ @SuppressFBWarnings(value = "NP_NONNULL_RETURN_VIOLATION", justification = "See FIXME below")
public QName deserialize(final IdentityValuesDTO data) {
final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0);
final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint,
controllerContext);
if (module == null) {
+ // FIXME: this should be a hard error
LOG.info("Module was not found for namespace {}", valueWithNamespace.getNamespace());
LOG.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace));
return null;
return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue());
}
-
}
public static class LeafrefCodecImpl implements LeafrefCodec<String> {
return identityValuesDTO;
}
- @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
+ @SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", "NP_NONNULL_RETURN_VIOLATION" },
justification = "Unrecognised NullableDecl")
@Override
public YangInstanceIdentifier deserialize(final IdentityValuesDTO data) {
valueWithNamespace.getNamespace());
LOG.info("Instance-identifier will be translated as NULL for data - {}",
String.valueOf(valueWithNamespace.getValue()));
+ // FIXME: this should be a hard error
return null;
}
final IdentityValue identityValue = identities.get(i);
XMLNamespace validNamespace = resolveValidNamespace(identityValue.getNamespace(), mountPoint,
controllerContext);
- final DataSchemaNode node = ControllerContext.findInstanceDataChildByNameAndNamespace(
- parentContainer, identityValue.getValue(), validNamespace);
- if (node == null) {
+ final var found = ControllerContext.findInstanceDataChildByNameAndNamespace(
+ parentContainer, identityValue.getValue(), validNamespace);
+ if (found == null) {
LOG.info("'{}' node was not found in {}", identityValue, parentContainer.getChildNodes());
LOG.info("Instance-identifier will be translated as NULL for data - {}",
String.valueOf(identityValue.getValue()));
+ // FIXME: this should be a hard error
return null;
}
+ final DataSchemaNode node = found.child;
final QName qName = node.getQName();
PathArgument pathArgument = null;
if (identityValue.getPredicates().isEmpty()) {
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 - {}",
String.valueOf(identityValue.getValue()));
+ // FIXME: this should be a hard error
return null;
}
pathArgument = new NodeWithValue<>(qName, leafListPredicate.getValue());
for (final Predicate predicate : identityValue.getPredicates()) {
validNamespace = resolveValidNamespace(predicate.getName().getNamespace(), mountPoint,
controllerContext);
- final DataSchemaNode listKey = ControllerContext
+ final var listKey = ControllerContext
.findInstanceDataChildByNameAndNamespace(listNode, predicate.getName().getValue(),
validNamespace);
- predicatesMap.put(listKey.getQName(), predicate.getValue());
+ predicatesMap.put(listKey.child.getQName(), predicate.getValue());
}
pathArgument = NodeIdentifierWithPredicates.of(qName, predicatesMap);
} else {
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()));
+ // FIXME: this should be a hard error
return null;
}
}
LOG.info("Node {} isn't instance of DataNodeContainer", node);
LOG.info("Instance-identifier will be translated as NULL for data - {}",
String.valueOf(identityValue.getValue()));
+ // FIXME: this should be a hard error
return null;
}
}
}
}
- @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 ControllerContext controllerContext) {
final XMLNamespace validNamespace = resolveValidNamespace(namespace, mountPoint, controllerContext);
return validNamespace;
}
-
}