/common/src/main/java/org/switchyard/common/type/classpath/ResourceExistsFilter.java

https://github.com/lincolnthree/switchyard-core · Java · 61 lines · 19 code · 7 blank · 35 comment · 0 complexity · d6757eac10779267c8139eb671ccc2b0 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
  4. * as indicated by the @author tags. All rights reserved.
  5. * See the copyright.txt in the distribution for a
  6. * full listing of individual contributors.
  7. *
  8. * This copyrighted material is made available to anyone wishing to use,
  9. * modify, copy, or redistribute it subject to the terms and conditions
  10. * of the GNU Lesser General Public License, v. 2.1.
  11. * This program is distributed in the hope that it will be useful, but WITHOUT A
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
  14. * You should have received a copy of the GNU Lesser General Public License,
  15. * v.2.1 along with this distribution; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. package org.switchyard.common.type.classpath;
  20. /**
  21. * @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
  22. */
  23. public class ResourceExistsFilter implements Filter {
  24. private String _resourceName;
  25. private boolean _resourceFound = false;
  26. /**
  27. * Public constructor.
  28. * @param resourceName The name of the resource to be checked for.
  29. */
  30. public ResourceExistsFilter(String resourceName) {
  31. this._resourceName = resourceName;
  32. }
  33. /**
  34. * {@inheritDoc}
  35. */
  36. @Override
  37. public void filter(String resourceName) {
  38. _resourceFound = resourceName.equals(_resourceName);
  39. }
  40. /**
  41. * {@inheritDoc}
  42. */
  43. @Override
  44. public boolean continueScanning() {
  45. return !_resourceFound;
  46. }
  47. /**
  48. * Was the resource was found on the scan.
  49. * @return True if the resource was found, otherwise false.
  50. */
  51. public boolean resourceExists() {
  52. return _resourceFound;
  53. }
  54. }