I have a bunch of sensors, which should be inherited from a superclass.

In my superclass, as well as in the sensor itself, there are static final attributes and possible value ranges of my attributes, which defines my sensor.

Now I want to source out a method, which returns a `HashMap` of attributes and its values ranges in the superclass.

Because of the fact, that the sensor never changes its parameters, I want to use this getAttributes() method as a class method for optional calling it in my main[].

My problem is: How can I get the attributes in a static way (I used reflections at the moment) So well.

A UML diagram of what I said:  

![Here](https://i.stack.imgur.com/WVsMem.jpg)

my main method looks like:

```
public static void main(String[] args){
    HashMap<String, List<String>> a = SensorA.getConfigurationAttributes();
}

```

and my abstract component class:

```
public static HashMap<String, List<String>> getConfigurationAttributes(boolean getMandatoryOnly){
    Field[] classAttributes = this.getClass().getDeclaredFields();  // error: cannot use this in static context
    // ... other code, working with the attributes.
}   

```

Of course, now, Java says: "cannot use this in a static context." But how can I correct this error?

On the one hand, remove the static tag would solve the problem, but on the other hand I have to instantiate every sensor before getting my attribute information.