1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of 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,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.collections.functors;
  17. import java.io.Serializable;
  18. import org.apache.commons.collections.FunctorException;
  19. import org.apache.commons.collections.Predicate;
  20. /**
  21. * Predicate implementation that always throws an exception.
  22. *
  23. * @since Commons Collections 3.0
  24. * @version $Revision: 1.7 $ $Date: 2004/05/16 11:16:01 $
  25. *
  26. * @author Stephen Colebourne
  27. */
  28. public final class ExceptionPredicate implements Predicate, Serializable {
  29. /** Serial version UID */
  30. static final long serialVersionUID = 7179106032121985545L;
  31. /** Singleton predicate instance */
  32. public static final Predicate INSTANCE = new ExceptionPredicate();
  33. /**
  34. * Factory returning the singleton instance.
  35. *
  36. * @return the singleton instance
  37. * @since Commons Collections 3.1
  38. */
  39. public static Predicate getInstance() {
  40. return INSTANCE;
  41. }
  42. /**
  43. * Restricted constructor.
  44. */
  45. private ExceptionPredicate() {
  46. super();
  47. }
  48. /**
  49. * Evaluates the predicate always throwing an exception.
  50. *
  51. * @param object the input object
  52. * @return never
  53. * @throws FunctorException always
  54. */
  55. public boolean evaluate(Object object) {
  56. throw new FunctorException("ExceptionPredicate invoked");
  57. }
  58. }