aboutsummaryrefslogtreecommitdiff
path: root/src/jdiff/ParamAPI.java
blob: 196a4b5e059c931b0f550d332e596a9a433726b0 (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
package jdiff;

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

/** 
 * Class to represent any (name, type) pair such as a parameter. 
 * Analogous to ParamType in the Javadoc doclet API. 
 *
 * The method used for Collection comparison (compareTo) must make its
 * comparison based upon everything that is known about this parameter.
 *
 * See the file LICENSE.txt for copyright details.
 * @author Matthew Doar, mdoar@pobox.com
 */
class ParamAPI implements Comparable {
    /** Name of the (name, type) pair. */
    public String name_;

    /** Type of the (name, type) pair. */
    public String type_;

    public ParamAPI(String name, String type) {
        name_ = name;
        type_ = type;
    }

    /** Compare two ParamAPI objects using both name and type. */
    public int compareTo(Object o) {
        ParamAPI oParamAPI = (ParamAPI)o;
        int comp = name_.compareTo(oParamAPI.name_);
        if (comp != 0)
            return comp;
        comp = type_.compareTo(oParamAPI.type_);
        if (comp != 0)
            return comp;
        return 0;
    }
  
    /** 
     * Tests two ParamAPI objects using just the name, used by indexOf().
     */
    public boolean equals(Object o) {
        if (name_.compareTo(((ParamAPI)o).name_) == 0)
            return true;
        return false;
    }
    
    /** Used to create signatures. */
    public String toString() {
        if (type_.compareTo("void") == 0)
            return "";
        return type_;
    }
}