2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore.node.utils;
11 import com.google.common.base.Splitter;
12 import java.util.HashSet;
14 import java.util.regex.Matcher;
15 import java.util.regex.Pattern;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 public class AugmentationIdentifierGenerator {
20 private static final Pattern PATTERN =
21 Pattern.compile("AugmentationIdentifier\\Q{\\EchildNames=\\Q[\\E(.*)\\Q]}\\E");
22 private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults();
24 private final String id;
25 private final Matcher matcher;
26 private final boolean doesMatch;
28 public AugmentationIdentifierGenerator(String id) {
30 matcher = PATTERN.matcher(this.id);
31 doesMatch = matcher.matches();
34 public boolean matches() {
38 public YangInstanceIdentifier.AugmentationIdentifier getPathArgument() {
39 final String childQNames = matcher.group(1);
41 final Set<QName> childNames = new HashSet<>();
42 for (String name : COMMA_SPLITTER.split(childQNames)) {
43 childNames.add(QNameFactory.create(name));
46 return new YangInstanceIdentifier.AugmentationIdentifier(childNames);