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 = Pattern.compile("AugmentationIdentifier\\Q{\\EchildNames=\\Q[\\E(.*)\\Q]}\\E");
21 private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults();
23 private final String id;
24 private final Matcher matcher;
25 private final boolean doesMatch;
27 public AugmentationIdentifierGenerator(String id) {
29 matcher = PATTERN.matcher(this.id);
30 doesMatch = matcher.matches();
33 public boolean matches() {
37 public YangInstanceIdentifier.AugmentationIdentifier getPathArgument() {
38 final String childQNames = matcher.group(1);
40 final Set<QName> childNames = new HashSet<>();
41 for (String name : COMMA_SPLITTER.split(childQNames)) {
42 childNames.add(QNameFactory.create(name));
45 return new YangInstanceIdentifier.AugmentationIdentifier(childNames);