Skip to content

Delete whole branch content#1

Open
ManuelMoeri wants to merge 1 commit into
masterfrom
review
Open

Delete whole branch content#1
ManuelMoeri wants to merge 1 commit into
masterfrom
review

Conversation

@ManuelMoeri

Copy link
Copy Markdown
Owner

Review

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)

public @interface Excercise1 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wieso gehst du hier über einen String?

Suggested change
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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bringt also einmal gar nichts. 😂 Bitte sinnvoll implementieren.


public @interface PersonData {
String[] names() default "none";
int[] ages() default 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default-Werte machen meiner Meinung nach keinen Sinn hier.

try {
constructor = clazz.getConstructor(String.class, int.class);

} catch (NoSuchMethodException e) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variablennamen: Bitte verwende für Arrays die Mehrzahlform.


for (int i = 0; i < 3; i++) {
System.out.println(name[i] + ", " + age[i]);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier solltest du noch neue Objekte der Klasse Person erzeugen.

Repository owner deleted a comment from RandomTannenbaum May 25, 2023
Repository owner deleted a comment from RandomTannenbaum May 25, 2023
Repository owner deleted a comment from RandomTannenbaum May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants