UIDisplayableProcessor extends AbstractMapProcessor<UIDisplayable, String, Long> { @Override protected void process(AnnotatedElement element) { Class<?> classType = MemberUtil.getCorrectType(element); if (null != classType) { UIDisplayable annotation = ReflectionsUtil.getAnnotationClassLoaderSafe(element, classType, UIDisplayable.class); if (null != annotation) { String fieldName = MemberUtil.getFieldName(element); Long position = annotation.position(); if (DEFAULT_VALUE.equals(position)) { put(fieldName, Long.MIN_VALUE + getElements().size()); } else if (getElements().containsValue(position)) { LOGGER.error("The annotation has the position value which is already used. Assigning default value"); put(fieldName, Long.MIN_VALUE + getElements().size()); } else { put(fieldName, position); } } } else { LOGGER.warn("Field type is unknown in: {}", element); } }  @Override Class<UIDisplayable> getAnnotationType(); @Override Map<String, Long> getProcessingResult(); void setClazz(Class clazz);  }
@Test public void shouldProcessField() throws Exception { Field world = getDeclaredField(Sample.class, FIELD_NAME, true); processor.process(world); Map<String, Long> positions = processor.getElements(); assertEquals(1, positions.size()); assertTrue(positions.containsValue(Long.MIN_VALUE)); assertTrue(positions.containsKey(FIELD_NAME)); }