*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
+import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
final AugmentationSchemaNode augment = SchemaUtils.findCorrespondingAugment(cazeDef.getSchema(),
cazeChild);
if (augment != null) {
- byYangCaseChildBuilder.put(SchemaUtils.getNodeIdentifierForAugmentation(augment), cazeDef);
+ byYangCaseChildBuilder.put(DataSchemaContextNode.augmentationIdentifierFrom(augment),
+ cazeDef);
continue;
}
}
return DataContainerCodecPrototype.from(childClass, childSchema.get(), factory());
}
- LOG.debug("Supplied class %s is not valid case in schema %s", childClass, getSchema());
+ LOG.debug("Supplied class {} is not valid case in schema {}", childClass, getSchema());
return null;
}
@Override
- public NodeCodecContext<?> yangPathArgumentChild(final YangInstanceIdentifier.PathArgument arg) {
+ public NodeCodecContext yangPathArgumentChild(final YangInstanceIdentifier.PathArgument arg) {
final DataContainerCodecPrototype<?> cazeProto;
if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
cazeProto = byYangCaseChild.get(new NodeIdentifier(arg.getNodeType()));
cazeProto = byYangCaseChild.get(arg);
}
- return childNonNull(cazeProto, arg,"Argument %s is not valid child of %s", arg, getSchema()).get()
+ return childNonNull(cazeProto, arg, "Argument %s is not valid child of %s", arg, getSchema()).get()
.yangPathArgumentChild(arg);
}
@SuppressWarnings("unchecked")
@Override
- @Nullable
public D deserialize(final NormalizedNode<?, ?> data) {
- Preconditions.checkArgument(data instanceof ChoiceNode);
- final NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>> casted =
- (NormalizedNodeContainer<?, ?, NormalizedNode<?, ?>>) data;
+ checkArgument(data instanceof ChoiceNode);
+ final ChoiceNode casted = (ChoiceNode) data;
final NormalizedNode<?, ?> first = Iterables.getFirst(casted.getValue(), null);
if (first == null) {
+ // FIXME: this needs to be sorted out
return null;
}
final DataContainerCodecPrototype<?> caze = byYangCaseChild.get(first.getIdentifier());
@Override
public PathArgument deserializePathArgument(final YangInstanceIdentifier.PathArgument arg) {
- Preconditions.checkArgument(getDomPathArgument().equals(arg));
+ checkArgument(getDomPathArgument().equals(arg));
return null;
}
return getDomPathArgument();
}
- DataContainerCodecContext<?, ?> getCaseByChildClass(final @Nonnull Class<? extends DataObject> type) {
+ DataContainerCodecContext<?, ?> getCaseByChildClass(final @NonNull Class<? extends DataObject> type) {
DataContainerCodecPrototype<?> result = byCaseChildClass.get(type);
if (result == null) {
// We have not found an unambiguous result, try ambiguous ones