use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class TypeVisitor method visit.
@Override
public boolean visit(MethodDeclaration node) {
if (!entityInfo.isInterfaceFlag())
return super.visit(node);
org.eclipse.jdt.core.dom.TypeDeclaration type = (org.eclipse.jdt.core.dom.TypeDeclaration) node.getParent();
// TODO check Abstract methods
if (type.isInterface()) {
String varName = Utils.getFieldNameByGetter(node);
if (varName != null) {
String primaryIdName = entityInfo.getPrimaryIdName();
Type methodType = node.getReturnType2();
if (varName.toLowerCase().equals(primaryIdName.toLowerCase()))
varName = primaryIdName;
IProperty prop = createProperty(varName, methodType);
if (varName.equals(primaryIdName)) {
rootClass.setIdentifierProperty(prop);
} else {
rootClass.addProperty(prop);
}
}
}
return super.visit(node);
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class TypeVisitor method visit.
@SuppressWarnings("unchecked")
public boolean visit(FieldDeclaration node) {
// do not map static or final fields
if ((node.getModifiers() & (Modifier.FINAL | Modifier.STATIC)) != 0) {
return false;
}
Type type = node.getType();
if (type == null) {
return true;
}
String primaryIdName = entityInfo.getPrimaryIdName();
Iterator<VariableDeclarationFragment> itVarNames = node.fragments().iterator();
while (itVarNames.hasNext()) {
VariableDeclarationFragment var = itVarNames.next();
IProperty prop = createProperty(var);
if (prop == null) {
continue;
}
if (!varHasGetterAndSetter(var)) {
// $NON-NLS-1$
prop.setPropertyAccessorName("field");
}
String name = var.getName().getIdentifier();
if (name.equals(primaryIdName)) {
rootClass.setIdentifierProperty(prop);
} else {
rootClass.addProperty(prop);
}
}
return true;
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class TypeVisitor method createProperty.
protected IProperty createProperty(String varName, Type varType) {
typeVisitor.init(varName, entityInfo);
varType.accept(typeVisitor);
IProperty p = typeVisitor.getProperty();
return p;
}
Aggregations