PackageUtils { public static String getShortenPackage(Class<?> clazz) { return getShortenPackage(clazz.getName()); } private  PackageUtils(); static String getShortenPackage(Class<?> clazz); static String getShortenPackage(String pack); static @Nullable String getPackageName(Class<?> clazz); static String toString(@Nullable Package pack, @Nullable String defaultValue); static @Nullable String toString(@Nullable Package pkg);  }
@Test void getShortenPackage() { Assertions.assertEquals("j.l.String", PackageUtils.getShortenPackage(String.class)); Assertions.assertEquals("j.l.String", PackageUtils.getShortenPackage(String.class.getName())); Assertions.assertEquals("j.lang", PackageUtils.getShortenPackage(String.class.getPackage().getName())); }