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

org.nakedobjects.applib.value.Magnitude Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
package org.nakedobjects.applib.value;

import java.io.Serializable;


public abstract class Magnitude implements Serializable {
    private static final long serialVersionUID = 1L;

    public boolean isBetween(final Magnitude minMagnitude, final Magnitude maxMagnitude) {
        return isGreaterThanOrEqualTo(minMagnitude) && isLessThanOrEqualTo(maxMagnitude);
    }

    public abstract boolean isEqualTo(final Magnitude magnitude);

    public boolean isGreaterThan(final Magnitude magnitude) {
        return magnitude.isLessThan(this);
    }

    public boolean isGreaterThanOrEqualTo(final Magnitude magnitude) {
        return !isLessThan(magnitude);
    }

    public abstract boolean isLessThan(final Magnitude magnitude);

    public boolean isLessThanOrEqualTo(final Magnitude magnitude) {
        return !isGreaterThan(magnitude);
    }

    public Magnitude max(final Magnitude magnitude) {
        return isGreaterThan(magnitude) ? this : magnitude;
    }

    public Magnitude min(final Magnitude magnitude) {
        return isLessThan(magnitude) ? this : magnitude;
    }

}
// Copyright (c) Naked Objects Group Ltd.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy