All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geotoolkit.referencing.NameComparator Maven / Gradle / Ivy

/*
 *    Geotoolkit.org - An Open Source Java GIS Toolkit
 *    http://www.geotoolkit.org
 *
 *    (C) 2001-2012, Open Source Geospatial Foundation (OSGeo)
 *    (C) 2009-2012, Geomatys
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    This package contains documentation from OpenGIS specifications.
 *    OpenGIS consortium's work is fully acknowledged here.
 */
package org.geotoolkit.referencing;

import java.util.Comparator;
import java.io.Serializable;
import java.io.ObjectStreamException;

import org.opengis.referencing.IdentifiedObject;


/**
 * {@link IdentifiedObjects#NAME_COMPARATOR} implementation as a named class (rather than anonymous)
 * for more predictable serialization.
 *
 * @author Martin Desruisseaux (IRD, Geomatys)
 * @version 3.20
 *
 * @since 3.20 (derived from 1.2)
 * @module
 */
final class NameComparator implements Comparator, Serializable {
    /** For cross-version compatibility. */
    private static final long serialVersionUID = -6605097017814062198L;

    /** Compares the given identified objects for order. */
    @Override public int compare(final IdentifiedObject o1, final IdentifiedObject o2) {
        return IdentifiedObjects.doCompare(o1.getName().getCode(), o2.getName().getCode());
    }

    /** Canonicalizes to the singleton on deserialization. */
    protected Object readResolve() throws ObjectStreamException {
        return IdentifiedObjects.NAME_COMPARATOR;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy