List of usage examples for org.springframework.ide.eclipse.core.java Introspector findWritableProperties
public static Set<IMethod> findWritableProperties(IType type, String methodPrefix, boolean ignoreCase) throws JavaModelException
From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java
public static void addPropertyNameAttributeValueProposals(ContentAssistRequest request, String prefix, String oldPrefix, IType type) { // resolve type of indexed and nested property path if (prefix.lastIndexOf(".") >= 0) { int firstIndex = prefix.indexOf("."); String firstPrefix = prefix.substring(0, firstIndex); String lastPrefix = prefix.substring(firstIndex); if (".".equals(lastPrefix)) { lastPrefix = ""; } else if (lastPrefix.startsWith(".")) { lastPrefix = lastPrefix.substring(1); }/*from ww w .jav a 2 s . c o m*/ try { Collection<?> methods = Introspector.findReadableProperties(type, firstPrefix, true); if (methods != null && methods.size() == 1) { Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { IMethod method = (IMethod) iterator.next(); IType returnType = JdtUtils.getJavaTypeForMethodReturnType(method, type); if (returnType != null) { String newPrefix = oldPrefix + firstPrefix + "."; addPropertyNameAttributeValueProposals(request, lastPrefix, newPrefix, returnType); } return; } } } catch (CoreException e) { // do nothing } } else { try { Collection<?> methods = Introspector.findWritableProperties(type, prefix, true); if (methods != null && methods.size() > 0) { Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { createMethodProposal(request, (IMethod) iterator.next(), oldPrefix); } } } catch (JavaModelException e1) { // do nothing } } }
From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java
public static IType hasWriteProperty(String property, String className, IProject project) throws JavaModelException { IType javaType = JdtUtils.getJavaType(project, className); String checkProperty = property; String[] propertySplitted = checkProperty.split("\\."); if (propertySplitted.length > 1) { List<String> l = new ArrayList(Arrays.asList(propertySplitted)); checkProperty = l.get(l.size() - 1); l.remove(l.size() - 1);//from ww w.j a v a 2s. c o m property = StringUtils.collectionToDelimitedString(l, "."); javaType = DozerPluginUtils.hasReadProperty(property, className, project, false); if (javaType == null) return null; } //if we are doing indexed property mapping, we remove the [] checkProperty = checkProperty.replaceAll("\\[\\]", ""); Collection<?> methods = Introspector.findWritableProperties(javaType, checkProperty, true); boolean retVal = methods.size() > 0; if (!retVal) return null; else return javaType; }