aboutsummaryrefslogtreecommitdiff
path: root/src/jdiff/ConstructorAPI.java
blob: 7390a4df502c2c4e797ae780d36cb491a985a38f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package jdiff;

import java.io.*;
import java.util.*;

/** 
 * Class to represent a constructor, analogous to ConstructorDoc in the 
 * Javadoc doclet API. 
 *
 * The method used for Collection comparison (compareTo) must make its
 * comparison based upon everything that is known about this constructor.
 *
 * See the file LICENSE.txt for copyright details.
 * @author Matthew Doar, mdoar@pobox.com
 */
class ConstructorAPI implements Comparable {
    /** 
     * The type of the constructor, being all the parameter types
     * separated by commas.
     */
    public String type_ = null;
    
    /** 
     * The exceptions thrown by this constructor, being all the exception types
     * separated by commas. "no exceptions" if no exceptions are thrown.
     */
    public String exceptions_ = "no exceptions";
    
    /** Modifiers for this class. */
    public Modifiers modifiers_;

    /** The doc block, default is null. */
    public String doc_ = null;

    /** Constructor. */
    public ConstructorAPI(String type, Modifiers modifiers) {
        type_ = type;
        modifiers_ = modifiers;
    }

    /** Compare two ConstructorAPI objects by type and modifiers. */
    public int compareTo(Object o) {
        ConstructorAPI constructorAPI = (ConstructorAPI)o;
        int comp = type_.compareTo(constructorAPI.type_);
        if (comp != 0)
            return comp;
        comp = exceptions_.compareTo(constructorAPI.exceptions_);
        if (comp != 0)
            return comp;
        comp = modifiers_.compareTo(constructorAPI.modifiers_);
        if (comp != 0)
            return comp;
        if (APIComparator.docChanged(doc_, constructorAPI.doc_))
            return -1;
        return 0;
    }

    /** 
     * Tests two constructors, using just the type, used by indexOf(). 
     */
    public boolean equals(Object o) {
        if (type_.compareTo(((ConstructorAPI)o).type_) == 0)
            return true;
        return false;
    }
}