/**
 * PDDL Graph Planner
 * Zeyn Saigol <zeyn@zeyn.net>
 * School of Computer Science
 * University of Birmingham
 *
 * $Id: MethodDef.java 33 2007-02-23 15:45:34Z zas $
 */
package uk.ac.bham.cs.zas.pddl.domain;

import java.util.*;

/**
 * Basic definition of a predicate or function, as in the PDDL domain description.
 */
public abstract class MethodDef
{
    private final String name;
    private final List<FormalArgument> arguments;
    
    public MethodDef(String name, List<FormalArgument> arguments) {
        if (name == null) {
            throw new IllegalArgumentException("null name");
        }
        this.name = name;
        this.arguments = arguments;
    }

    public List<FormalArgument> getArguments() {
        return arguments;
    }

    public String getName() {
        return name;
    }
    
    public String toString() {
        //return getClass().getSimpleName() + ":" + name + arguments;
        return name + arguments;
    }
    
    @Override
    public int hashCode() {
        return name.hashCode();
    }
    
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof MethodDef)) {
            return false;
        }
        final MethodDef other = (MethodDef) obj;
        if (Domain.CASE_SENSITIVE) {
            return name.equals(other.name);
        } else {
            return name.equalsIgnoreCase(other.name);            
        }
    }
}