Package uk.me.nxg.unity

# Class FunctionDefinition

java.lang.Object
uk.me.nxg.unity.FunctionDefinition

All Implemented Interfaces:
  `Comparable<FunctionDefinition>`

public class FunctionDefinition extends Object implements Comparable<FunctionDefinition>
Describes a ‘known’' function. Functions take a single unit as argument.

There are no syntax variations, beyond the set of functions which are recommended.

## Method Summary

Modifier and Type
Method
Description
`int`
`compareTo(FunctionDefinition o)`
Provides a sorting order for definitions.
`String`
`description()`
A human-readable description of the function.
`boolean`
`equals(Object o)`
`String`
`fallbackName()`
A fallback name for the function.
`int`
`hashCode()`
`String`
`latexForm()`
A LaTeX form of the function name.
`String`
`name()`
The name of this function, or null.
`String`
`toString()`
Produces a representation of this function as a string.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Method Details

### description

public String description()
A human-readable description of the function.

Returns:
  a string description

### latexForm

public String latexForm()
A LaTeX form of the function name.

Returns:
  a LaTeX representation of the function

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()
Produces a representation of this function as a string. This should not generally be used for formatting expressions: for that, use `UnitExpr.toString()`.

Overrides:
  `toString` in class `Object`
Returns:
  a string representation of the function

### name

public String name()
The name of this function, or null. The response will be null if the function definition doesn't have enough syntax information to know what the function is called in a given syntax. The syntax in question is that associated with the function when it was parsed, which may not, of course, be the syntax associated with it when it is written.

Returns:
  a null string

### fallbackName

public String fallbackName()
A fallback name for the function.

In fact, this is (a) only necessary for debugging purposes, because usually the overridden name() function will work, and (b) it is always (?) the same as the string eventually returned from name(), because (at present) all of the functions have the same short names in those syntaxes which know about them. This may be unnecessary generality (YAGNI, and all that), but it's essentially here for symmetry with the UnitDefinition lookup process, here and in ParseFunctions.java

Returns:
  a purely text representation of the function

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### compareTo

public int compareTo(FunctionDefinition o)
Provides a sorting order for definitions. The order is well-defined but is not specified here.

Specified by:
  `compareTo` in interface `Comparable<FunctionDefinition>`