+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Reference preSaveBean(Reference bean) {
+
+ // handle annotation changes
+ List<Annotation> annotations = getView().getAnnotationsField().getValue();
+ List<Annotation> currentAnnotations = new ArrayList<>(bean.getAnnotations());
+ List<Annotation> annotationsSeen = new ArrayList<>();
+ for(Annotation a : annotations){
+ if(a == null){
+ continue;
+ }
+ if(!currentAnnotations.contains(a)){
+ bean.addAnnotation(a);
+ }
+ annotationsSeen.add(a);
+ }
+ for(Annotation a : currentAnnotations){
+ if(!annotationsSeen.contains(a)){
+ bean.removeAnnotation(a);
+ }
+ }
+
+
+ return bean;
+ }
+
+
+