@Test @SuppressWarnings("ResultOfMethodCallIgnored") public void convertShouldThrowExceptionWhenInvalidName() throws Exception { application.invokeAndWait(() -> { assertThatThrownBy(() -> { underTest.convert("+-*/", TypeName.OBJECT); }).isInstanceOf(IllegalArgumentException.class); }); }
@Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } }
MethodNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } } }
MethodNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } } @Inject  MethodNamePolicy(@Nonnull Project project, @Nonnull PsiTypeConverter typeConverter); }
MethodNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } } @Inject  MethodNamePolicy(@Nonnull Project project, @Nonnull PsiTypeConverter typeConverter); @Nonnull @Override String convert(@Nonnull String name, @Nonnull TypeName type); }
MethodNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } } @Inject  MethodNamePolicy(@Nonnull Project project, @Nonnull PsiTypeConverter typeConverter); @Nonnull @Override String convert(@Nonnull String name, @Nonnull TypeName type);  }