2 * Copyright (c) 2016 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
8 package org.opendaylight.restconf.common.util;
10 import java.util.Collection;
11 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
12 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
13 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
14 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
18 * Util class for finding {@link DataSchemaNode}.
21 public final class RestconfSchemaUtil {
23 private RestconfSchemaUtil() {
24 throw new UnsupportedOperationException("Util class");
28 * Find child of {@link SchemaNode} in {@link Collection} by {@link String}
35 * @param schemaNodeName
37 * @return {@link SchemaNode}
39 public static <T extends SchemaNode> T findSchemaNodeInCollection(final Collection<T> collection,
40 final String schemaNodeName) {
41 for (final T child : collection) {
42 if (child.getQName().getLocalName().equals(schemaNodeName)) {
46 throw new RestconfDocumentedException("Schema node " + schemaNodeName + " does not exist in module.",
47 ErrorType.PROTOCOL, ErrorTag.DATA_MISSING);