-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javadoc for gestalt-inject-java #158
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a first-pass review. I have not looked over everything yet and will carry-on another time. It should be enough to start with.
@@ -12,22 +12,38 @@ | |||
import java.util.HashSet; | |||
import java.util.Map; | |||
|
|||
/** | |||
* Class to write annotation types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AnnotationTypeWriter
class is responsible for writing to files under META-INF/annotations
listing which classes are annotated with a particular annotation. For example, types annotated with @IndexInherited
would be listed in META-INF/annotations/org.terasology.context.annotation.IndexInherited
.
public class AnnotationTypeWriter { | ||
private static final String META_INF = "META-INF/annotations"; | ||
|
||
private final Filer filer; | ||
private final Map<String, HashSet<String>> results = new HashMap<>(); | ||
private final Map<String, FileObject> files = new HashMap<>(); | ||
|
||
/** | ||
* Creates a AnnotationTypeWriter to write an annotation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Creates a AnnotationTypeWriter to write an annotation. | |
* Creates an AnnotationTypeWriter. |
Short and not very useful but this constructor doesn't do much anyway. This is probably enough.
* Writes an annotation to a service. | ||
* @param service the service to write. | ||
* @param target the target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not actually do any writing to files yet, so I will admit that the name is misleading. What it does is register that a given class should be associated as being annotated by a given annotation (aka. service).
In this instance, a service refers to a particular annotation type. So, the service parameter would be the fully-qualified type name of the annotation.
The target is the target class that was annotated with that annotation.
public void writeAnnotation(String service, String target) { | ||
results.putIfAbsent(service, new HashSet<>()); | ||
results.get(service).add(target); | ||
} | ||
|
||
/** | ||
* Writes class to file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Writes class to file. | |
* Writes out annotation-class mappings to files. |
@@ -66,13 +69,23 @@ public class BeanDefinitionProcessor extends AbstractProcessor { | |||
}; | |||
private final Set<String> processed = new HashSet<>(); | |||
private final Set<String> beanDefinitions = new HashSet<>(); | |||
/** | |||
* the elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elements
refers to javax.lang.model.util.Elements
. It is a set of utilities for manipulating Java syntax elements, not a collection of elements, as the name might misleadingly suggest.
@@ -86,11 +99,19 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) { | |||
this.utility = new ElementUtility(processingEnvironment.getElementUtils(), processingEnvironment.getTypeUtils()); | |||
} | |||
|
|||
/** | |||
* {@return the supported annotation types.} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* {@return the supported annotation types.} | |
* {@inheritDoc} |
This is an override from an already well-documented base method, so we might as well inherit that.
* {@return true if bean definitions could be processes, fals otherwise.} | ||
* @param annotations the annotations. | ||
* @param environment the environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* {@return true if bean definitions could be processes, fals otherwise.} | |
* @param annotations the annotations. | |
* @param environment the environment. | |
* {@inheritDoc} |
This is an override from an already well-documented base method, so we might as well inherit that.
@@ -20,6 +20,9 @@ | |||
import java.util.regex.Pattern; | |||
import java.util.stream.Collectors; | |||
|
|||
/** | |||
* Annotation processor to create resources for types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Annotation processor to create resources for types. | |
* Annotation processor to list resources for types. |
This processor does not create the resources, it just lists the resources that are there. We need to do this because listing resources packed in an APK on Android is prohibitively expensive.
@@ -11,23 +11,41 @@ | |||
import javax.lang.model.util.Types; | |||
import java.util.List; | |||
|
|||
/** | |||
* BenjaminAmos, pls proper description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* BenjaminAmos, pls proper description. | |
* Utilities for discovering and distinguishing element types. |
This is a utility class: convenient but just a mixture of related useful routines. Most projects have one somewhere, even if it's not considered the best programming practice sometimes.
@@ -24,6 +24,9 @@ | |||
import java.util.Queue; | |||
import java.util.Set; | |||
|
|||
/** | |||
* BenjaminAmos pls description which makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* BenjaminAmos pls description which makes sense. | |
* Records all types annotated with `@Index` or `@IndexInherited`, as well as all descendants of a type annotated with `@IndexInherited`. |
No description provided.