/** * Returns the extension if the extension name exists otherwise returns null * * @param extensionName * @return the found extension or null if it is not found */ public SubTypeExtension getExtension(String extensionName) { SubTypeExtension ext = null; for (SubTypeExtension e : extensions) { if (e.getName().equals(extensionName)) { ext = e; } } return ext; }
/** * Add an extension - this changes the data to reflect an extension for this sub type. * * @param extension */ public void addExtension(SubTypeExtension extension) throws DuplicateNameException { if (getExtension(extension.getName()) != null) { throw new DuplicateNameException( "Subtype extension for subtype " + this + " with name already exists", extension.getName()); } extension.setSubType(this); extension.setMimeType( getTopMediaType().getName() + SubTypeExtension.MIME_TYPE_SEPERATOR + getName()); extensions.add(extension); }
/** * Returns the extension if the id exists otherwise returns null - null is always returned if the * id is 0 * * @param extensionName * @return the found extension or null if it is not found */ public SubTypeExtension getExtension(Long id) { SubTypeExtension ext = null; if (id == 0) { return ext; } for (SubTypeExtension e : extensions) { if (e.getId().equals(id)) { ext = e; } } return ext; }
/** * Remove an extension from this subtype * * @param extension to remove * @return true if the extension is removed */ private boolean removeExtension(SubTypeExtension extension) { extension.setSubType(null); return extensions.remove(extension); }