private GenerationInfo generateWithMethodFor(PsiField field) { PsiMethod templateMethod = generateMethodPrototype(field); PsiMethod existingMethod = field.getContainingClass().findMethodBySignature(templateMethod, false); return existingMethod == null ? new PsiGenerationInfo(templateMethod) : null; }
private PsiMethod generateMethodFor( PsiField field, String methodName, String parameterName, PsiElementFactory elementFactory) { PsiMethod withMethod = elementFactory.createMethod( methodName, elementFactory.createType(field.getContainingClass())); PsiParameter parameter = elementFactory.createParameter(parameterName, field.getType()); withMethod.getParameterList().add(parameter); PsiUtil.setModifierProperty(withMethod, PsiModifier.PUBLIC, true); return withMethod; }