001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.osm;
003
004import java.util.Comparator;
005
006/**
007 * Comparators for comparing {@link OsmPrimitive}.
008 * @since 4113
009 */
010public final class OsmPrimitiveComparator {
011
012    /**
013     * Returns a comparator comparing primitives by their name using {@link DefaultNameFormatter}.
014     *
015     * {@linkplain DefaultNameFormatter#format(IPrimitive) Formatted names} are cached.
016     *
017     * @return a comparator comparing primitives by their name using {@link DefaultNameFormatter}
018     */
019    public static Comparator<OsmPrimitive> comparingNames() {
020        return PrimitiveComparator.doComparingNames();
021    }
022
023    /**
024     * Returns a comparator comparing primitives by their {@linkplain OsmPrimitive#getUniqueId unique id}.
025     *
026     * @return a comparator comparing primitives by their {@linkplain OsmPrimitive#getUniqueId unique id}.
027     */
028    public static Comparator<OsmPrimitive> comparingUniqueId() {
029        return PrimitiveComparator.doComparingUniqueId();
030    }
031
032    /**
033     * Returns a comparator ordering the primitives by type in the order NODE, WAY, RELATION
034     *
035     * @return a comparator ordering the primitives by type in the order NODE, WAY, RELATION
036     */
037    public static Comparator<OsmPrimitive> orderingNodesWaysRelations() {
038        return PrimitiveComparator.doOrderingNodesWaysRelations();
039    }
040
041    /**
042     * Returns a comparator ordering the primitives by type in the order WAY, RELATION, NODE
043     *
044     * @return a comparator ordering the primitives by type in the order WAY, RELATION, NODE
045     */
046    public static Comparator<OsmPrimitive> orderingWaysRelationsNodes() {
047        return PrimitiveComparator.doOrderingWaysRelationsNodes();
048    }
049
050    /**
051     * Returns a comparator ordering the primitives by type in the order RELATION, WAY, NODE
052     *
053     * @return a comparator ordering the primitives by type in the order RELATION, WAY, NODE
054     * @since 11679
055     */
056    public static Comparator<OsmPrimitive> orderingRelationsWaysNodes() {
057        return PrimitiveComparator.doOrderingRelationsWaysNodes();
058    }
059
060    private OsmPrimitiveComparator() {
061    }
062}