Class DefaultJavaPackage

All Implemented Interfaces:
JavaAnnotatedElement, JavaModel, JavaPackage, Serializable

public class DefaultJavaPackage extends AbstractBaseJavaEntity implements JavaPackage
The default implementation of JavaPackage, representing a Package.
Since:
1.9
See Also:
  • Field Details

  • Constructor Details

    • DefaultJavaPackage

      public DefaultJavaPackage(String name)
      Parameters:
      name - the name of the package, should never be null
  • Method Details

    • getName

      public String getName()
      Equivalent of Package.getName()
      Specified by:
      getName in interface JavaPackage
      Returns:
      the name, should never be null
    • setName

      public void setName(String name)
    • getCodeBlock

      public String getCodeBlock()
      Specified by:
      getCodeBlock in interface JavaModel
      Returns:
      the codeblock
    • setClassLibrary

      public void setClassLibrary(ClassLibrary classLibrary)
    • getJavaClassLibrary

      public ClassLibrary getJavaClassLibrary()
      The ClassLibrary of this package.
      Specified by:
      getJavaClassLibrary in interface JavaPackage
      Returns:
      the classLibrary, should never be null
    • addClass

      public void addClass(JavaClass clazz)
    • getClasses

      public Collection<JavaClass> getClasses()
      Returns all the classes found for the package.
      Specified by:
      getClasses in interface JavaPackage
      Returns:
      all the classes found for the package, never null
    • getClassByName

      public JavaClass getClassByName(String name)
      Try to get any class of this package by name. The name can be both the fully qualified name or just the name of the class.
      Specified by:
      getClassByName in interface JavaPackage
      Parameters:
      name - the (fully qualified) name of the class
      Returns:
      the matching class, otherwise null
    • getParentPackage

      public JavaPackage getParentPackage()
      The parent of this package For instance: the package of java.lang.reflect is java.lang
      Specified by:
      getParentPackage in interface JavaPackage
      Returns:
      the parent package, otherwise null
    • getSubPackages

      public List<JavaPackage> getSubPackages()
      For instance: one of the children of java.lang would be java.lang.reflect
      Specified by:
      getSubPackages in interface JavaPackage
      Returns:
      all the children of this package , never null
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Description copied from interface: JavaPackage
      Equivalent of Package.toString()
      Specified by:
      toString in interface JavaPackage
      Overrides:
      toString in class Object
      Returns:
      the string representation of the package.