L2Object.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model;
  20. import java.util.Map;
  21. import java.util.concurrent.atomic.AtomicInteger;
  22. import javolution.util.FastMap;
  23. import com.l2jserver.gameserver.enums.InstanceType;
  24. import com.l2jserver.gameserver.enums.ShotType;
  25. import com.l2jserver.gameserver.handler.ActionHandler;
  26. import com.l2jserver.gameserver.handler.ActionShiftHandler;
  27. import com.l2jserver.gameserver.handler.IActionHandler;
  28. import com.l2jserver.gameserver.idfactory.IdFactory;
  29. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  30. import com.l2jserver.gameserver.model.actor.L2Character;
  31. import com.l2jserver.gameserver.model.actor.L2Npc;
  32. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  33. import com.l2jserver.gameserver.model.actor.knownlist.ObjectKnownList;
  34. import com.l2jserver.gameserver.model.actor.poly.ObjectPoly;
  35. import com.l2jserver.gameserver.model.entity.Instance;
  36. import com.l2jserver.gameserver.model.interfaces.IDecayable;
  37. import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
  38. import com.l2jserver.gameserver.model.interfaces.ILocational;
  39. import com.l2jserver.gameserver.model.interfaces.INamable;
  40. import com.l2jserver.gameserver.model.interfaces.IPositionable;
  41. import com.l2jserver.gameserver.model.interfaces.ISpawnable;
  42. import com.l2jserver.gameserver.model.interfaces.IUniqueId;
  43. import com.l2jserver.gameserver.model.zone.ZoneId;
  44. import com.l2jserver.gameserver.network.SystemMessageId;
  45. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  46. import com.l2jserver.gameserver.network.serverpackets.ExSendUIEvent;
  47. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  48. /**
  49. * Base class for all interactive objects.
  50. */
  51. public abstract class L2Object implements IIdentifiable, INamable, ISpawnable, IUniqueId, IDecayable, IPositionable
  52. {
  53. private boolean _isVisible;
  54. private ObjectKnownList _knownList;
  55. private String _name;
  56. private int _objectId;
  57. private L2WorldRegion _worldRegion;
  58. private InstanceType _instanceType = null;
  59. private volatile Map<String, Object> _scripts;
  60. private final AtomicInteger _x = new AtomicInteger(0);
  61. private final AtomicInteger _y = new AtomicInteger(0);
  62. private final AtomicInteger _z = new AtomicInteger(0);
  63. private final AtomicInteger _heading = new AtomicInteger(0);
  64. private final AtomicInteger _instanceId = new AtomicInteger(0);
  65. public L2Object(int objectId)
  66. {
  67. setInstanceType(InstanceType.L2Object);
  68. _objectId = objectId;
  69. initKnownList();
  70. }
  71. protected final void setInstanceType(InstanceType instanceType)
  72. {
  73. _instanceType = instanceType;
  74. }
  75. public final InstanceType getInstanceType()
  76. {
  77. return _instanceType;
  78. }
  79. public final boolean isInstanceType(InstanceType instanceType)
  80. {
  81. return _instanceType.isType(instanceType);
  82. }
  83. public final boolean isInstanceTypes(InstanceType... instanceType)
  84. {
  85. return _instanceType.isTypes(instanceType);
  86. }
  87. public final void onAction(L2PcInstance player)
  88. {
  89. onAction(player, true);
  90. }
  91. public void onAction(L2PcInstance player, boolean interact)
  92. {
  93. IActionHandler handler = ActionHandler.getInstance().getHandler(getInstanceType());
  94. if (handler != null)
  95. {
  96. handler.action(player, this, interact);
  97. }
  98. player.sendPacket(ActionFailed.STATIC_PACKET);
  99. }
  100. public void onActionShift(L2PcInstance player)
  101. {
  102. IActionHandler handler = ActionShiftHandler.getInstance().getHandler(getInstanceType());
  103. if (handler != null)
  104. {
  105. handler.action(player, this, true);
  106. }
  107. player.sendPacket(ActionFailed.STATIC_PACKET);
  108. }
  109. public void onForcedAttack(L2PcInstance player)
  110. {
  111. player.sendPacket(ActionFailed.STATIC_PACKET);
  112. }
  113. public void onSpawn()
  114. {
  115. }
  116. /**
  117. * UnAfraid: TODO: Add listener here.
  118. * @param instanceId The id of the instance zone the object is in - id 0 is global
  119. */
  120. @Override
  121. public void setInstanceId(int instanceId)
  122. {
  123. if ((instanceId < 0) || (getInstanceId() == instanceId))
  124. {
  125. return;
  126. }
  127. Instance oldI = InstanceManager.getInstance().getInstance(getInstanceId());
  128. Instance newI = InstanceManager.getInstance().getInstance(instanceId);
  129. if (newI == null)
  130. {
  131. return;
  132. }
  133. if (isPlayer())
  134. {
  135. final L2PcInstance player = getActingPlayer();
  136. if ((getInstanceId() > 0) && (oldI != null))
  137. {
  138. oldI.removePlayer(getObjectId());
  139. if (oldI.isShowTimer())
  140. {
  141. sendInstanceUpdate(oldI, true);
  142. }
  143. }
  144. if (instanceId > 0)
  145. {
  146. newI.addPlayer(getObjectId());
  147. if (newI.isShowTimer())
  148. {
  149. sendInstanceUpdate(newI, false);
  150. }
  151. }
  152. if (player.hasSummon())
  153. {
  154. player.getSummon().setInstanceId(instanceId);
  155. }
  156. }
  157. else if (isNpc())
  158. {
  159. final L2Npc npc = (L2Npc) this;
  160. if ((getInstanceId() > 0) && (oldI != null))
  161. {
  162. oldI.removeNpc(npc);
  163. }
  164. if (instanceId > 0)
  165. {
  166. newI.addNpc(npc);
  167. }
  168. }
  169. _instanceId.set(instanceId);
  170. if (_isVisible && (_knownList != null))
  171. {
  172. // We don't want some ugly looking disappear/appear effects, so don't update
  173. // the knownlist here, but players usually enter instancezones through teleporting
  174. // and the teleport will do the revalidation for us.
  175. if (!isPlayer())
  176. {
  177. decayMe();
  178. spawnMe();
  179. }
  180. }
  181. }
  182. private final void sendInstanceUpdate(Instance instance, boolean hide)
  183. {
  184. final int startTime = (int) ((System.currentTimeMillis() - instance.getInstanceStartTime()) / 1000);
  185. final int endTime = (int) ((instance.getInstanceEndTime() - instance.getInstanceStartTime()) / 1000);
  186. if (instance.isTimerIncrease())
  187. {
  188. sendPacket(new ExSendUIEvent(getActingPlayer(), hide, true, startTime, endTime, instance.getTimerText()));
  189. }
  190. else
  191. {
  192. sendPacket(new ExSendUIEvent(getActingPlayer(), hide, false, endTime - startTime, 0, instance.getTimerText()));
  193. }
  194. }
  195. @Override
  196. public boolean decayMe()
  197. {
  198. assert getWorldRegion() != null;
  199. L2WorldRegion reg = getWorldRegion();
  200. synchronized (this)
  201. {
  202. _isVisible = false;
  203. setWorldRegion(null);
  204. }
  205. // this can synchronize on others instances, so it's out of
  206. // synchronized, to avoid deadlocks
  207. // Remove the L2Object from the world
  208. L2World.getInstance().removeVisibleObject(this, reg);
  209. L2World.getInstance().removeObject(this);
  210. return true;
  211. }
  212. public void refreshID()
  213. {
  214. L2World.getInstance().removeObject(this);
  215. IdFactory.getInstance().releaseId(getObjectId());
  216. _objectId = IdFactory.getInstance().getNextId();
  217. }
  218. @Override
  219. public final boolean spawnMe()
  220. {
  221. assert (getWorldRegion() == null) && (getLocation().getX() != 0) && (getLocation().getY() != 0) && (getLocation().getZ() != 0);
  222. synchronized (this)
  223. {
  224. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  225. _isVisible = true;
  226. setWorldRegion(L2World.getInstance().getRegion(getLocation()));
  227. // Add the L2Object spawn in the _allobjects of L2World
  228. L2World.getInstance().storeObject(this);
  229. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  230. getWorldRegion().addVisibleObject(this);
  231. }
  232. // this can synchronize on others instances, so it's out of synchronized, to avoid deadlocks
  233. // Add the L2Object spawn in the world as a visible object
  234. L2World.getInstance().addVisibleObject(this, getWorldRegion());
  235. onSpawn();
  236. return true;
  237. }
  238. public final void spawnMe(int x, int y, int z)
  239. {
  240. assert getWorldRegion() == null;
  241. synchronized (this)
  242. {
  243. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  244. _isVisible = true;
  245. if (x > L2World.MAP_MAX_X)
  246. {
  247. x = L2World.MAP_MAX_X - 5000;
  248. }
  249. if (x < L2World.MAP_MIN_X)
  250. {
  251. x = L2World.MAP_MIN_X + 5000;
  252. }
  253. if (y > L2World.MAP_MAX_Y)
  254. {
  255. y = L2World.MAP_MAX_Y - 5000;
  256. }
  257. if (y < L2World.MAP_MIN_Y)
  258. {
  259. y = L2World.MAP_MIN_Y + 5000;
  260. }
  261. setXYZ(x, y, z);
  262. setWorldRegion(L2World.getInstance().getRegion(getLocation()));
  263. // Add the L2Object spawn in the _allobjects of L2World
  264. }
  265. L2World.getInstance().storeObject(this);
  266. // these can synchronize on others instances, so they're out of
  267. // synchronized, to avoid deadlocks
  268. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  269. getWorldRegion().addVisibleObject(this);
  270. // Add the L2Object spawn in the world as a visible object
  271. L2World.getInstance().addVisibleObject(this, getWorldRegion());
  272. onSpawn();
  273. }
  274. public boolean isAttackable()
  275. {
  276. return false;
  277. }
  278. public abstract boolean isAutoAttackable(L2Character attacker);
  279. public final boolean isVisible()
  280. {
  281. return getWorldRegion() != null;
  282. }
  283. public final void setIsVisible(boolean value)
  284. {
  285. _isVisible = value;
  286. if (!_isVisible)
  287. {
  288. setWorldRegion(null);
  289. }
  290. }
  291. public void toggleVisible()
  292. {
  293. if (isVisible())
  294. {
  295. decayMe();
  296. }
  297. else
  298. {
  299. spawnMe();
  300. }
  301. }
  302. public ObjectKnownList getKnownList()
  303. {
  304. return _knownList;
  305. }
  306. public void initKnownList()
  307. {
  308. _knownList = new ObjectKnownList(this);
  309. }
  310. public final void setKnownList(ObjectKnownList value)
  311. {
  312. _knownList = value;
  313. }
  314. @Override
  315. public final String getName()
  316. {
  317. return _name;
  318. }
  319. public void setName(String value)
  320. {
  321. _name = value;
  322. }
  323. @Override
  324. public final int getObjectId()
  325. {
  326. return _objectId;
  327. }
  328. public final ObjectPoly getPoly()
  329. {
  330. final ObjectPoly poly = getScript(ObjectPoly.class);
  331. return (poly == null) ? addScript(new ObjectPoly(this)) : poly;
  332. }
  333. public abstract void sendInfo(L2PcInstance activeChar);
  334. public void sendPacket(L2GameServerPacket mov)
  335. {
  336. }
  337. public void sendPacket(SystemMessageId id)
  338. {
  339. }
  340. public L2PcInstance getActingPlayer()
  341. {
  342. return null;
  343. }
  344. /**
  345. * @return {@code true} if object is instance of L2PcInstance
  346. */
  347. public boolean isPlayer()
  348. {
  349. return false;
  350. }
  351. /**
  352. * @return {@code true} if object is instance of L2Playable
  353. */
  354. public boolean isPlayable()
  355. {
  356. return false;
  357. }
  358. /**
  359. * @return {@code true} if object is instance of L2Summon
  360. */
  361. public boolean isSummon()
  362. {
  363. return false;
  364. }
  365. /**
  366. * @return {@code true} if object is instance of L2PetInstance
  367. */
  368. public boolean isPet()
  369. {
  370. return false;
  371. }
  372. /**
  373. * @return {@code true} if object is instance of L2ServitorInstance
  374. */
  375. public boolean isServitor()
  376. {
  377. return false;
  378. }
  379. /**
  380. * @return {@code true} if object is instance of L2Attackable
  381. */
  382. public boolean isCharacter()
  383. {
  384. return false;
  385. }
  386. /**
  387. * @return {@code true} if object is instance of L2DoorInstance
  388. */
  389. public boolean isDoor()
  390. {
  391. return false;
  392. }
  393. /**
  394. * @return {@code true} if object is instance of L2Npc
  395. */
  396. public boolean isNpc()
  397. {
  398. return false;
  399. }
  400. /**
  401. * @return {@code true} if object is instance of L2Attackable
  402. */
  403. public boolean isL2Attackable()
  404. {
  405. return false;
  406. }
  407. /**
  408. * @return {@code true} if object is instance of L2MonsterInstance
  409. */
  410. public boolean isMonster()
  411. {
  412. return false;
  413. }
  414. /**
  415. * @return {@code true} if object is instance of L2TrapInstance
  416. */
  417. public boolean isTrap()
  418. {
  419. return false;
  420. }
  421. /**
  422. * @return {@code true} if object is instance of L2ItemInstance
  423. */
  424. public boolean isItem()
  425. {
  426. return false;
  427. }
  428. /**
  429. * @return {@code true} if object Npc Walker or Vehicle
  430. */
  431. public boolean isWalker()
  432. {
  433. return false;
  434. }
  435. /**
  436. * @return {@code true} if object Can be targeted
  437. */
  438. public boolean isTargetable()
  439. {
  440. return true;
  441. }
  442. /**
  443. * Check if the object is in the given zone Id.
  444. * @param zone the zone Id to check
  445. * @return {@code true} if the object is in that zone Id
  446. */
  447. public boolean isInsideZone(ZoneId zone)
  448. {
  449. return false;
  450. }
  451. /**
  452. * Check if current object has charged shot.
  453. * @param type of the shot to be checked.
  454. * @return {@code true} if the object has charged shot
  455. */
  456. public boolean isChargedShot(ShotType type)
  457. {
  458. return false;
  459. }
  460. /**
  461. * Charging shot into the current object.
  462. * @param type of the shot to be charged.
  463. * @param charged
  464. */
  465. public void setChargedShot(ShotType type, boolean charged)
  466. {
  467. }
  468. /**
  469. * Try to recharge a shot.
  470. * @param physical skill are using Soul shots.
  471. * @param magical skill are using Spirit shots.
  472. */
  473. public void rechargeShots(boolean physical, boolean magical)
  474. {
  475. }
  476. /**
  477. * @param <T>
  478. * @param script
  479. * @return
  480. */
  481. public final <T> T addScript(T script)
  482. {
  483. if (_scripts == null)
  484. {
  485. // Double-checked locking
  486. synchronized (this)
  487. {
  488. if (_scripts == null)
  489. {
  490. _scripts = new FastMap<String, Object>().shared();
  491. }
  492. }
  493. }
  494. _scripts.put(script.getClass().getName(), script);
  495. return script;
  496. }
  497. /**
  498. * @param <T>
  499. * @param script
  500. * @return
  501. */
  502. @SuppressWarnings("unchecked")
  503. public final <T> T removeScript(Class<T> script)
  504. {
  505. if (_scripts == null)
  506. {
  507. return null;
  508. }
  509. return (T) _scripts.remove(script.getName());
  510. }
  511. /**
  512. * @param <T>
  513. * @param script
  514. * @return
  515. */
  516. @SuppressWarnings("unchecked")
  517. public final <T> T getScript(Class<T> script)
  518. {
  519. if (_scripts == null)
  520. {
  521. return null;
  522. }
  523. return (T) _scripts.get(script.getName());
  524. }
  525. public void removeStatusListener(L2Character object)
  526. {
  527. }
  528. @Override
  529. public final void setXYZ(int x, int y, int z)
  530. {
  531. assert getWorldRegion() != null;
  532. setX(x);
  533. setY(y);
  534. setZ(z);
  535. try
  536. {
  537. if (L2World.getInstance().getRegion(getLocation()) != getWorldRegion())
  538. {
  539. updateWorldRegion();
  540. }
  541. }
  542. catch (Exception e)
  543. {
  544. badCoords();
  545. }
  546. }
  547. protected void badCoords()
  548. {
  549. if (isCharacter())
  550. {
  551. decayMe();
  552. }
  553. else if (isPlayer())
  554. {
  555. ((L2Character) this).teleToLocation(new Location(0, 0, 0), false);
  556. ((L2Character) this).sendMessage("Error with your coords, Please ask a GM for help!");
  557. }
  558. }
  559. public final void setXYZInvisible(int x, int y, int z)
  560. {
  561. assert getWorldRegion() == null;
  562. if (x > L2World.MAP_MAX_X)
  563. {
  564. x = L2World.MAP_MAX_X - 5000;
  565. }
  566. if (x < L2World.MAP_MIN_X)
  567. {
  568. x = L2World.MAP_MIN_X + 5000;
  569. }
  570. if (y > L2World.MAP_MAX_Y)
  571. {
  572. y = L2World.MAP_MAX_Y - 5000;
  573. }
  574. if (y < L2World.MAP_MIN_Y)
  575. {
  576. y = L2World.MAP_MIN_Y + 5000;
  577. }
  578. setXYZ(x, y, z);
  579. setIsVisible(false);
  580. }
  581. public final void setLocationInvisible(ILocational loc)
  582. {
  583. setXYZInvisible(loc.getX(), loc.getY(), loc.getZ());
  584. }
  585. public void updateWorldRegion()
  586. {
  587. if (!isVisible())
  588. {
  589. return;
  590. }
  591. L2WorldRegion newRegion = L2World.getInstance().getRegion(getLocation());
  592. if (newRegion != getWorldRegion())
  593. {
  594. getWorldRegion().removeVisibleObject(this);
  595. setWorldRegion(newRegion);
  596. // Add the L2Oject spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  597. getWorldRegion().addVisibleObject(this);
  598. }
  599. }
  600. public final L2WorldRegion getWorldRegion()
  601. {
  602. return _worldRegion;
  603. }
  604. public void setWorldRegion(L2WorldRegion value)
  605. {
  606. if ((getWorldRegion() != null) && isCharacter()) // confirm revalidation of old region's zones
  607. {
  608. if (value != null)
  609. {
  610. getWorldRegion().revalidateZones((L2Character) this); // at world region change
  611. }
  612. else
  613. {
  614. getWorldRegion().removeFromZones((L2Character) this); // at world region change
  615. }
  616. }
  617. _worldRegion = value;
  618. }
  619. /**
  620. * Calculates distance between this L2Object and given x, y , z.
  621. * @param x - X coordinate.
  622. * @param y - Y coordinate.
  623. * @param z - Z coordinate.
  624. * @param includeZAxis - If set to true, Z coordinate will be included.
  625. * @param squared - If set to true, distance returned will be squared.
  626. * @return {@code double} - Distance between object and given x, y , z.
  627. */
  628. public double calculateDistance(int x, int y, int z, boolean includeZAxis, boolean squared)
  629. {
  630. final double distance = Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + (includeZAxis ? Math.pow(z - getZ(), 2) : 0);
  631. return (squared) ? distance : Math.sqrt(distance);
  632. }
  633. /**
  634. * Calculates distance between this L2Object and given location.
  635. * @param loc - Location on map.
  636. * @param includeZAxis - If set to true, Z coordinate will be included.
  637. * @param squared - If set to true, distance returned will be squared.
  638. * @return {@code double} - Distance between object and given location.
  639. */
  640. public double calculateDistance(ILocational loc, boolean includeZAxis, boolean squared)
  641. {
  642. return calculateDistance(loc.getX(), loc.getY(), loc.getZ(), includeZAxis, squared);
  643. }
  644. @Override
  645. public int getX()
  646. {
  647. return _x.get();
  648. }
  649. @Override
  650. public int getY()
  651. {
  652. return _y.get();
  653. }
  654. @Override
  655. public int getZ()
  656. {
  657. return _z.get();
  658. }
  659. @Override
  660. public int getHeading()
  661. {
  662. return _heading.get();
  663. }
  664. @Override
  665. public int getInstanceId()
  666. {
  667. return _instanceId.get();
  668. }
  669. @Override
  670. public Location getLocation()
  671. {
  672. return new Location(getX(), getY(), getZ(), getHeading(), getInstanceId());
  673. }
  674. @Override
  675. public void setX(int x)
  676. {
  677. _x.set(x);
  678. }
  679. @Override
  680. public void setY(int y)
  681. {
  682. _y.set(y);
  683. }
  684. @Override
  685. public void setZ(int z)
  686. {
  687. _z.set(z);
  688. }
  689. @Override
  690. public void setXYZ(ILocational loc)
  691. {
  692. setXYZ(loc.getX(), loc.getY(), loc.getZ());
  693. }
  694. @Override
  695. public void setHeading(int heading)
  696. {
  697. _heading.set(heading);
  698. }
  699. @Override
  700. public void setLocation(Location loc)
  701. {
  702. _x.set(loc.getX());
  703. _y.set(loc.getY());
  704. _z.set(loc.getZ());
  705. _heading.set(loc.getHeading());
  706. _instanceId.set(loc.getInstanceId());
  707. }
  708. @Override
  709. public boolean equals(Object obj)
  710. {
  711. return ((obj instanceof L2Object) && (((L2Object) obj).getObjectId() == getObjectId()));
  712. }
  713. @Override
  714. public String toString()
  715. {
  716. return (getClass().getSimpleName() + ":" + getName() + "[" + getObjectId() + "]");
  717. }
  718. }