Package com.iizix
Class Size
- java.lang.Object
- com.iizix.Size
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class Size extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
A size with integers.- Author:
- Christopher Mindus
- See Also:
- Serialized Form
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Size
clone()
Clones this instance.static int
compareWidthThenHeight(Size s1, Size s2)
Compares to sizes by first the width, then the height.boolean
equals(java.lang.Object o)
Check for equality.int
hashCode()
Hash code.java.lang.String
toString()
Creates the string representation of this position as className[width=NN,height=NN].
Constructor Detail
Size
public Size()
Constructs a size initialized to 0,0.
Size
public Size(int width, int height)
Constructs and initializes position.- Parameters:
width
- The width.height
- The height.
Size
public Size(Size s)
Constructs and initializes position.- Parameters:
s
- Another size.
Method Detail
equals
public boolean equals(java.lang.Object o)
Check for equality.
clone
public Size clone()
Clones this instance.- Overrides:
clone
in classjava.lang.Object
- Returns:
- As cloned instance of Size.
hashCode
public int hashCode()
Hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Returns the hash code.
toString
public java.lang.String toString()
Creates the string representation of this position as className[width=NN,height=NN].- Overrides:
toString
in classjava.lang.Object
compareWidthThenHeight
public static int compareWidthThenHeight(Size s1, Size s2)
Compares to sizes by first the width, then the height.- Parameters:
s1
- Size 1 (null allowed).s2
- Size 2 (null allowed).- Returns:
- 1 if s2 is wider then higher than s1 (or s2 is null), -1 if smaller (or s1 is null), 0 if equal (both null).