ApkPackage { @NotNull public ApkClass addClass(@NotNull String name) { return myClassesByName.computeIfAbsent(name, s -> new ApkClass(name, this)); } ApkPackage(@NotNull String name, @Nullable ApkPackage parent); @NotNull Collection<ApkPackage> getSubpackages(); @Nullable ApkPackage findSubpackage(@NotNull String name); @NotNull Collection<ApkClass> getClasses(); @Nullable ApkClass findClass(@NotNull String name); @Nullable ApkPackage getParent(); @NotNull ApkPackage addSubpackage(@NotNull String name); @NotNull ApkClass addClass(@NotNull String name); @NotNull String getName(); @NotNull String getFqn(); boolean doSubpackagesHaveClasses(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void addClass() { ApkPackage aPackage = new ApkPackage("a", null); ApkClass xClass = aPackage.addClass("X"); assertEquals("X", xClass.getName()); assertEquals("a.X", xClass.getFqn()); assertSame(aPackage, xClass.getParent()); ApkPackage defaultPackage = new ApkPackage("", null); ApkClass yClass = defaultPackage.addClass("Y"); assertEquals("Y", yClass.getName()); assertEquals("Y", yClass.getFqn()); assertSame(defaultPackage, yClass.getParent()); }