Comparing objects that implement WSObject

On what criteria are objects in WorldServer that implement the WSObject interface compared for equality? Is it safe to assume that calling the inherited java.lang.Object equals method to compare one WSObject to another will always return true if the IDs (the value returned by calling getId) and implementing types are the same?

Thanks

Parents
  • Hi Joseph, 

    Interesting, because I was always comparing by IDs just for safety. So I checked this actual behavior.

    In the WSObjectImp class, there is the equals() method overriding the base. And in that method, it is comparing some conditions, and finally comparing the IDs. 

    Therefore, as long as you are comparing the objects based on the WSObject class, you can use the equals() method, I think. 

    If you are interested in this behavior, you can check the WSObjectImp class by yourself in your IDE. 

    Best,
    Taiki

  • Thanks for looking into this, Taiki. I have also been comparing objects by ID just to be safe. Like you said it looks like the WSObjectImp class compares IDs, so if that method implementation is used in the comparison, it should be safe to use. However, I think I might continue to do ID and type comparisons myself instead of relying on SDL's internal implementation.

    -Joseph

Reply
  • Thanks for looking into this, Taiki. I have also been comparing objects by ID just to be safe. Like you said it looks like the WSObjectImp class compares IDs, so if that method implementation is used in the comparison, it should be safe to use. However, I think I might continue to do ID and type comparisons myself instead of relying on SDL's internal implementation.

    -Joseph

Children
No Data