AbstractNode.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.pathfinding;
  16. public abstract class AbstractNode
  17. {
  18. private AbstractNodeLoc _loc;
  19. private AbstractNode _parent;
  20. public AbstractNode(AbstractNodeLoc loc)
  21. {
  22. _loc = loc;
  23. }
  24. public void setParent(AbstractNode p)
  25. {
  26. _parent = p;
  27. }
  28. public AbstractNode getParent()
  29. {
  30. return _parent;
  31. }
  32. public AbstractNodeLoc getLoc()
  33. {
  34. return _loc;
  35. }
  36. public void setLoc(AbstractNodeLoc l)
  37. {
  38. _loc = l;
  39. }
  40. /**
  41. * @see java.lang.Object#hashCode()
  42. */
  43. @Override
  44. public int hashCode()
  45. {
  46. final int prime = 31;
  47. int result = 1;
  48. result = prime * result + ((_loc == null) ? 0 : _loc.hashCode());
  49. return result;
  50. }
  51. /**
  52. * @see java.lang.Object#equals(java.lang.Object)
  53. */
  54. @Override
  55. public boolean equals(Object obj)
  56. {
  57. if (this == obj)
  58. return true;
  59. if (obj == null)
  60. return false;
  61. if (!(obj instanceof AbstractNode))
  62. return false;
  63. final AbstractNode other = (AbstractNode) obj;
  64. if (_loc == null)
  65. {
  66. if (other._loc != null)
  67. return false;
  68. }
  69. else if (!_loc.equals(other._loc))
  70. return false;
  71. return true;
  72. }
  73. }