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

org.opentcs.util.persistence.v002.Comparators Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
/**
 * Copyright (c) The openTCS Authors.
 *
 * This program is free software and subject to the MIT license. (For details,
 * see the licensing information (LICENSE.txt) you should have received with
 * this copy of the software.)
 */
package org.opentcs.util.persistence.v002;

import java.util.Comparator;

/**
 * Some comparator implementations for JAXB classes.
 *
 * @author Martin Grzenia (Fraunhofer IML)
 */
public final class Comparators {

  /**
   * A Comparator for ordering PlantModelElementTOs ascendingly by their
   * names.
   */
  private static final Comparator ELEMENTS_BY_NAME
      = (PlantModelElementTO o1, PlantModelElementTO o2) -> o1.getName().compareTo(o2.getName());
  /**
   * A Comparator for ordering OutgoingPaths ascendingly by their names.
   */
  private static final Comparator OUTGOING_PATHS_BY_NAME
      = (PointTO.OutgoingPath o1, PointTO.OutgoingPath o2) -> o1.getName().compareTo(o2.getName());
  /**
   * A Comparator for ordering Links ascendingly by their point names.
   */
  private static final Comparator LINKS_BY_POINT_NAME
      = (LocationTO.Link o1, LocationTO.Link o2) -> o1.getPoint().compareTo(o2.getPoint());
  /**
   * A Comparator for ordering Hops ascendingly by their names.
   */
  private static final Comparator HOPS_BY_NAME
      = (StaticRouteTO.Hop o1, StaticRouteTO.Hop o2) -> o1.getName().compareTo(o2.getName());
  /**
   * A Comparator for ordering ModelLayoutelementss ascendingly by their
   * names.
   */
  private static final Comparator MODEL_LAYOUT_ELEMENTS_BY_NAME
      = (VisualLayoutTO.ModelLayoutElement o1, VisualLayoutTO.ModelLayoutElement o2)
      -> o1.getVisualizedObjectName().compareTo(o2.getVisualizedObjectName());
  /**
   * A Comparator for ordering Properties ascendingly by their
   * names.
   */
  private static final Comparator PROPERTIES_BY_NAME
      = (PropertyTO o1, PropertyTO o2) -> o1.getName().compareTo(o2.getName());

  private Comparators() {
  }

  /**
   * Returns a comparator for ordering PlantModelElementTOs ascendingly by their names.
   *
   * @return A comparator for ordering PlantModelElementTOs ascendingly by their names.
   */
  public static Comparator elementsByName() {
    return ELEMENTS_BY_NAME;
  }

  /**
   * Returns a comparator for ordering OutgoingPaths ascendingly by their names.
   *
   * @return A comparator for ordering OutgoingPaths ascendingly by their names.
   */
  public static Comparator outgoingPathsByName() {
    return OUTGOING_PATHS_BY_NAME;
  }

  /**
   * Returns a comparator for ordering Links ascendingly by their point names.
   *
   * @return A comparator for ordering Links ascendingly by their point names.
   */
  public static Comparator linksByPointName() {
    return LINKS_BY_POINT_NAME;
  }

  /**
   * Returns a comparator for ordering Hops ascendingly by their names.
   *
   * @return A comparator for ordering Hops ascendingly by their names.
   */
  public static Comparator hopsByName() {
    return HOPS_BY_NAME;
  }

  /**
   * Returns a comparator for ordering ModelLayoutElementss ascendingly by their names.
   *
   * @return A comparator for ordering ModelLayoutElementss ascendingly by their names.
   */
  public static Comparator modelLayoutelementsByName() {
    return MODEL_LAYOUT_ELEMENTS_BY_NAME;
  }

  /**
   * Returns a comparator for ordering Propertiess ascendingly by their names.
   *
   * @return A comparator for ordering Properties ascendingly by their names.
   */
  public static Comparator propertiesByName() {
    return PROPERTIES_BY_NAME;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy