X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-protocolbuffer-encoding%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FNodeIdentifierWithValueGenerator.java;h=2d434fffcfe8b9f538aa51f828a382498f21e9bd;hb=eff56082a308f3be21cd4eefd03e0799a6b04714;hp=fcde679bedab36d90715af74a269cad259bdf33a;hpb=fe4049d34de103016d11f3a9050853c6380646d3;p=controller.git diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java index fcde679bed..2d434fffcf 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java @@ -1,18 +1,33 @@ +/* + * + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + */ + package org.opendaylight.controller.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import java.util.regex.Matcher; import java.util.regex.Pattern; public class NodeIdentifierWithValueGenerator{ private final String id; - private static final Pattern pattern = Pattern.compile("(.*)\\Q[\\E(.*)\\Q]\\E"); + private final DataSchemaNode schemaNode; + private static final Pattern pattern = Pattern.compile("(.*)\\Q[\\E(.*)\\Q]\\E"); private final Matcher matcher; private final boolean doesMatch; - public NodeIdentifierWithValueGenerator(String id){ + public NodeIdentifierWithValueGenerator(String id, DataSchemaNode schemaNode){ this.id = id; + this.schemaNode = schemaNode; matcher = pattern.matcher(this.id); doesMatch = matcher.matches(); } @@ -26,6 +41,18 @@ public class NodeIdentifierWithValueGenerator{ final String value = matcher.group(2); return new YangInstanceIdentifier.NodeWithValue( - QNameFactory.create(name), value); + QNameFactory.create(name), getValue(value)); } + + private Object getValue(String value){ + if(schemaNode != null){ + if(schemaNode instanceof LeafListSchemaNode){ + return TypeDefinitionAwareCodec + .from(LeafListSchemaNode.class.cast(schemaNode).getType()).deserialize(value); + + } + } + return value; + } + }