Scanner { ImmutableMap<ColumnName, InterfaceBasedColumn> interfaceBasedColumns() { if (!columnsInterfaceBased) { return ImmutableMap.of(); } ImmutableMap.Builder<ColumnName, InterfaceBasedColumn> columns = ImmutableMap.builder(); for (FieldDeclaration field : columnsOf(entityClass.stateType())) { addImplementedColumn(field, columns); } return columns.build(); } Scanner(EntityClass<?> entityClass);   }
@Test @DisplayName("extract columns implemented via `EntityWithColumns` descendant") void extractImplementedColumns() { EntityClass<TaskViewProjection> entityClass = asEntityClass(TaskViewProjection.class); Scanner scanner = new Scanner(entityClass); ImmutableMap<ColumnName, InterfaceBasedColumn> columns = scanner.interfaceBasedColumns(); assertThat(columns).containsKey(ColumnName.of("name")); assertThat(columns).containsKey(ColumnName.of("estimate_in_days")); assertThat(columns).containsKey(ColumnName.of("status")); assertThat(columns).containsKey(ColumnName.of("due_date")); }
@Test @DisplayName("extract columns from the non-`public` entity class") void extractFromNonPublic() { EntityClass<PrivateProjection> entityClass = asEntityClass(PrivateProjection.class); Scanner scanner = new Scanner(entityClass); ImmutableMap<ColumnName, InterfaceBasedColumn> columns = scanner.interfaceBasedColumns(); ColumnName description = ColumnName.of("description"); InterfaceBasedColumn column = columns.get(description); Entity<TaskListViewId, TaskListView> projection = new PrivateProjection(); assertThat(column.valueIn(projection)).isEqualTo(PrivateProjection.DESCRIPTION); }