@Test public void convertShouldRemoveInvalidCharacter() throws Exception { final String actual = underTest.convert("1nva|id", TypeName.OBJECT); assertThat(actual) .isEqualTo("a1nvaid"); }
@Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; }
FieldNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; } }
FieldNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; } @Inject  FieldNamePolicy(@Nonnull JavaCodeStyleManager codeStyleManager); }
FieldNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; } @Inject  FieldNamePolicy(@Nonnull JavaCodeStyleManager codeStyleManager); @Nonnull @Override String convert(@Nonnull String name, @Nonnull TypeName type); }
FieldNamePolicy implements NamePolicy { @Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; } @Inject  FieldNamePolicy(@Nonnull JavaCodeStyleManager codeStyleManager); @Nonnull @Override String convert(@Nonnull String name, @Nonnull TypeName type);  }