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

com.softicar.platform.common.container.comparator.OrderDirection Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.container.comparator;

import com.softicar.platform.common.container.CommonContainerI18n;
import com.softicar.platform.common.core.i18n.IDisplayString;
import com.softicar.platform.common.core.i18n.IDisplayable;

/**
 * Simple enum for the two possible order directions, ascending and descending.
 *
 * @author Oliver Richers
 */
public enum OrderDirection implements IDisplayable {

	ASCENDING(1, CommonContainerI18n.ASCENDING),
	DESCENDING(-1, CommonContainerI18n.DESCENDING);

	private final int sign;
	private final IDisplayString displayString;

	private OrderDirection(int sign, IDisplayString displayString) {

		this.sign = sign;
		this.displayString = displayString;
	}

	@Override
	public IDisplayString toDisplay() {

		return displayString;
	}

	/**
	 * Returns the reverse order direction of this direction.
	 *
	 * @return reverse direction (never null)
	 */
	public OrderDirection getReversed() {

		return this == ASCENDING? DESCENDING : ASCENDING;
	}

	/**
	 * Returns the comparison sign of this direction.
	 * 

* The sign is 1 for {@link #ASCENDING} and -1 for * {@link #DESCENDING} * * @return the comparison sign */ public int getSign() { return sign; } /** * Returns true if this is {@link OrderDirection#ASCENDING}. * * @return true if this is {@link OrderDirection#ASCENDING}; * false otherwise. */ public boolean isAscending() { return this == ASCENDING; } /** * Returns true if this is {@link OrderDirection#DESCENDING}. * * @return true if this is {@link OrderDirection#DESCENDING}; * false otherwise. */ public boolean isDescending() { return this == DESCENDING; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy