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

com.softicar.platform.common.math.arithmetic.IArithmetic 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.math.arithmetic;

import java.util.Comparator;
import java.util.Objects;

/**
 * Defines basic arithmetic properties for a specific type.
 *
 * @author Oliver Richers
 */
public interface IArithmetic extends Comparator {

	T getZero();

	T getOne();

	T plus(T left, T right);

	T minus(T left, T right);

	T times(T left, T right);

	T divided(T left, T right);

	T negate(T value);

	default boolean isZero(T value) {

		return Objects.equals(getZero(), value);
	}

	default boolean isNotZero(T value) {

		return !Objects.equals(getZero(), value);
	}

	default boolean isEqual(T left, T right) {

		return Objects.equals(left, right);
	}

	default boolean isNotEqual(T left, T right) {

		return !Objects.equals(left, right);
	}

	default boolean isLess(T left, T right) {

		return compare(left, right) < 0;
	}

	default boolean isGreater(T left, T right) {

		return compare(left, right) > 0;
	}

	default boolean isLessEqual(T left, T right) {

		return compare(left, right) <= 0;
	}

	default boolean isGreaterEqual(T left, T right) {

		return compare(left, right) >= 0;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy