lundi 24 janvier 2022

Reflection: Get values from Scanned Class with Annotation

So Im trying to get the file with the searched annotation, like this:

package com.nikita.Nikitos;

import java.util.Set;

import org.reflections.Reflections;

public class Main {

    public static void main(String[] args) {
        Reflections reflections = new Reflections("com.nikita.Nikitos");
        Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(lombok.Getter.class);
        System.out.println(annotated);

}
}

Im sure that my codes finds the file in which the annotation is located. Because I get following output in my console:

Reflections took 138 ms to scan 1 urls, producing 1 keys and 1 values

So there has to be a value. But my List that Im trying to print out is empty. So how do I get these values?

The file that contains the annotation looks like this:

package com.nikita.Nikitos;

import lombok.Getter;

@Getter
public class App
{
    int zahl;
    public App (int zahl) {
        zahl = this.zahl;
    }


}

Any suggestions?





Aucun commentaire:

Enregistrer un commentaire