PsyMultiplicative.java

  1. package coneforest.psylla.core;

  2. import coneforest.psylla.runtime.*;

  3. /**
  4. *   The representation of {@code multiplicative}, a type of object that is an operand of
  5. *   multiplicative operation. This interface declares methods for multiplication, division.
  6. *
  7. *   @param <T> a type of the second operand at binary operation.
  8. */
  9. @Type("multiplicative")
  10. public interface PsyMultiplicative<T extends PsyMultiplicative<T>>
  11.     extends PsyObject
  12. {
  13.     /**
  14.     *   Context action of the {@code div} operator.
  15.     */
  16.     @SuppressWarnings({"unchecked", "rawtypes"})
  17.     @OperatorType("div")
  18.     public static final ContextAction PSY_DIV
  19.         =ContextAction.<PsyMultiplicative, PsyMultiplicative>ofBiFunction(PsyMultiplicative::psyDiv);

  20.     /**
  21.     *   Context action of the {@code mul} operator.
  22.     */
  23.     @SuppressWarnings({"unchecked", "rawtypes"})
  24.     @OperatorType("mul")
  25.     public static final ContextAction PSY_MUL
  26.         =ContextAction.<PsyMultiplicative, PsyMultiplicative>ofBiFunction(PsyMultiplicative::psyMul);

  27.     /**
  28.     *   Context action of the {@code reciprocal} operator.
  29.     */
  30.     @SuppressWarnings("rawtypes")
  31.     @OperatorType("reciprocal")
  32.     public static final ContextAction PSY_RECIPROCAL
  33.         =ContextAction.<PsyMultiplicative>ofFunction(PsyMultiplicative::psyReciprocal);

  34.     /**
  35.     *   {@return the multiplicative inverse of this object}
  36.     *
  37.     *   @throws PsyUndefinedResultException if this object is zero.
  38.     */
  39.     public T psyReciprocal()
  40.         throws PsyUndefinedResultException;

  41.     /**
  42.     *   {@return a result of arithmetic multiplication of this number by given object}
  43.     *
  44.     *   @param oMultiplicative a given number.
  45.     */
  46.     public T psyMul(final T oMultiplicative);

  47.     /**
  48.     *   {@return a result of arithmetic division of this object by given object}
  49.     *
  50.     *   @param oMultiplicative a given object.
  51.     *   @throws PsyUndefinedResultException when the result of division is not defined.
  52.     */
  53.     public T psyDiv(final T oMultiplicative)
  54.         throws PsyUndefinedResultException;
  55. }