Desktop tool for browsing account info from EVE-Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrFilter.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*--
  2. $Id: OrFilter.java,v 1.5 2007/11/10 05:29:00 jhunter Exp $
  3. Copyright (C) 2000-2007 Jason Hunter & Brett McLaughlin.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions, and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions, and the disclaimer that follows
  12. these conditions in the documentation and/or other materials
  13. provided with the distribution.
  14. 3. The name "JDOM" must not be used to endorse or promote products
  15. derived from this software without prior written permission. For
  16. written permission, please contact <request_AT_jdom_DOT_org>.
  17. 4. Products derived from this software may not be called "JDOM", nor
  18. may "JDOM" appear in their name, without prior written permission
  19. from the JDOM Project Management <request_AT_jdom_DOT_org>.
  20. In addition, we request (but do not require) that you include in the
  21. end-user documentation provided with the redistribution and/or in the
  22. software itself an acknowledgement equivalent to the following:
  23. "This product includes software developed by the
  24. JDOM Project (http://www.jdom.org/)."
  25. Alternatively, the acknowledgment may be graphical using the logos
  26. available at http://www.jdom.org/images/logos.
  27. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  28. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
  31. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  34. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  36. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. SUCH DAMAGE.
  39. This software consists of voluntary contributions made by many
  40. individuals on behalf of the JDOM Project and was originally
  41. created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
  42. Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
  43. on the JDOM Project, please see <http://www.jdom.org/>.
  44. */
  45. package org.jdom.filter;
  46. /**
  47. * Allow two filters to be chained together with a logical
  48. * <b>or</b> operation.
  49. *
  50. * @author Bradley S. Huffman
  51. * @version $Revision: 1.5 $, $Date: 2007/11/10 05:29:00 $
  52. */
  53. final class OrFilter extends AbstractFilter {
  54. private static final String CVS_ID =
  55. "@(#) $RCSfile: OrFilter.java,v $ $Revision: 1.5 $ $Date: 2007/11/10 05:29:00 $";
  56. /** Filter for left side of logical <b>or</b> */
  57. private Filter left;
  58. /** Filter for right side of logical <b>or</b> */
  59. private Filter right;
  60. /**
  61. * Match if either of the supplied filters.
  62. *
  63. * @param left left side of logical <b>or</b>
  64. * @param right right side of logical <b>or</b>
  65. * @throws IllegalArgumentException if either supplied filter is null
  66. */
  67. public OrFilter(Filter left, Filter right) {
  68. if ((left == null) || (right == null)) {
  69. throw new IllegalArgumentException("null filter not allowed");
  70. }
  71. this.left = left;
  72. this.right = right;
  73. }
  74. public boolean matches(Object obj) {
  75. return left.matches(obj) || right.matches(obj);
  76. }
  77. public boolean equals(Object obj) {
  78. if (this == obj) {
  79. return true;
  80. }
  81. if (obj instanceof OrFilter) {
  82. OrFilter filter = (OrFilter) obj;
  83. if ((left.equals(filter.left) && right.equals(filter.right)) ||
  84. (left.equals(filter.right) && right.equals(filter.left))) {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. public int hashCode() {
  91. return (31 * left.hashCode()) + right.hashCode();
  92. }
  93. public String toString() {
  94. return new StringBuffer(64)
  95. .append("[OrFilter: ")
  96. .append(left.toString())
  97. .append(",\n")
  98. .append(" ")
  99. .append(right.toString())
  100. .append("]")
  101. .toString();
  102. }
  103. }