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.util;
10 import java.util.Comparator;
11 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
12 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
14 public final class Comparators {
17 * Comparator based on alphabetical order of local name of SchemaNode's qname.
19 public static final SchemaNodeComparator SCHEMA_NODE_COMP = new SchemaNodeComparator();
22 * Comparator based on augment target path length.
24 public static final AugmentComparator AUGMENT_COMP = new AugmentComparator();
26 private Comparators() {
29 private static final class SchemaNodeComparator implements Comparator<SchemaNode> {
31 public int compare(SchemaNode o1, SchemaNode o2) {
32 return o1.getQName().compareTo(o2.getQName());
36 private static final class AugmentComparator implements Comparator<AugmentationSchemaBuilder> {
38 public int compare(AugmentationSchemaBuilder o1, AugmentationSchemaBuilder o2) {
39 return o1.getTargetPath().getPath().size() - o2.getTargetPath().getPath().size();