/** * Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param name the name of the type to unregister. * @return true if the type was successfully unregistered, false otherwise (it was not present) */ public boolean unregister(String name) { AnnotationType oldType = nameMap.remove(name); if (oldType != null) { idMap.remove(oldType.getId()); return true; } return false; }
/** * Unregisters the type given by the argument. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the AnnotationType to unregister. * @return true if the type was successfully unregistered, false otherwise (it was not present) * @throws IllegalArgumentException if the ID and name of this annotation type are present, but they do not belong together. */ public boolean unregister(AnnotationType type) { if (idMap.containsKey(type.getId()) && nameMap.containsKey(type.getName())) { AnnotationType idType = idMap.get(type.getId()); AnnotationType nameType = nameMap.get(type.getName()); if (idType == nameType) { //name and id belong together in our maps idMap.remove(type.getId()); nameMap.remove(type.getName()); } else { throw new IllegalArgumentException("The ID and name of this annotation type are present, but they do not belong together. Not removing type."); } return true; } //it's not there, but that's no problem return false; }
/** * Register a new annotation type. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the type to register * @throws IllegalArgumentException if a type is already registered with this name or this id, and it is non-equal to the argument. */ public void register(AnnotationType type) { if (idMap.containsKey(type.getId()) || nameMap.containsKey(type.getName())) { AnnotationType idType = idMap.get(type.getId()); AnnotationType nameType = nameMap.get(type.getName()); if (type.equals(idType) && type.equals(nameType)) { //it's the same one being re-registered, we're OK! return; } throw new IllegalArgumentException("A type is already registered with this name or this id."); } idMap.put(type.getId(), type); nameMap.put(type.getName(), type); }
private void buildConfig(AnnotationType annotation, DocumenttypesConfig.Documenttype.Annotationtype.Builder builder) { builder. id(annotation.getId()). name(annotation.getName()); DataType dt = annotation.getDataType(); if (dt != null) { builder.datatype(dt.getId()); } for (AnnotationType inherited : annotation.getInheritedTypes()) { builder.inherits(new DocumenttypesConfig.Documenttype.Annotationtype.Inherits.Builder().id(inherited.getId())); } }
private void buildConfig(AnnotationType type, DocumentmanagerConfig.Annotationtype.Builder atb) { atb. id(type.getId()). name(type.getName()); if (type.getDataType() != null) { atb.datatype(type.getDataType().getId()); } if ( ! type.getInheritedTypes().isEmpty()) { for (AnnotationType inherited : type.getInheritedTypes()) { atb.inherits(new DocumentmanagerConfig.Annotationtype.Inherits.Builder().id(inherited.getId())); } } } private void buildConfig(Collection<AnnotationType> types, DocumentmanagerConfig.Builder builder) {
private void buildConfig(AnnotationReferenceDataType type, DocumenttypesConfig.Documenttype.Datatype.Builder dataTypeBuilder) { dataTypeBuilder. type(DocumenttypesConfig.Documenttype.Datatype.Type.Enum.ANNOTATIONREF). annotationref(new DocumenttypesConfig.Documenttype.Datatype.Annotationref.Builder(). annotation(new DocumenttypesConfig.Documenttype.Datatype.Annotationref.Annotation.Builder(). id(type.getAnnotationType().getId()))); }
public void write(Annotation annotation) { buf.putInt(annotation.getType().getId()); //name hash
public void write(Annotation annotation) { buf.putInt(annotation.getType().getId()); //name hash