@Test public void testPackageNameComputation() { assertThat(Packages.getPackageName("foo/bar/Baz.class")).isEqualTo("foo.bar"); assertThat(Packages.getPackageName("foo/bar/Baz.java")).isEqualTo("foo.bar"); assertThat(Packages.getPackageName("Baz.class")).isEqualTo("."); }
public static String getPackageName(String filePath) { char sep = File.separatorChar; int n = filePath.lastIndexOf(sep); if (n == -1 && sep != '/') { sep = '/'; n = filePath.lastIndexOf(sep); } return n < 0 ? "." : filePath.substring(0, n).replace(sep, '.'); }
Packages { public static String getPackageName(String filePath) { char sep = File.separatorChar; int n = filePath.lastIndexOf(sep); if (n == -1 && sep != '/') { sep = '/'; n = filePath.lastIndexOf(sep); } return n < 0 ? "." : filePath.substring(0, n).replace(sep, '.'); } }
Packages { public static String getPackageName(String filePath) { char sep = File.separatorChar; int n = filePath.lastIndexOf(sep); if (n == -1 && sep != '/') { sep = '/'; n = filePath.lastIndexOf(sep); } return n < 0 ? "." : filePath.substring(0, n).replace(sep, '.'); } private  Packages(); }
Packages { public static String getPackageName(String filePath) { char sep = File.separatorChar; int n = filePath.lastIndexOf(sep); if (n == -1 && sep != '/') { sep = '/'; n = filePath.lastIndexOf(sep); } return n < 0 ? "." : filePath.substring(0, n).replace(sep, '.'); } private  Packages(); static String toClause(List<String> packages); static String getPackageName(String filePath); static boolean shouldBeExported(String packageName); }
Packages { public static String getPackageName(String filePath) { char sep = File.separatorChar; int n = filePath.lastIndexOf(sep); if (n == -1 && sep != '/') { sep = '/'; n = filePath.lastIndexOf(sep); } return n < 0 ? "." : filePath.substring(0, n).replace(sep, '.'); } private  Packages(); static String toClause(List<String> packages); static String getPackageName(String filePath); static boolean shouldBeExported(String packageName);  }