List of usage examples for org.springframework.ide.eclipse.core StringUtils collectionToDelimitedString
public static String collectionToDelimitedString(Collection coll, String delim)
Collection as a delimited (e.g. From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java
public static IType hasReadProperty(String property, String className, IProject project, boolean noGetter) throws JavaModelException { IType javaType = JdtUtils.getJavaType(project, className); String checkProperty = property; String[] propertySplitted = checkProperty.split("\\."); //we only check the first level, if there is some x.y.z property if (propertySplitted.length > 1) { checkProperty = propertySplitted[0]; }/*from w ww . j a v a 2 s . c om*/ //if we are doing indexed property mapping, we remove the [] checkProperty = checkProperty.replaceAll("\\[\\]", ""); if (noGetter) { IField[] fields = javaType.getFields(); for (IField field : fields) { if (field.getElementName().equals(property)) { return field.getDeclaringType(); } } return null; } Collection<IMethod> methods = Introspector.findReadableProperties(javaType, checkProperty, true); boolean retVal = methods.size() > 0; if (!retVal) return null; else { try { //className = JdtUtils.resolveClassName(className, javaType); if (!Class.forName(className).isPrimitive()) className = null; } catch (Throwable t) { //className = null; } Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { IMethod method = (IMethod) iterator.next(); IType returnType = JdtUtils.getJavaTypeForMethodReturnType(method, javaType); if (className == null) { if (returnType != null) className = returnType.getFullyQualifiedName(); } if (className != null) { if (propertySplitted.length > 1) { List<String> l = new ArrayList<String>(Arrays.asList(propertySplitted)); l.remove(0); property = StringUtils.collectionToDelimitedString(l, "."); return hasReadProperty(property, returnType.getFullyQualifiedName(), project, false); } else { return returnType; } } } } return null; }
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);//ww w .j a v a2s .c om 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; }