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