1. /*
  2. * @(#)AnnotationProcessorFactory.java 1.9 04/07/13
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.mirror.apt;
  8. import java.util.Collection;
  9. import java.util.Set;
  10. import com.sun.mirror.declaration.AnnotationTypeDeclaration;
  11. /**
  12. * A factory for creating annotation processors.
  13. * Each factory is responsible for creating processors for one or more
  14. * annotation types.
  15. * The factory is said to <i>support</i> these types.
  16. *
  17. * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
  18. * must provide a public no-argument constructor to be used by tools to
  19. * instantiate the factory.
  20. *
  21. * @author Joseph D. Darcy
  22. * @author Scott Seligman
  23. * @version 1.9 04/07/13
  24. * @since 1.5
  25. */
  26. public interface AnnotationProcessorFactory {
  27. /**
  28. * Returns the options recognized by this factory or by any of the
  29. * processors it may create.
  30. * Only {@linkplain AnnotationProcessorEnvironment#getOptions()
  31. * processor-specific} options are included, each of which begins
  32. * with <tt>"-A"</tt>. For example, if this factory recognizes
  33. * options such as <tt>-Adebug -Aloglevel=3</tt>, it will
  34. * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
  35. *
  36. * <p> A tool might use this information to determine if any
  37. * options provided by a user are unrecognized by any processor,
  38. * in which case it may wish to report an error.
  39. *
  40. * @return the options recognized by this factory or by any of the
  41. * processors it may create, or an empty collection if none
  42. */
  43. Collection<String> supportedOptions();
  44. /**
  45. * Returns the names of the annotation types supported by this factory.
  46. * An element of the result may be the canonical (fully qualified) name
  47. * of a supported annotation type. Alternately it may be of the form
  48. * <tt>"<i>name</i>.*"</tt>
  49. * representing the set of all annotation types
  50. * with canonical names beginning with <tt>"<i>name</i>."</tt>
  51. * Finally, <tt>"*"</tt> by itself represents the set of all
  52. * annotation types.
  53. *
  54. * @return the names of the annotation types supported by this factory
  55. */
  56. Collection<String> supportedAnnotationTypes();
  57. /**
  58. * Returns an annotation processor for a set of annotation
  59. * types. The set will be empty if the factory supports
  60. * "<tt>*</tt>" and the specified type declarations have
  61. * no annotations. Note that the set of annotation types may be
  62. * empty for other reasons, such as giving the factory an
  63. * opportunity to register a listener. An
  64. * <tt>AnnotationProcessorFactory</tt> must gracefully handle an
  65. * empty set of annotations; an appropriate response to an empty
  66. * set will often be returning {@link AnnotationProcessors#NO_OP}.
  67. *
  68. * @param atds type declarations of the annotation types to be processed
  69. * @param env environment to use during processing
  70. * @return an annotation processor for the given annotation types,
  71. * or <tt>null</tt> if the types are not supported or the
  72. * processor cannot be created
  73. */
  74. AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
  75. AnnotationProcessorEnvironment env);
  76. }