Package uk.me.nxg.unity
Class FunctionDefinition
- java.lang.Object
-
- uk.me.nxg.unity.FunctionDefinition
-
- All Implemented Interfaces:
java.lang.Comparable<FunctionDefinition>
public class FunctionDefinition extends java.lang.Object implements java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(FunctionDefinition o)Provides a sorting order for definitions.java.lang.Stringdescription()A human-readable description of the function.booleanequals(java.lang.Object o)java.lang.StringfallbackName()A fallback name for the function.inthashCode()java.lang.StringlatexForm()A LaTeX form of the function name.java.lang.Stringname()The name of this function, or null.java.lang.StringtoString()Produces a representation of this function as a string.
-
-
-
Method Detail
-
description
public java.lang.String description()
A human-readable description of the function.- Returns:
- a string description
-
latexForm
public java.lang.String latexForm()
A LaTeX form of the function name.- Returns:
- a LaTeX representation of the function
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Produces a representation of this function as a string. This should not generally be used for formatting expressions: for that, useUnitExpr.toString().- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the function
-
name
public java.lang.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 java.lang.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(java.lang.Object o)
- Overrides:
equalsin classjava.lang.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:
compareToin interfacejava.lang.Comparable<FunctionDefinition>
-
-