From: Robert Varga Date: Tue, 20 May 2014 07:21:43 +0000 (+0200) Subject: BUG-509: remove unused code X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~52^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=fd474e19dd339c1abb9ed528ff3fd052004d7fe2 BUG-509: remove unused code Removes unused code, writen -> written, adds a FIXME Change-Id: Id0795edc23f2aef6f73e42d54be877003daf4244 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java index 57e97113eb..909aaae1ca 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java @@ -114,15 +114,17 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, final AugmentationTarget augSchemas, final AugmentationIdentifier identifier) { AugmentationSchema augSchema = null; - allAugments: for (AugmentationSchema potential : augSchemas.getAvailableAugmentations()) { - boolean containsAll = true; - for (DataSchemaNode child : potential.getChildNodes()) { - if (identifier.getPossibleChildNames().contains(child.getQName())) { - augSchema = potential; - break allAugments; + + allAugments: + for (AugmentationSchema potential : augSchemas.getAvailableAugmentations()) { + for (DataSchemaNode child : potential.getChildNodes()) { + if (identifier.getPossibleChildNames().contains(child.getQName())) { + augSchema = potential; + break allAugments; + } } } - } + if (augSchema != null) { return new AugmentationModificationStrategy(augSchema, resolvedTree); } @@ -138,11 +140,11 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override public void verifyStructure(final NodeModification modification) throws IllegalArgumentException { if (modification.getModificationType() == ModificationType.WRITE) { - verifyWritenStructure(modification.getWritenValue()); + verifyWrittenStructure(modification.getWrittenValue()); } } - protected abstract void verifyWritenStructure(NormalizedNode writenValue); + protected abstract void verifyWrittenStructure(NormalizedNode writtenValue); @Override public void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional current) throws DataPreconditionFailedException { @@ -236,8 +238,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper protected abstract StoreMetadataNode applySubtreeChange(NodeModification modification, StoreMetadataNode currentMeta, UnsignedLong subtreeVersion); - public static abstract class ValueNodeModificationStrategy extends - SchemaAwareApplyOperation { + public static abstract class ValueNodeModificationStrategy extends SchemaAwareApplyOperation { private final T schema; private final Class> nodeClass; @@ -249,8 +250,8 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } @Override - protected void verifyWritenStructure(final NormalizedNode writenValue) { - checkArgument(nodeClass.isInstance(writenValue), "Node should must be of type %s", nodeClass); + protected void verifyWrittenStructure(final NormalizedNode writtenValue) { + checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass); } @Override @@ -277,7 +278,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper final Optional currentMeta, final UnsignedLong subtreeVersion) { UnsignedLong nodeVersion = subtreeVersion; return StoreMetadataNode.builder().setNodeVersion(nodeVersion).setSubtreeVersion(subtreeVersion) - .setData(modification.getWritenValue()).build(); + .setData(modification.getWrittenValue()).build(); } @Override @@ -332,13 +333,20 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @SuppressWarnings("rawtypes") @Override - protected void verifyWritenStructure(final NormalizedNode writenValue) { - checkArgument(nodeClass.isInstance(writenValue), "Node should must be of type %s", nodeClass); - checkArgument(writenValue instanceof NormalizedNodeContainer); - NormalizedNodeContainer writenCont = (NormalizedNodeContainer) writenValue; - for (Object child : writenCont.getValue()) { + protected void verifyWrittenStructure(final NormalizedNode writtenValue) { + checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass); + checkArgument(writtenValue instanceof NormalizedNodeContainer); + + NormalizedNodeContainer container = (NormalizedNodeContainer) writtenValue; + for (Object child : container.getValue()) { checkArgument(child instanceof NormalizedNode); - NormalizedNode childNode = (NormalizedNode) child; + + /* + * FIXME: fail-fast semantics: + * + * We can validate the data structure here, aborting the commit + * before it ever progresses to being committed. + */ } } @@ -346,7 +354,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper protected StoreMetadataNode applyWrite(final NodeModification modification, final Optional currentMeta, final UnsignedLong subtreeVersion) { - NormalizedNode newValue = modification.getWritenValue(); + NormalizedNode newValue = modification.getWrittenValue(); final UnsignedLong nodeVersion; if (currentMeta.isPresent()) { @@ -439,8 +447,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper protected abstract NormalizedNodeContainerBuilder createBuilder(NormalizedNode original); } - public static abstract class DataNodeContainerModificationStrategy extends - NormalizedNodeContainerModificationStrategy { + public static abstract class DataNodeContainerModificationStrategy extends NormalizedNodeContainerModificationStrategy { private final T schema; private final LoadingCache childCache = CacheBuilder.newBuilder() @@ -490,8 +497,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } - public static class ContainerModificationStrategy extends - DataNodeContainerModificationStrategy { + public static class ContainerModificationStrategy extends DataNodeContainerModificationStrategy { public ContainerModificationStrategy(final ContainerSchemaNode schemaNode) { super(schemaNode, ContainerNode.class); @@ -505,8 +511,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } } - public static class UnkeyedListItemModificationStrategy extends - DataNodeContainerModificationStrategy { + public static class UnkeyedListItemModificationStrategy extends DataNodeContainerModificationStrategy { public UnkeyedListItemModificationStrategy(final ListSchemaNode schemaNode) { super(schemaNode, UnkeyedListEntryNode.class); @@ -520,8 +525,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } } - public static class AugmentationModificationStrategy extends - DataNodeContainerModificationStrategy { + public static class AugmentationModificationStrategy extends DataNodeContainerModificationStrategy { protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) { super(createAugmentProxy(schema,resolved), AugmentationNode.class); @@ -537,12 +541,10 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper public static class ChoiceModificationStrategy extends NormalizedNodeContainerModificationStrategy { - private final ChoiceNode schema; private final Map childNodes; public ChoiceModificationStrategy(final ChoiceNode schemaNode) { super(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode.class); - this.schema = schemaNode; ImmutableMap.Builder child = ImmutableMap.builder(); for (ChoiceCaseNode caze : schemaNode.getCases()) { @@ -656,7 +658,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override protected StoreMetadataNode applyWrite(final NodeModification modification, final Optional currentMeta, final UnsignedLong subtreeVersion) { - return StoreMetadataNode.createRecursively(modification.getWritenValue(), subtreeVersion); + return StoreMetadataNode.createRecursively(modification.getWrittenValue(), subtreeVersion); } @Override @@ -668,7 +670,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } @Override - protected void verifyWritenStructure(final NormalizedNode writenValue) { + protected void verifyWrittenStructure(final NormalizedNode writtenValue) { } @@ -740,10 +742,6 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } } - public void verifyIdentifier(final PathArgument identifier) { - - } - public static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) { Set realChildSchemas = new HashSet<>(); for(DataSchemaNode augChild : schema.getChildNodes()) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java index 71897e8098..0f9a335627 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java @@ -68,7 +68,7 @@ public class NodeModification implements StoreTreeNode, Identi * * @return */ - public NormalizedNode getWritenValue() { + public NormalizedNode getWrittenValue() { return value; }