private static Collection<Annotation> getSelectableAnnotations() { AnnotationFactory factory = DefaultAnnotationFactory.getInstance(); List<Annotation> annotations = new ArrayList<Annotation>(); annotations.addAll(factory.getSubclassInstances(StringAnnotation.class)); annotations.add(factory.ofClass(Charge.class)); // display name order Collections.sort( annotations, new Comparator<Annotation>() { @Override public int compare(Annotation o1, Annotation o2) { return name(o1).compareTo(name(o2)); } private String name(Annotation a) { return a.getBrief() != null ? a.getBrief() : a.getClass().getSimpleName(); } }); // displayed as: -- select annotation -- annotations.add(0, null); return annotations; }
/** * Map the identifier to all entities which match the given key. If the key did not match any * entity then the key is added to {@link #unmapped()} * * @param key look up entities * @param id the id * @return an entity <i>handled</i> the identifier * @see #unmapped() */ public boolean map(K key, Identifier id) { if (id == null) throw new IllegalArgumentException("no identifier provided"); return map(key, annotations.getCrossReference(id)); }