2 * Copyright (c) 2013 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.yangtools.yang.parser.builder.util;
10 import java.util.Comparator;
12 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
13 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
15 public final class Comparators {
18 * Comparator based on alphabetical order of local name of SchemaNode's qname.
20 public static final SchemaNodeComparator SCHEMA_NODE_COMP = new SchemaNodeComparator();
23 * Comparator based on augment target path length.
26 public static final AugmentComparator AUGMENT_COMP = new AugmentComparator();
28 private Comparators() {
31 private static final class SchemaNodeComparator implements Comparator<SchemaNode> {
33 public int compare(final SchemaNode o1, final SchemaNode o2) {
34 return o1.getQName().compareTo(o2.getQName());
38 private static final class AugmentComparator implements Comparator<AugmentationSchemaBuilder> {
40 public int compare(final AugmentationSchemaBuilder o1, final AugmentationSchemaBuilder o2) {
41 return o1.getTargetPath().getPath().size() - o2.getTargetPath().getPath().size();