001/** 002 * @author Francesco.Kriegel@gmx.de 003 */ 004package conexp.fx.core.math; 005 006/* 007 * #%L 008 * Concept Explorer FX 009 * %% 010 * Copyright (C) 2010 - 2023 Francesco Kriegel 011 * %% 012 * This program is free software: you can redistribute it and/or modify 013 * it under the terms of the GNU General Public License as 014 * published by the Free Software Foundation, either version 3 of the 015 * License, or (at your option) any later version. 016 * 017 * This program is distributed in the hope that it will be useful, 018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 020 * GNU General Public License for more details. 021 * 022 * You should have received a copy of the GNU General Public 023 * License along with this program. If not, see 024 * <http://www.gnu.org/licenses/gpl-3.0.html>. 025 * #L% 026 */ 027 028public interface PartialComparable<E> extends Comparable<E> { 029 030 public default boolean equivalent(E e) { 031 return compareTo(e) == 0; 032 } 033 034 public default boolean smaller(E e) { 035 return compareTo(e) == -1; 036 } 037 038 public default boolean greater(E e) { 039 return compareTo(e) == 1; 040 } 041 042 public default boolean smallerEq(E e) { 043 final int c = compareTo(e); 044 return c == -1 || c == 0; 045 } 046 047 public default boolean greaterEq(E e) { 048 final int c = compareTo(e); 049 return c == 0 || c == 1; 050 } 051 052 public default boolean uncomparable(E e) { 053 final int c = compareTo(e); 054 return c < 1 || c > 1; 055 } 056}