Package 

Class RouteItemViewModel

    • Constructor Detail

      • RouteItemViewModel

        RouteItemViewModel(Integer directionIconRes, String directionMessage, Float directionDuration)
    • Method Detail

      • 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.