Class Size2D

  • All Implemented Interfaces:
    java.io.Serializable

    public class Size2D
    extends java.lang.Object
    implements java.io.Serializable
    The class Size2D represents a 2d rectangular area. Sizes always are positive. This class doesn't allow zero or negative sizes.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Size2D ONE
      One size object.
    • Constructor Summary

      Constructors 
      Constructor Description
      Size2D​(int width, int height)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(@Nullable java.lang.Object obj)  
      int getHeight()
      Returns the height of the area.
      int getWidth()
      Returns the width of the area.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ONE

        public static final Size2D ONE
        One size object.
    • Constructor Detail

      • Size2D

        public Size2D​(int width,
                      int height)
        Creates a new instance.
        Parameters:
        width - the width of the area; must be greater than zero
        height - the height of the area; must be greater than zero
        Throws:
        java.lang.IllegalArgumentException - in case width or height is less than 1.
    • Method Detail

      • equals

        public boolean equals​(@Nullable
                              @Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getWidth

        public int getWidth()
        Returns the width of the area. It is always greater than zero.
        Returns:
        the width of the area
      • getHeight

        public int getHeight()
        Returns the height of the area. It is always greater than zero.
        Returns:
        the height of the area
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object