org.chromattic.metamodel.mapping.BeanMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chromattic.metamodel Show documentation
Show all versions of chromattic.metamodel Show documentation
Chromattic Framework Metamodel
The newest version!
/*
* Copyright (C) 2010 eXo Platform SAS.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.chromattic.metamodel.mapping;
import org.chromattic.api.NameConflictResolution;
import org.chromattic.metamodel.bean.BeanInfo;
import org.reflext.api.ClassTypeInfo;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Julien Viet
* @version $Revision$
*/
public class BeanMapping {
/** . */
final BeanInfo bean;
/** . */
BeanMapping parent;
/** . */
final Map> properties;
/** . */
final Map> unmodifiableProperties;
/** . */
final List methods;
/** . */
final List unmodifiableMethods;
/** . */
final NodeTypeKind nodeTypeKind;
/** . */
final ClassTypeInfo formatterClassType;
/** . */
final String nodeTypeName;
/** . */
final boolean orderable;
/** . */
final boolean abstract_;
/** . */
final NameConflictResolution onDuplicate;
/** . */
final String prefix;
public BeanMapping(
BeanInfo bean,
NodeTypeKind nodeTypeKind,
String nodeTypeName,
NameConflictResolution onDuplicate,
ClassTypeInfo formatterClassType,
boolean orderable,
boolean abstract_,
String prefix) {
this.bean = bean;
this.nodeTypeKind = nodeTypeKind;
this.nodeTypeName = nodeTypeName;
this.orderable = orderable;
this.abstract_ = abstract_;
this.properties = new HashMap>();
this.unmodifiableProperties = Collections.unmodifiableMap(properties);
this.methods = new ArrayList();
this.unmodifiableMethods = Collections.unmodifiableList(methods);
this.onDuplicate = onDuplicate;
this.formatterClassType = formatterClassType;
this.prefix = prefix;
}
public NodeTypeKind getNodeTypeKind() {
return nodeTypeKind;
}
public String getNodeTypeName() {
return nodeTypeName;
}
public ClassTypeInfo getFormatterClassType() {
return formatterClassType;
}
public NameConflictResolution getOnDuplicate() {
return onDuplicate;
}
public boolean isOrderable() {
return orderable;
}
public boolean isAbstract() {
return abstract_;
}
public BeanInfo getBean() {
return bean;
}
public Map> getProperties() {
return properties;
}
public Collection getMethods() {
return methods;
}
public String getPrefix() {
return prefix;
}
public > M getPropertyMapping(String name, Class type) {
PropertyMapping, ?, ?> mapping = properties.get(name);
if (type.isInstance(mapping)) {
return type.cast(mapping);
} else {
return null;
}
}
public void accept(MappingVisitor visitor) {
visitor.startBean(this);
for (PropertyMapping, ?, ?> property : properties.values()) {
property.accept(visitor);
}
for (MethodMapping method : methods) {
method.accept(visitor);
}
visitor.endBean();
}
@Override
public String toString() {
return "BeanMapping[info=" + bean + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy