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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.data.util.filter;
  17. import com.vaadin.data.provider.DataProvider;
  18. import com.vaadin.data.provider.ListDataProvider;
  19. import com.vaadin.v7.data.Container.Filter;
  20. import com.vaadin.v7.data.Item;
  21. /**
  22. * Negating filter that accepts the items rejected by another filter.
  23. *
  24. * This filter directly supports in-memory filtering when the negated filter
  25. * does so.
  26. *
  27. * @since 6.6
  28. *
  29. * @deprecated As of 8.0, the whole filtering feature is integrated into {@link DataProvider}.
  30. * For in-memory case ({@link ListDataProvider}), use predicates as filters. For back-end DataProviders,
  31. * filters are specific to the implementation.
  32. */
  33. @Deprecated
  34. public final class Not implements Filter {
  35. private final Filter filter;
  36. /**
  37. * Constructs a filter that negates a filter.
  38. *
  39. * @param filter
  40. * {@link Filter} to negate, not-null
  41. */
  42. public Not(Filter filter) {
  43. this.filter = filter;
  44. }
  45. /**
  46. * Returns the negated filter.
  47. *
  48. * @return Filter
  49. */
  50. public Filter getFilter() {
  51. return filter;
  52. }
  53. @Override
  54. public boolean passesFilter(Object itemId, Item item)
  55. throws UnsupportedOperationException {
  56. return !filter.passesFilter(itemId, item);
  57. }
  58. /**
  59. * Returns true if a change in the named property may affect the filtering
  60. * result. Return value is the same as {@link #appliesToProperty(Object)}
  61. * for the negated filter.
  62. *
  63. * @return boolean
  64. */
  65. @Override
  66. public boolean appliesToProperty(Object propertyId) {
  67. return filter.appliesToProperty(propertyId);
  68. }
  69. @Override
  70. public boolean equals(Object obj) {
  71. if (obj == null || !getClass().equals(obj.getClass())) {
  72. return false;
  73. }
  74. return filter.equals(((Not) obj).getFilter());
  75. }
  76. @Override
  77. public int hashCode() {
  78. return filter.hashCode();
  79. }
  80. }