-
- All Implemented Interfaces:
public final class RouteItemViewModel
ViewModel represents the information to be displayed in RouteHeaderView
-
-
Field Summary
Fields Modifier and Type Field Description private final Integer
directionIconRes
private final String
directionMessage
private final Float
directionDuration
-
Constructor Summary
Constructors Constructor Description RouteItemViewModel(Integer directionIconRes, String directionMessage, Float directionDuration)
-
Method Summary
Modifier and Type Method Description final Integer
getDirectionIconRes()
final String
getDirectionMessage()
final Float
getDirectionDuration()
String
toString()
Boolean
equals(Object other)
Integer
hashCode()
In the custom hashcode implementation, we should only check the equality of the directionIconRes, directionMessage and isDestination . -
-
Method Detail
-
getDirectionIconRes
final Integer getDirectionIconRes()
-
getDirectionMessage
final String getDirectionMessage()
-
getDirectionDuration
final Float getDirectionDuration()
-
hashCode
Integer hashCode()
In the custom hashcode implementation, we should only check the equality of the directionIconRes, directionMessage and isDestination . Because we have a custom comparison for the duration related parameters of these items, which should only be considered different depending on the result of areDurationsSignificantlyDifferent method. So, we consider two RouteItemViewModel items to be same in terms of hashcode if we have the other fields same, to later check the equals method to determine if they are actually the same. If the hashcode comparison fails, there is no reason to check the equals method.
Check doc here;
If an object’s hashcode is not the same as another object’s hashcode, there is no reason to execute the equals() method: you just know the two objects are not the same. On the other hand, if the hashcode is the same, then you must execute the equals() method to determine whether the values and fields are the same.
-
-
-
-