InfinispanSchemaStore { protected int getMaxIndexNumber(List<Field> fields) { return fields.stream() .sorted(Comparator.comparingInt(Field::getIndex).reversed()) .mapToInt(Field::getIndex) .findFirst() .orElse(0); } InfinispanSchemaStore(InfinispanContext infinispanContext,
                                 MappingProvider mappingProvider); void updateSchema(KObject kObject); boolean containsField(List<Field> fields,
                                 Field field);  }
@Test public void testMaxIndexNumbert() { List<Field> fields = Arrays.asList(new Field(ProtobufScope.OPTIONAL, ProtobufType.STRING, "field1", 1), new Field(ProtobufScope.OPTIONAL, ProtobufType.STRING, "field2", 2)); int max = this.infinispanSchemaStore.getMaxIndexNumber(fields); assertThat(max).isEqualTo(2); }