@Test public void shouldThrowForNonDataenumClassName() throws Exception { assertThatThrownBy( () -> OutputSpecFactory.toOutputClassName(ClassName.get("com.spotify", "My"))) .isInstanceOf(ParserException.class) .hasMessageContaining("Bad name"); }
static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); }
OutputSpecFactory { static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); } }
OutputSpecFactory { static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); } private  OutputSpecFactory(); }
OutputSpecFactory { static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); } private  OutputSpecFactory(); static OutputSpec create(Spec spec); }
OutputSpecFactory { static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); } private  OutputSpecFactory(); static OutputSpec create(Spec spec);  }