*/
package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
-import com.google.common.base.Optional;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
final class NormalizedNodeBuilderWrapper {
private final NormalizedNodeContainerBuilder<?, ?, ?, ?> builder;
private final PathArgument identifier;
- private final Optional<DataSchemaContextNode<?>> schemaNode;
+ private final DataSchemaContextNode<?> schemaNode;
NormalizedNodeBuilderWrapper(final NormalizedNodeContainerBuilder<?, ?, ?, ?> builder,
- final PathArgument identifier, final Optional<DataSchemaContextNode<?>> schemaNode) {
- this.builder = builder;
- this.identifier = identifier;
+ final PathArgument identifier, final @Nullable DataSchemaContextNode<?> schemaNode) {
+ this.builder = requireNonNull(builder);
+ this.identifier = requireNonNull(identifier);
this.schemaNode = schemaNode;
}
return identifier;
}
- Optional<DataSchemaContextNode<?>> getSchema() {
+ @Nullable DataSchemaContextNode<?> getSchema() {
return schemaNode;
}
}
import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Optional;
import java.net.URI;
import java.util.ArrayDeque;
import java.util.Deque;
throw new IllegalStateException("endNode called on an empty stack", e);
}
- if (!child.getSchema().isPresent()) {
+ if (child.getSchema() == null) {
LOG.debug("Schema not found for {}", child.identifier());
return;
}
}
private static boolean hasValidSchema(final QName name, final NormalizedNodeBuilderWrapper parent) {
- boolean valid = parent.getSchema().isPresent() && parent.getSchema().get().getChild(name) != null;
+ final DataSchemaContextNode<?> parentSchema = parent.getSchema();
+ final boolean valid = parentSchema != null && parentSchema.getChild(name) != null;
if (!valid) {
LOG.debug("Schema not found for {}", name);
}
private NormalizedNodeBuilderWrapper addBuilder(final NormalizedNodeContainerBuilder<?, ?, ?, ?> builder,
final PathArgument identifier) {
- final Optional<DataSchemaContextNode<?>> schemaNode;
- NormalizedNodeBuilderWrapper parent = stack.peek();
- if (parent == null) {
- schemaNode = Optional.fromNullable(nodePathSchemaNode);
- } else if (parent.getSchema().isPresent()) {
- schemaNode = Optional.fromNullable(parent.getSchema().get().getChild(identifier));
+ final DataSchemaContextNode<?> schemaNode;
+ final NormalizedNodeBuilderWrapper parent = stack.peek();
+ if (parent != null) {
+ final DataSchemaContextNode<?> parentSchema = parent.getSchema();
+ schemaNode = parentSchema == null ? null : parentSchema.getChild(identifier);
} else {
- schemaNode = Optional.absent();
+ schemaNode = nodePathSchemaNode;
}
NormalizedNodeBuilderWrapper wrapper = new NormalizedNodeBuilderWrapper(builder, identifier, schemaNode);