use of org.eclipse.jdt.core.dom.ParameterizedType in project sts4 by spring-projects.
the class BeansSymbolProvider method isFunctionBean.
private boolean isFunctionBean(Annotation node) {
ASTNode parent = node.getParent();
if (parent instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration) parent;
String returnType = null;
if (method.getReturnType2().isParameterizedType()) {
ParameterizedType paramType = (ParameterizedType) method.getReturnType2();
Type type = paramType.getType();
ITypeBinding typeBinding = type.resolveBinding();
returnType = typeBinding.getBinaryName();
} else {
returnType = method.getReturnType2().resolveBinding().getQualifiedName();
}
return FunctionUtils.FUNCTION_FUNCTION_TYPE.equals(returnType) || FunctionUtils.FUNCTION_CONSUMER_TYPE.equals(returnType) || FunctionUtils.FUNCTION_SUPPLIER_TYPE.equals(returnType);
}
return false;
}
use of org.eclipse.jdt.core.dom.ParameterizedType in project jbosstools-hibernate by jbosstools.
the class CollectEntityInfo method processFieldOrGetter.
public boolean processFieldOrGetter(Type type, List<String> list, boolean fieldFlag) {
if (type == null) {
return false;
}
if (type.isPrimitiveType()) {
PrimitiveType pt = (PrimitiveType) type;
if (!pt.getPrimitiveTypeCode().equals(PrimitiveType.BOOLEAN)) {
// this is candidate for primary id
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
if ("version".equalsIgnoreCase(name)) {
// $NON-NLS-1$
FieldGetterType versionFieldGetter = updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
entityInfo.setVersionFieldGetter(versionFieldGetter);
} else {
entityInfo.addPrimaryIdCandidate(name);
}
}
}
} else if (type.isSimpleType()) {
SimpleType st = (SimpleType) type;
ITypeBinding tb = st.resolveBinding();
if (tb != null) {
// $NON-NLS-1$
String entityFullyQualifiedName = "";
if (tb.getJavaElement() instanceof SourceType) {
SourceType sourceT = (SourceType) tb.getJavaElement();
entityFullyQualifiedName = sourceT.getFullyQualifiedName();
entityInfo.addDependency(entityFullyQualifiedName);
RefType refType2Use = tb.isEnum() ? RefType.ENUMERATED : RefType.MANY2ONE;
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
entityInfo.addReference(name, entityFullyQualifiedName, refType2Use);
}
} else if (tb.getJavaElement() instanceof BinaryType) {
ITypeBinding tbParent = tb.getTypeDeclaration().getSuperclass();
if (tbParent != null) {
if ("java.lang.Number".equals(tbParent.getBinaryName())) {
// $NON-NLS-1$
// this is candidate for primary id
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
if ("version".equalsIgnoreCase(name)) {
// $NON-NLS-1$
FieldGetterType versionFieldGetter = updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
entityInfo.setVersionFieldGetter(versionFieldGetter);
} else {
entityInfo.addPrimaryIdCandidate(name);
}
}
} else if ("java.util.Date".equals(tbParent.getBinaryName())) {
// $NON-NLS-1$
// this is candidate for version
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
if ("version".equalsIgnoreCase(name)) {
// $NON-NLS-1$
FieldGetterType versionFieldGetter = updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
entityInfo.setVersionFieldGetter(versionFieldGetter);
}
}
}
}
if ("java.lang.String".equals(tb.getBinaryName())) {
// $NON-NLS-1$
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
entityInfo.updateAnnotationColumn(name, null, false);
entityInfo.addPrimaryIdCandidate(name);
}
}
}
}
} else if (type.isArrayType()) {
ArrayType at = (ArrayType) type;
Type elementType = at.getElementType();
ITypeBinding tb = elementType.resolveBinding();
if (tb != null) {
if (tb.getJavaElement() instanceof SourceType) {
// $NON-NLS-1$
String entityFullyQualifiedName = "";
SourceType sourceT = (SourceType) tb.getJavaElement();
try {
entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
} catch (JavaModelException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e);
}
entityInfo.addDependency(entityFullyQualifiedName);
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY);
}
}
}
} else if (type.isParameterizedType()) {
ParameterizedType pt = (ParameterizedType) type;
Type typeP = pt.getType();
ITypeBinding tb = typeP.resolveBinding();
if (tb != null) {
ITypeBinding[] interfaces = Utils.getAllInterfaces(tb);
// $NON-NLS-1$
String fullyQualifiedNameTypeName = "";
if (Utils.isImplementInterface(interfaces, "java.util.Collection")) {
// $NON-NLS-1$
// $NON-NLS-1$
fullyQualifiedNameTypeName = "java.util.Collection";
}
if (Utils.isImplementInterface(interfaces, "java.util.Map")) {
// $NON-NLS-1$
// $NON-NLS-1$
fullyQualifiedNameTypeName = "java.util.Map";
}
/*for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i].getJavaElement() instanceof BinaryType) {
BinaryType binaryT = (BinaryType)interfaces[i].getJavaElement();
String tmp = binaryT.getFullyQualifiedName('.');
if (0 == "java.util.Collection".compareTo(tmp)) { //$NON-NLS-1$
fullyQualifiedNameTypeName = tmp;
break;
}
}
}*/
if (fullyQualifiedNameTypeName.length() > 0) {
Iterator<Type> typeArgsIt = pt.typeArguments().iterator();
while (typeArgsIt.hasNext()) {
typeP = typeArgsIt.next();
tb = typeP.resolveBinding();
// $NON-NLS-1$
String entityFullyQualifiedName = "";
if (tb.getJavaElement() instanceof SourceType) {
SourceType sourceT = (SourceType) tb.getJavaElement();
try {
entityFullyQualifiedName = sourceT.getFullyQualifiedParameterizedName();
} catch (JavaModelException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e);
}
entityInfo.addDependency(entityFullyQualifiedName);
Iterator<String> itVarNames = list.iterator();
while (itVarNames.hasNext()) {
String name = itVarNames.next();
entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY);
}
}
}
}
}
} else if (type.isQualifiedType()) {
QualifiedType qt = (QualifiedType) type;
@SuppressWarnings("unused") ITypeBinding tb = qt.resolveBinding();
} else if (type.isWildcardType()) {
WildcardType wt = (WildcardType) type;
@SuppressWarnings("unused") ITypeBinding tb = wt.resolveBinding();
}
return true;
}
Aggregations