Delete whole branch content#1
Conversation
| @Retention(RetentionPolicy.SOURCE) | ||
| @Target(ElementType.TYPE) | ||
|
|
||
| public @interface Excercise1 { |
There was a problem hiding this comment.
Aufgabe richtig gelöst. Würde der Annotation einfach noch einen sinnvolleren Namen geben.
|
|
||
| import java.util.Scanner; | ||
|
|
||
| @Excercise1(authors = "Manuel", description = "No idea", version = "1.0.2") |
There was a problem hiding this comment.
Korrekt implementiert.
Wenn deine Annotation Docoumentation oder so ähnlich heisst, dann hättest du hier noch eine sinnvolle Beschreibung zur Aufgabe hinschreiben können.
| Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotation); | ||
| for (Element element : annotatedElements) { | ||
| Excercise1 annotation1 = element.getAnnotation(Excercise1.class); | ||
| Class<?> clazz = Class.forName("Java.grundlagen.j6.annotations.Excercise2"); |
There was a problem hiding this comment.
Wieso gehst du hier über einen String?
| Class<?> clazz = Class.forName("Java.grundlagen.j6.annotations.Excercise2"); | |
| Class<?> clazz = Excercise2.class; |
Ausserdem brauchst du diese Variable gar nicht wirklich, oder? Bitte die Referenz entfernen, damit die Model-Klasse nicht dazu kompiliert werden muss. Du willst ja via AnnotationsProzessor irgendeine Java-Klasse angeben können, die noch nicht kompiliiert ist.
|
|
||
| @Override | ||
| public String toString() { | ||
| return super.toString(); |
There was a problem hiding this comment.
Bringt also einmal gar nichts. 😂 Bitte sinnvoll implementieren.
|
|
||
| public @interface PersonData { | ||
| String[] names() default "none"; | ||
| int[] ages() default 0; |
There was a problem hiding this comment.
Default-Werte machen meiner Meinung nach keinen Sinn hier.
| try { | ||
| constructor = clazz.getConstructor(String.class, int.class); | ||
|
|
||
| } catch (NoSuchMethodException e) { |
There was a problem hiding this comment.
Error-Handling macht für micht keinen Sinn. Bitte wirf nie einfach so eine RuntimeException!
| } | ||
| PersonData annotation = constructor.getAnnotation(PersonData.class); | ||
| String[] name = annotation.names(); | ||
| int[] age = annotation.ages(); |
There was a problem hiding this comment.
Variablennamen: Bitte verwende für Arrays die Mehrzahlform.
|
|
||
| for (int i = 0; i < 3; i++) { | ||
| System.out.println(name[i] + ", " + age[i]); | ||
| } |
There was a problem hiding this comment.
Hier solltest du noch neue Objekte der Klasse Person erzeugen.
Review