@Test(expected = IllegalArgumentException.class) public void testCreateEmptyPackage() { JavaTypeName.create("", "Foo"); }
public static JavaTypeName create(final Class<?> clazz) { final Class<?> enclosing = clazz.getEnclosingClass(); if (enclosing != null) { return create(enclosing).createEnclosed(clazz.getSimpleName()); } final Package pkg = clazz.getPackage(); return pkg == null ? new Primitive(clazz.getSimpleName()) : new TopLevel(pkg.getName(), clazz.getSimpleName()); }
JavaTypeName implements Identifier, Immutable { public static JavaTypeName create(final Class<?> clazz) { final Class<?> enclosing = clazz.getEnclosingClass(); if (enclosing != null) { return create(enclosing).createEnclosed(clazz.getSimpleName()); } final Package pkg = clazz.getPackage(); return pkg == null ? new Primitive(clazz.getSimpleName()) : new TopLevel(pkg.getName(), clazz.getSimpleName()); } }
JavaTypeName implements Identifier, Immutable { public static JavaTypeName create(final Class<?> clazz) { final Class<?> enclosing = clazz.getEnclosingClass(); if (enclosing != null) { return create(enclosing).createEnclosed(clazz.getSimpleName()); } final Package pkg = clazz.getPackage(); return pkg == null ? new Primitive(clazz.getSimpleName()) : new TopLevel(pkg.getName(), clazz.getSimpleName()); } JavaTypeName(final String simpleName); }
JavaTypeName implements Identifier, Immutable { public static JavaTypeName create(final Class<?> clazz) { final Class<?> enclosing = clazz.getEnclosingClass(); if (enclosing != null) { return create(enclosing).createEnclosed(clazz.getSimpleName()); } final Package pkg = clazz.getPackage(); return pkg == null ? new Primitive(clazz.getSimpleName()) : new TopLevel(pkg.getName(), clazz.getSimpleName()); } JavaTypeName(final String simpleName); static JavaTypeName create(final Class<?> clazz); static JavaTypeName create(final String packageName, final String simpleName); abstract boolean canCreateEnclosed(String simpleName); abstract JavaTypeName createEnclosed(String simpleName); @SuppressWarnings("checkstyle:hiddenField") final JavaTypeName createEnclosed(final String simpleName, final String fallbackSuffix); abstract JavaTypeName createSibling(String simpleName); final String simpleName(); abstract String packageName(); abstract Optional<JavaTypeName> immediatelyEnclosingClass(); abstract JavaTypeName topLevelClass(); abstract String localName(); abstract List<String> localNameComponents(); @Override final int hashCode(); @Override final boolean equals(final @Nullable Object obj); @Override abstract String toString(); }
JavaTypeName implements Identifier, Immutable { public static JavaTypeName create(final Class<?> clazz) { final Class<?> enclosing = clazz.getEnclosingClass(); if (enclosing != null) { return create(enclosing).createEnclosed(clazz.getSimpleName()); } final Package pkg = clazz.getPackage(); return pkg == null ? new Primitive(clazz.getSimpleName()) : new TopLevel(pkg.getName(), clazz.getSimpleName()); } JavaTypeName(final String simpleName); static JavaTypeName create(final Class<?> clazz); static JavaTypeName create(final String packageName, final String simpleName); abstract boolean canCreateEnclosed(String simpleName); abstract JavaTypeName createEnclosed(String simpleName); @SuppressWarnings("checkstyle:hiddenField") final JavaTypeName createEnclosed(final String simpleName, final String fallbackSuffix); abstract JavaTypeName createSibling(String simpleName); final String simpleName(); abstract String packageName(); abstract Optional<JavaTypeName> immediatelyEnclosingClass(); abstract JavaTypeName topLevelClass(); abstract String localName(); abstract List<String> localNameComponents(); @Override final int hashCode(); @Override final boolean equals(final @Nullable Object obj); @Override abstract String toString();  }