Question: Most probably I oversee something in this trivial use case.
My code iterates over annotated fields in a class and the for every field I'd like to run some code dependent on the type. The simplest is just to set a value:

```
field.setAccessible(true);
final Class<?> type = field.getType();
if (type.equals(Boolean.class)) {
    field.set(this, Boolean.parseBoolean(property));
} else if (type.equals(Integer.class)) {
    field.set(this, Integer.parseInt(property));
} else if (type.equals(String.class)) {
    field.set(this, property);
} else {
    LOGGER.warn("Cannot parse property -{}{}. Unknown type defined.", option.getOpt(),
            field.getName());
}

```

However this check:

```
if (type.equals(Boolean.class))

```

dosn't work as expected e.g. for a field defined as `private boolean isVerbose;`. After inspection of `type` I got the property `name` as just only `"boolean"` where the `Boolean.class` property `name` was filled with `"java.lang.Boolean"`. These object were different.

What would be the right implementation of this scenario?

Answer: 
Take a look at this post: [Check type of primitive field](https://stackoverflow.com/questions/1891595/check-type-of-primitive-field)

basically you need to check primitive types separately (`Boolean.TYPE`, `Long.TYPE` etc)

```
if (field.getType().equals(Boolean.TYPE) {
  // do something if field is boolean
}

```
I believe you are having troubles with the java primitives and the boxing.
java.lang.Boolean is a class, where as "boolean" just denotes the primitive type.

It is a difference wether you declare:

```
private boolean myBool; // this a java primitive
private Boolean myOtherBool; // this is an object

```

Java automatically converts between those types as needed, but as you are inspecting the type yourself you have to pay attention to this.

The same goes for:
- Integer
- Long
- Short
- Byte

I hope I did not forget anything.