Package javascalautils
Class Unit
- java.lang.Object
-
- javascalautils.Unit
-
- All Implemented Interfaces:
java.io.Serializable
public final class Unit extends java.lang.Object implements java.io.Serializable
Represents the type scala.Unit.
The usage of Unit is for situations where one returns types such asTry
orFuture
that are not meant to hold a value.
E.g.Try<Unit> deleteSynchronous(String id) Future<Unit> deleteAsynchronous(String id)
This becomes very apparent with the asynchronous method. In that case we only care if the operation is finished and successful.
One can of course return dummy objects/values but providing Unit is more concise as it clearly marks a non-value.
Instead of creating new instances it is recommended to use thesingleton
instance.- Since:
- 1.6
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Unit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Simply compares the provided object to see if it is an instance ofUnit
.int
hashCode()
Always returns69
.java.lang.String
toString()
Always returns the stringUnit
-
-
-
Field Detail
-
Instance
public static final Unit Instance
Static singleton representing the Unit.- Since:
- 1.7
-
-
Method Detail
-
hashCode
public int hashCode()
Always returns69
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Always
69
- Since:
- 1.7
-
equals
public boolean equals(java.lang.Object obj)
Simply compares the provided object to see if it is an instance ofUnit
.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to compare to- Since:
- 1.7
-
toString
public java.lang.String toString()
Always returns the stringUnit
- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string
Unit
- Since:
- 1.7
-
-