ConditionLogicNot.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2004-2014 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.conditions;
  20. import com.l2jserver.gameserver.model.stats.Env;
  21. /**
  22. * The Class ConditionLogicNot.
  23. * @author mkizub
  24. */
  25. public class ConditionLogicNot extends Condition
  26. {
  27. private final Condition _condition;
  28. /**
  29. * Instantiates a new condition logic not.
  30. * @param condition the condition
  31. */
  32. public ConditionLogicNot(Condition condition)
  33. {
  34. _condition = condition;
  35. if (getListener() != null)
  36. {
  37. _condition.setListener(this);
  38. }
  39. }
  40. /**
  41. * Sets the listener.
  42. * @param listener the new listener
  43. */
  44. @Override
  45. void setListener(ConditionListener listener)
  46. {
  47. if (listener != null)
  48. {
  49. _condition.setListener(this);
  50. }
  51. else
  52. {
  53. _condition.setListener(null);
  54. }
  55. super.setListener(listener);
  56. }
  57. /**
  58. * Test impl.
  59. * @param env the env
  60. * @return true, if successful
  61. */
  62. @Override
  63. public boolean testImpl(Env env)
  64. {
  65. return !_condition.test(env);
  66. }
  67. }