blob: 6fcf39a895ecfa27863eff3b5c715bc7d47c02fb [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation
*
******************************************************************************/
package org.eclipse.persistence.tools.mapping.orm.dom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.persistence.annotations.ChangeTrackingType;
import org.eclipse.persistence.tools.mapping.AbstractExternalForm;
import org.eclipse.persistence.tools.mapping.ExternalProperty;
import org.eclipse.persistence.tools.mapping.orm.AccessType;
import org.eclipse.persistence.tools.mapping.orm.ExternalAccessMethods;
import org.eclipse.persistence.tools.mapping.orm.ExternalBasicCollectionMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalBasicMapMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalBasicMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalCloneCopyPolicy;
import org.eclipse.persistence.tools.mapping.orm.ExternalConverter;
import org.eclipse.persistence.tools.mapping.orm.ExternalCopyPolicy;
import org.eclipse.persistence.tools.mapping.orm.ExternalElementCollectionMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalEmbeddable;
import org.eclipse.persistence.tools.mapping.orm.ExternalEmbeddedMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalIDMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalInstantiationCopyPolicy;
import org.eclipse.persistence.tools.mapping.orm.ExternalManyToManyMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalManyToOneMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalNoSql;
import org.eclipse.persistence.tools.mapping.orm.ExternalObjectTypeConverter;
import org.eclipse.persistence.tools.mapping.orm.ExternalOneToManyMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalOneToOneMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalStructConverter;
import org.eclipse.persistence.tools.mapping.orm.ExternalTransientMapping;
import org.eclipse.persistence.tools.mapping.orm.ExternalTypeConverter;
import org.eclipse.persistence.tools.utility.NameTools;
import org.eclipse.persistence.tools.utility.ObjectTools;
import org.eclipse.persistence.tools.utility.TextRange;
import org.eclipse.persistence.tools.utility.collection.ListTools;
import org.w3c.dom.Element;
/**
* The external form of an embeddable entity, which is a child of an ORM configuration.
*
* @see ORMConfiguration
*
* @version 2.6
*/
class Embeddable extends AbstractExternalForm
implements ExternalEmbeddable {
/**
* The position of the element within the list of children with the same type owned by the parent.
*/
private int index;
/**
* The order of the mapping element names in the attributes element.
*/
private List<String> mappingElementNamesOrder;
/**
* Creates a new <code>Embeddable</code>.
*
* @param parent The parent of this external form
* @param index The position of the element within the list of children with the same type owned by the parent
*/
Embeddable(ORMConfiguration parent, int index) {
super(parent);
this.index = index;
this.mappingElementNamesOrder = buildMappingElementNamesOrder();
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalAccessMethods addAccessMethods(String getMethodName, String setMethodName) {
AccessMethods accessMethods = buildAccessMethods();
accessMethods.addSelf();
accessMethods.setGetMethod(getMethodName);
accessMethods.setSetMethod(setMethodName);
return accessMethods;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalBasicCollectionMapping addBasicCollectionMapping(String name) {
BasicCollectionMapping mapping = buildBasicCollectionMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalBasicMapMapping addBasicMapMapping(String name) {
BasicMapMapping mapping = buildBasicMapMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalBasicMapping addBasicMapping(String name) {
BasicMapping mapping = buildBasicMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalCloneCopyPolicy addCloneCopyPolicy() {
CloneCopyPolicy cloneCopyPolicy = buildCloneCopyPolicy();
cloneCopyPolicy.addSelf();
return cloneCopyPolicy;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalConverter addConverter(String name) {
Converter converter = buildConverter(index);
converter.addSelf();
converter.setName(name);
return converter;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalCopyPolicy addCopyPolicy() {
CopyPolicy copyPolicy = buildCopyPolicy();
copyPolicy.addSelf();
return copyPolicy;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalElementCollectionMapping addElementCollectionMapping(String name) {
ElementCollectionMapping mapping = buildElementCollectionMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalEmbeddedMapping addEmbeddedMapping(String name) {
EmbeddedMapping mapping = buildEmbeddedMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* Embeddables don't currently support ID, but the implementation is here for convenience.
*
* {@inheritDoc}
*/
@Override
public ExternalIDMapping addIdMapping(String name) {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalInstantiationCopyPolicy addInstantiationCopyPolicy() {
InstantiationCopyPolicy instantiationCopyPolicy = buildInstantiationCopyPolicy();
instantiationCopyPolicy.addSelf();
return instantiationCopyPolicy;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalManyToManyMapping addManyToManyMapping(String name) {
ManyToManyMapping mapping = buildManyToManyMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalManyToOneMapping addManyToOneMapping(String name) {
ManyToOneMapping mapping = buildManyToOneMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalNoSql addNoSql() {
NoSql noSql = buildNoSql();
noSql.addSelf();
return noSql;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalObjectTypeConverter addObjectTypeConverter(String name) {
ObjectTypeConverter converter = buildObjectTypeConverter(index);
converter.addSelf();
converter.setName(name);
return converter;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalOneToManyMapping addOneToManyMapping(String name) {
OneToManyMapping mapping = buildOneToManyMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalOneToOneMapping addOneToOneMapping(String name) {
OneToOneMapping mapping = buildOneToOneMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalProperty addProperty(String name, String value) {
Property property = buildProperty(index);
property.addSelf();
property.setName(name);
property.setValue(value);
return property;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalStructConverter addStructConverter(String name) {
StructConverter converter = buildStructConverter(index);
converter.addSelf();
converter.setName(name);
return converter;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalTransientMapping addTransientMapping(String name) {
TransientMapping mapping = buildTransientMapping(mappingsSize());
mapping.addSelf();
mapping.setName(name);
return mapping;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalTypeConverter addTypeConverter(String name) {
TypeConverter converter = buildTypeConverter(index);
converter.addSelf();
converter.setName(name);
return converter;
}
private AccessMethods buildAccessMethods() {
return new AccessMethods(this);
}
/**
* {@inheritDoc}
*/
@Override
protected List<String> buildAttributeNamesOrder() {
List<String> names = new ArrayList<String>();
names.add(CLASS);
names.add(ACCESS);
names.add(METADATA_COMPLETE);
names.add(EXCLUDE_DEFAULT_MAPPINGS);
return names;
}
private BasicCollectionMapping buildBasicCollectionMapping(int index) {
return new BasicCollectionMapping(this, index);
}
private BasicMapMapping buildBasicMapMapping(int index) {
return new BasicMapMapping(this, index);
}
private BasicMapping buildBasicMapping(int index) {
return new BasicMapping(this, index);
}
private CloneCopyPolicy buildCloneCopyPolicy() {
return new CloneCopyPolicy(this);
}
private Converter buildConverter(int index) {
return new Converter(this, index);
}
private CopyPolicy buildCopyPolicy() {
return new CopyPolicy(this);
}
private ElementCollectionMapping buildElementCollectionMapping(int index) {
return new ElementCollectionMapping(this, index);
}
/**
* {@inheritDoc}
*/
@Override
protected List<String> buildElementNamesOrder() {
List<String> names = new ArrayList<String>();
names.add(DESCRIPTION);
names.add(AccessMethods.ACCESS_METHODS);
names.add(CUSTOMIZER);
names.add(CHANGE_TRACKING);
names.add(NoSql.NO_SQL);
names.add(Converter.CONVERTER);
names.add(TypeConverter.TYPE_CONVERTER);
names.add(ObjectTypeConverter.OBJECT_TYPE_CONVERTER);
names.add(StructConverter.STRUCT_CONVERTER);
names.add(Property.PROPERTY);
names.add(CopyPolicy.COPY_POLICY);
names.add(InstantiationCopyPolicy.INSTANTIATION_COPY_POLICY);
names.add(CloneCopyPolicy.CLONE_COPY_POLICY);
names.add(Mapping.ATTRIBUTES);
return names;
}
private EmbeddedMapping buildEmbeddedMapping(int index) {
return new EmbeddedMapping(this, index);
}
private InstantiationCopyPolicy buildInstantiationCopyPolicy() {
return new InstantiationCopyPolicy(this);
}
private ManyToManyMapping buildManyToManyMapping(int index) {
return new ManyToManyMapping(this, index);
}
private ManyToOneMapping buildManyToOneMapping(int index) {
return new ManyToOneMapping(this, index);
}
Mapping buildMapping(String elementName, int index) {
// Basic
if (ObjectTools.equals(elementName, BasicMapping.BASIC)) {
return buildBasicMapping(index);
}
// Basic Collection
if (ObjectTools.equals(elementName, BasicCollectionMapping.BASIC_COLLECTION)) {
return buildBasicCollectionMapping(index);
}
// Basic Map
if (ObjectTools.equals(elementName, BasicMapMapping.BASIC_MAP)) {
return buildBasicMapMapping(index);
}
// Embedded
if (ObjectTools.equals(elementName, EmbeddedMapping.EMBEDDED)) {
return buildEmbeddedMapping(index);
}
// Element Collection
if (ObjectTools.equals(elementName, ElementCollectionMapping.ELEMENT_COLLECTION)) {
return buildElementCollectionMapping(index);
}
// M:M
if (ObjectTools.equals(elementName, ManyToManyMapping.MANY_TO_MANY)) {
return buildManyToManyMapping(index);
}
// M:1
if (ObjectTools.equals(elementName, ManyToOneMapping.MANY_TO_ONE)) {
return buildManyToOneMapping(index);
}
// 1:M
if (ObjectTools.equals(elementName, OneToManyMapping.ONE_TO_MANY)) {
return buildOneToManyMapping(index);
}
// 1:1
if (ObjectTools.equals(elementName, OneToOneMapping.ONE_TO_ONE)) {
return buildOneToOneMapping(index);
}
// Transient
if (ObjectTools.equals(elementName, TransientMapping.TRANSIENT)) {
return buildTransientMapping(index);
}
return null;
}
/**
* Creates a collection of element names for the supported mappings.
*
* @return The mapping names
*/
List<String> buildMappingElementNamesOrder() {
List<String> names = new ArrayList<String>();
names.add(IdMapping.ID);
names.add(EmbeddedIDMapping.EMBEDDED_ID);
names.add(BasicMapping.BASIC);
names.add(BasicCollectionMapping.BASIC_COLLECTION);
names.add(BasicMapMapping.BASIC_MAP);
names.add(VersionMapping.VERSION);
names.add(ManyToOneMapping.MANY_TO_ONE);
names.add(OneToManyMapping.ONE_TO_MANY);
names.add(OneToOneMapping.ONE_TO_ONE);
names.add(VariableOneToOneMapping.VARIABLE_ONE_TO_ONE);
names.add(ManyToManyMapping.MANY_TO_MANY);
names.add(ElementCollectionMapping.ELEMENT_COLLECTION);
names.add(EmbeddedMapping.EMBEDDED);
names.add(TransformationMapping.TRANSFORMATION);
names.add(TransientMapping.TRANSIENT);
return names;
}
private NoSql buildNoSql() {
return new NoSql(this);
}
private ObjectTypeConverter buildObjectTypeConverter(int index) {
return new ObjectTypeConverter(this, index);
}
private OneToManyMapping buildOneToManyMapping(int index) {
return new OneToManyMapping(this, index);
}
private OneToOneMapping buildOneToOneMapping(int index) {
return new OneToOneMapping(this, index);
}
private Property buildProperty(int index) {
return new Property(this, index);
}
private StructConverter buildStructConverter(int index) {
return new StructConverter(this, index);
}
private TransientMapping buildTransientMapping(int index) {
return new TransientMapping(this, index);
}
private TypeConverter buildTypeConverter(int index) {
return new TypeConverter(this, index);
}
/**
* {@inheritDoc}
*/
@Override
protected void calculateInsertionIndex(Element parent, Element child, String elementName) {
index = index(parent, child, elementName);
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalConverter> converters() {
int count = convertersSize();
List<ExternalConverter> converters = new ArrayList<ExternalConverter>(count);
for (int index = 0; index < count; index++) {
converters.add(buildConverter(index));
}
return converters;
}
/**
* {@inheritDoc}
*/
@Override
public final int convertersSize() {
return getChildrenSize(Converter.CONVERTER);
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalAccessMethods getAccessMethods() {
if (hasChild(AccessMethods.ACCESS_METHODS)) {
return buildAccessMethods();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final AccessType getAccessType() {
return getEnumAttribute(ACCESS, AccessType.class);
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getAccessTypeTextRange() {
return getAttributeTextRange(ACCESS);
}
/**
* {@inheritDoc}
*/
@Override
public final ChangeTrackingType getChangeTrackingType() {
return getChildEnumAttribute(CHANGE_TRACKING, TYPE, ChangeTrackingType.class);
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getChangeTrackingTypeTextRange() {
return getChildAttributeTextRange(CHANGE_TRACKING, TYPE);
}
/**
* {@inheritDoc}
*/
@Override
public final String getClassName() {
return getAttribute(CLASS);
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getClassNameTextRange() {
return getAttributeTextRange(CLASS);
}
/**
* {@inheritDoc}
*/
@Override
public final String getClassShortName() {
return NameTools.shortNameForClassNamed(getClassName());
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalCloneCopyPolicy getCloneCopyPolicy() {
if (hasChild(CloneCopyPolicy.CLONE_COPY_POLICY)) {
return buildCloneCopyPolicy();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalConverter getConverter(int index) {
if (hasChild(Converter.CONVERTER, index)) {
return buildConverter(index);
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalCopyPolicy getCopyPolicy() {
if (hasChild(CopyPolicy.COPY_POLICY)) {
return buildCopyPolicy();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final String getCustomizerClassName() {
return getChildAttribute(CUSTOMIZER, CLASS);
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getCustomizerClassNameTextRange() {
return getChildAttributeTextRange(CUSTOMIZER, CLASS);
}
/**
* {@inheritDoc}
*/
@Override
public final String getDescription() {
return getChildTextNode(DESCRIPTION);
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getDescriptionTextRange() {
return getChildTextNodeTextRange(DESCRIPTION);
}
/**
* {@inheritDoc}
*/
@Override
public final Element getElement() {
return getChild(getParent(), getElementName(), index);
}
/**
* {@inheritDoc}
*/
@Override
protected String getElementName() {
return EMBEDDABLE;
}
/**
* {@inheritDoc}
*/
@Override
public TextRange getExcludeDefaultMappingsTextRange() {
return getAttributeTextRange(EXCLUDE_DEFAULT_MAPPINGS);
}
@Override
@Deprecated
public int getIndex() {
return index;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalInstantiationCopyPolicy getInstantiationCopyPolicy() {
if (hasChild(InstantiationCopyPolicy.INSTANTIATION_COPY_POLICY)) {
return buildInstantiationCopyPolicy();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final Mapping getMapping(String name) {
// TODO: Speed up by creating a helper method that will retrieve the node directly
for (ExternalMapping mapping : mappings()) {
if (ObjectTools.equals(name, mapping.getName())) {
return (Mapping) mapping;
}
}
return null;
}
protected List<String> getMappingElementNamesOrder() {
return this.mappingElementNamesOrder;
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getMetadataCompleteTextRange() {
return getAttributeTextRange(METADATA_COMPLETE);
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalNoSql getNoSql() {
if (hasChild(NoSql.NO_SQL)) {
return buildNoSql();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalObjectTypeConverter getObjectTypeConverter(int index) {
if (hasChild(ObjectTypeConverter.OBJECT_TYPE_CONVERTER, index)) {
return buildObjectTypeConverter(index);
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalProperty> getProperties(String name) {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalProperty getProperty(int index) {
if (hasChild(Property.PROPERTY, index)) {
return buildProperty(index);
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalProperty getProperty(String name) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name)) {
return property;
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalProperty getProperty(String name, int index) {
ExternalProperty property = getProperty(index);
if ((property != null) && ObjectTools.equals(name, property.getName())) {
return property;
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalProperty getProperty(String name, String value) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name) &&
ObjectTools.equals(property.getValue(), value)) {
return property;
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getPropertyNameTextRange(String name) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name)) {
return property.getNameTextRange();
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getPropertyTextRange(String name) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name)) {
return property.getTextRange();
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getPropertyTextRange(String name, String value) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name) &&
ObjectTools.equals(property.getValue(), value)) {
return property.getTextRange();
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final TextRange getPropertyValueTextRange(String name) {
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name)) {
return property.getValueTextRange();
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalStructConverter getStructConverter(int index) {
if (hasChild(StructConverter.STRUCT_CONVERTER, index)) {
return buildStructConverter(index);
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final ExternalTypeConverter getTypeConverter(int index) {
if (hasChild(TypeConverter.TYPE_CONVERTER, index)) {
return buildTypeConverter(index);
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalIDMapping> idMappings() {
List<ExternalIDMapping> idMappings = new ArrayList<ExternalIDMapping>();
// TODO: Use a filter
for (ExternalMapping mapping : mappings()) {
if (mapping instanceof ExternalIDMapping) {
idMappings.add((ExternalIDMapping)mapping);
}
}
return idMappings;
}
/**
* {@inheritDoc}
*/
@Override
public final Boolean isExcludeDefaultMappings() {
return getBooleanAttribute(EXCLUDE_DEFAULT_MAPPINGS);
}
/**
* {@inheritDoc}
*/
@Override
public final Boolean isMetadataComplete() {
return getBooleanAttribute(METADATA_COMPLETE);
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalMapping> mappings() {
Element element = getChild(Mapping.ATTRIBUTES);
if (element != null) {
return mappings(element);
}
return Collections.emptyList();
}
private List<ExternalMapping> mappings(Element element) {
List<ExternalMapping> mappings = new ArrayList<ExternalMapping>();
int index = 0;
for (Element childElement : getChildren(element)) {
String elementName = getNodeName(childElement);
ExternalMapping mapping = buildMapping(elementName, index++);
if (mapping != null) {
mappings.add(mapping);
}
}
return mappings;
}
/**
* {@inheritDoc}
*/
@Override
public final int mappingsSize() {
Element attributes = getChild(Mapping.ATTRIBUTES);
if (attributes != null) {
return getChildrenSize(attributes, getMappingElementNamesOrder());
}
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalObjectTypeConverter> objectTypeConverters() {
int count = objectTypeConvertersSize();
List<ExternalObjectTypeConverter> converters = new ArrayList<ExternalObjectTypeConverter>(count);
for (int index = 0; index < count; index++) {
converters.add(buildObjectTypeConverter(index));
}
return converters;
}
/**
* {@inheritDoc}
*/
@Override
public final int objectTypeConvertersSize() {
return getChildrenSize(ObjectTypeConverter.OBJECT_TYPE_CONVERTER);
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalProperty> properties() {
int count = propertiesSize();
List<ExternalProperty> properties = new ArrayList<ExternalProperty>(count);
for (int index = 0; index < count; index++) {
properties.add(buildProperty(index));
}
return properties;
}
/**
* {@inheritDoc}
*/
@Override
public final int propertiesSize() {
return getChildrenSize(Property.PROPERTY);
}
/**
* {@inheritDoc}
*/
@Override
public final int propertiesSize(String name) {
int count = 0;
for (ExternalProperty property : properties()) {
if (ObjectTools.equals(property.getName(), name)) {
count++;
}
}
return count;
}
/**
* {@inheritDoc}
*/
@Override
public final void removeAccessMethods() {
removeChild(AccessMethods.ACCESS_METHODS);
}
/**
* {@inheritDoc}
*/
@Override
public final void removeCloneCopyPolicy() {
CloneCopyPolicy policy = buildCloneCopyPolicy();
policy.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeConverter(int index) {
Converter converter = buildConverter(index);
converter.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeCopyPolicy() {
CopyPolicy policy = buildCopyPolicy();
policy.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeInstantiationCopyPolicy() {
InstantiationCopyPolicy policy = buildInstantiationCopyPolicy();
policy.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeMapping(String name) {
Mapping mapping = getMapping(name);
if (mapping != null) {
mapping.removeSelf();
}
}
/**
* {@inheritDoc}
*/
@Override
public final void removeNoSql() {
NoSql noSql = buildNoSql();
noSql.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeObjectTypeConverter(int index) {
ObjectTypeConverter converter = buildObjectTypeConverter(index);
converter.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeProperty(int index) {
Property converter = buildProperty(index);
converter.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeProperty(String name) {
Property property = (Property) getProperty(name);
property.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeProperty(String name, String value) {
Property property = (Property) getProperty(name, value);
property.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeSelf() {
removeChild(getParent(), getElementName(), index);
}
/**
* {@inheritDoc}
*/
@Override
public final void removeStructConverter(int index) {
StructConverter converter = buildStructConverter(index);
converter.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void removeTypeConverter(int index) {
TypeConverter converter = buildTypeConverter(index);
converter.removeSelf();
}
/**
* {@inheritDoc}
*/
@Override
public final void setAccessType(AccessType type) {
setAttribute(ACCESS, type);
}
/**
* {@inheritDoc}
*/
@Override
public final void setChangeTrackingType(ChangeTrackingType type) {
updateChildAttribute(CHANGE_TRACKING, TYPE, type);
}
/**
* {@inheritDoc}
*/
@Override
public final void setClassName(String className) {
setAttribute(CLASS, className);
}
/**
* {@inheritDoc}
*/
@Override
public final void setCustomizerClassName(String name) {
updateChildAttribute(CUSTOMIZER, CLASS, name);
}
/**
* {@inheritDoc}
*/
@Override
public final void setDescription(String description) {
updateChildTextNode(DESCRIPTION, description);
}
/**
* {@inheritDoc}
*/
@Override
public final void setExcludeDefaultMappings(Boolean excludeDefaultMappings) {
setAttribute(EXCLUDE_DEFAULT_MAPPINGS, excludeDefaultMappings);
}
/**
* {@inheritDoc}
*/
@Override
public final void setMetadataComplete(Boolean metaDataComplete) {
setAttribute(METADATA_COMPLETE, metaDataComplete);
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalStructConverter> structConverters() {
int count = structConvertersSize();
List<ExternalStructConverter> converters = new ArrayList<ExternalStructConverter>(count);
for (int index = 0; index < count; index++) {
converters.add(buildStructConverter(index));
}
return converters;
}
/**
* {@inheritDoc}
*/
@Override
public final int structConvertersSize() {
return getChildrenSize(StructConverter.STRUCT_CONVERTER);
}
/**
* {@inheritDoc}
*/
@Override
public final List<ExternalTypeConverter> typeConverters() {
int count = typeConvertersSize();
List<ExternalTypeConverter> converters = new ArrayList<ExternalTypeConverter>(count);
for (int index = 0; index < count; index++) {
converters.add(buildTypeConverter(index));
}
return converters;
}
/**
* {@inheritDoc}
*/
@Override
public final int typeConvertersSize() {
return getChildrenSize(TypeConverter.TYPE_CONVERTER);
}
}