ByteCodeUtils { @NonNull public static Optional<String> getPackageName(@NonNull String internalName) { List<String> parts = Splitter.on('/').splitToList(internalName); if (parts.size() == 1) { return Optional.empty(); } return Optional.of(Joiner.on('.').join(parts.subList(0, parts.size() - 1))); }  static void unbox(GeneratorAdapter mv, Type type); static String textify(@NonNull MethodNode method); @NonNull static String toInternalName(@NonNull String className); @NonNull static String getClassName(@NonNull String memberName); @NonNull static Optional<String> getPackageName(@NonNull String internalName); static final String CONSTRUCTOR; static final String CLASS_INITIALIZER; }
@Test public void testGetPackageName() throws Exception { assertThat(ByteCodeUtils.getPackageName("foo/bar/Baz")).isEqualTo(Optional.of("foo.bar")); assertThat(ByteCodeUtils.getPackageName("Baz")).isEqualTo(Optional.empty()); }