de.rwth.domains.templates
Class ConstantFunction
java.lang.Object
|
+--de.rwth.domains.templates.ConstantFunction
- All Implemented Interfaces:
- Function
- public class ConstantFunction
- extends java.lang.Object
- implements Function
Implements functions with a constant value.
- Version:
- $Id: ConstantFunction.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
- Author:
- Markus Mohnen
Field Summary |
protected Set |
domain
The domain of this constant function. |
protected Set |
range
The range of this constant function. |
protected java.lang.Object |
value
The constant value of this function. |
Constructor Summary |
ConstantFunction(Set domain,
Set range,
java.lang.Object value)
Creates a new ConstantFunction instance. |
Method Summary |
java.lang.Object |
apply(java.lang.Object arg)
Applies this function to an argument and returns the result. |
boolean |
equals(java.lang.Object o)
|
Set |
getDomain()
Returns the domain of this function. |
Set |
getRange()
Returns the range (co-domain) of this function. |
static void |
main(java.lang.String[] args)
Mini test environment. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
domain
protected Set domain
- The domain of this constant function.
range
protected Set range
- The range of this constant function.
value
protected java.lang.Object value
- The constant value of this function.
ConstantFunction
public ConstantFunction(Set domain,
Set range,
java.lang.Object value)
throws java.lang.IllegalArgumentException
- Creates a new
ConstantFunction
instance.
- Parameters:
domain
- a Set
value: The domain.range
- a Set
value: The range.value
- an Object
value: The value- Throws:
java.lang.IllegalArgumentException
- if value
is not an element of
domain
.
getDomain
public Set getDomain()
- Description copied from interface:
Function
- Returns the domain of this function.
- Specified by:
getDomain
in interface Function
- Following copied from interface:
de.rwth.domains.Function
- Returns:
- a value of type
Set
getRange
public Set getRange()
- Description copied from interface:
Function
- Returns the range (co-domain) of this function.
- Specified by:
getRange
in interface Function
- Following copied from interface:
de.rwth.domains.Function
- Returns:
- a value of type
Set
apply
public java.lang.Object apply(java.lang.Object arg)
- Description copied from interface:
Function
- Applies this function to an argument and returns the result.
- Specified by:
apply
in interface Function
- Following copied from interface:
de.rwth.domains.Function
- Parameters:
x
- the argument- Returns:
- this function's value for argument
x
- Throws:
FunctionException
- if x
is not
an element of the
functions domain.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in class java.lang.Object
main
public static void main(java.lang.String[] args)
- Mini test environment.
- Parameters:
args
- a String[]
value