Skip to content

Add AbstractClassAssert#is(Not)Primitive() #2717

@onacit

Description

@onacit

Feature summary

The AbstractClassAssert lacks with is(Not)Primitive().

Example

assertThat(int.class).isPrimitive();
assertThat(String.class).isNotPrimitive();

There is already workarounds for the case, I know.

assertThat(c.isPrimitive()).isTrue();

I just found a case regarding the .as(...).

for (Field file : findSomeSpecificFields()) {
    assertThat(field.getType().isPrimitive())
        .as("@NullableBySpecification on primitive field: %s", field)
        .isFalse();
}

which may be more fluent,

for (Field file : findSomeSpecificFields()) {
    assertThat(field.getType())
        .as("%s annotated with @NullableBySpecification, field)
        .isNotPrimitive();
    //  '...Class#field annotated with @NullableBySpecification should not be primitive.
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions