X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FAugmentationIdentifierGenerator.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FAugmentationIdentifierGenerator.java;h=e2c4c358935c184c9244b969533fcf86175e55e8;hb=6b9c0bb57b65343df31fd68d178821a22afd0fe2;hp=0000000000000000000000000000000000000000;hpb=cc6c063be5f143cd601208ef26604d90a25bd1a5;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java new file mode 100644 index 0000000000..e2c4c35893 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java @@ -0,0 +1,52 @@ +/* + * + * 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.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class AugmentationIdentifierGenerator { + private final String id; + private static final Pattern pattern = Pattern.compile("AugmentationIdentifier\\Q{\\EchildNames=\\Q[\\E(.*)\\Q]}\\E"); + private final Matcher matcher; + private final boolean doesMatch; + + public AugmentationIdentifierGenerator(String id){ + this.id = id; + matcher = pattern.matcher(this.id); + doesMatch = matcher.matches(); + } + + public boolean matches(){ + return doesMatch; + } + + public YangInstanceIdentifier.AugmentationIdentifier getPathArgument(){ + Set childNames = new HashSet(); + final String childQNames = matcher.group(1); + + final String[] splitChildQNames = childQNames.split(","); + + for(String name : splitChildQNames){ + childNames.add( + org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory + .create(name.trim())); + } + + return new YangInstanceIdentifier.AugmentationIdentifier(null, childNames); + } + +}