Home | History | Annotate | Download | only in jdiff
      1 package jdiff;
      2 
      3 import java.io.*;
      4 import java.util.*;
      5 
      6 /**
      7  * Class to represent a package, analogous to PackageDoc in the
      8  * Javadoc doclet API.
      9  *
     10  * The method used for Collection comparison (compareTo) must make its
     11  * comparison based upon everything that is known about this package.
     12  *
     13  * See the file LICENSE.txt for copyright details.
     14  * @author Matthew Doar, mdoar (at) pobox.com
     15  */
     16 class PackageAPI implements Comparable<PackageAPI> {
     17 
     18     /** Full qualified name of the package. */
     19     public String name_;
     20 
     21     /** Classes within this package. */
     22     public final List<ClassAPI> classes_ = new ArrayList<>();
     23 
     24     /** The doc block, default is null. */
     25     public String doc_ = null;
     26 
     27     /** Constructor. */
     28     public PackageAPI(String name) {
     29         name_ = name;
     30     }
     31 
     32     /** Compare two PackageAPI objects by name. */
     33     public int compareTo(PackageAPI o) {
     34         PackageAPI oPackageAPI = (PackageAPI)o;
     35         if (APIComparator.docChanged(doc_, oPackageAPI.doc_))
     36             return -1;
     37         return name_.compareTo(oPackageAPI.name_);
     38     }
     39 
     40     /**
     41      * Tests two packages, using just the package name, used by indexOf().
     42      */
     43     public boolean equals(Object o) {
     44         if (name_.compareTo(((PackageAPI)o).name_) == 0)
     45             return true;
     46         return false;
     47     }
     48 }
     49