import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.UnknownStatementImpl;
public final class StmtContextUtils {
-
- public static final char LIST_KEY_SEPARATOR = ' ';
- private static final Splitter KEY_SPLITTER = Splitter.on(LIST_KEY_SEPARATOR).omitEmptyStrings().trimResults();
+ public static final Splitter LIST_KEY_SPLITTER = Splitter.on(' ').omitEmptyStrings().trimResults();
private static final Function<StmtContext<?, ?,?>, DeclaredStatement<?>> BUILD_DECLARED =
new Function<StmtContext<?,?,?>, DeclaredStatement<?>>() {
final QNameModule newQNameModule) {
Set<SchemaNodeIdentifier> newKeys = new LinkedHashSet<>();
- for (String keyToken : KEY_SPLITTER.split(keyStmtCtx.rawStatementArgument())) {
+ for (String keyToken : LIST_KEY_SPLITTER.split(keyStmtCtx.rawStatementArgument())) {
final QName keyQName = QName.create(newQNameModule, keyToken);
newKeys.add(SchemaNodeIdentifier.create(false, keyQName));
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import com.google.common.base.Splitter;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
public class KeyStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier>> implements
KeyStatement {
- protected KeyStatementImpl(StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> context) {
+ protected KeyStatementImpl(final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> context) {
super(context);
}
}
@Override
- public Collection<SchemaNodeIdentifier> parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+ public Collection<SchemaNodeIdentifier> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value)
throws SourceException {
- Splitter keySplitter = Splitter.on(StmtContextUtils.LIST_KEY_SEPARATOR).omitEmptyStrings().trimResults();
- List<String> keyTokens = keySplitter.splitToList(value);
+ final List<String> keyTokens = StmtContextUtils.LIST_KEY_SPLITTER.splitToList(value);
// to detect if key contains duplicates
if ((new HashSet<>(keyTokens)).size() < keyTokens.size()) {
throw new IllegalArgumentException();
}
+ // FIXME: would an ImmutableSetBuilder be better?
Set<SchemaNodeIdentifier> keyNodes = new LinkedHashSet<>();
-
for (String keyToken : keyTokens) {
-
- SchemaNodeIdentifier keyNode = SchemaNodeIdentifier
- .create(false, Utils.qNameFromArgument(ctx, keyToken));
- keyNodes.add(keyNode);
+ keyNodes.add(SchemaNodeIdentifier.create(false, Utils.qNameFromArgument(ctx, keyToken)));
}
return keyNodes;
}
@Override
- public KeyStatement createDeclared(StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> ctx) {
+ public KeyStatement createDeclared(final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> ctx) {
return new KeyStatementImpl(ctx);
}
@Override
public EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement> createEffective(
- StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
+ final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
return new KeyEffectiveStatementImpl(ctx);
}
}