001    package data;
002    
003    import java.io.Serializable;
004    
005    /**
006     * An objectified value.
007     *
008     * <p>Values are objects that understand the four basic operations <code>add</code>, <code>subtract</code>,
009             * <code>multiply</code> and <code>divide</code>. Additionally, they have an operation for multiplication with
010     * 'scalars', i.e. simple type numeric values. Values are commutative monoids with respect to addition and
011     * multiplication.</p>
012     *
013     * <p>An ordering relation is defined on the values, but it is up to the concrete type of value, whether this
014     * ordering is a half ordering relation.</p>
015     *
016     * @author Steffen Zschaler
017     * @version 2.0 19/08/1999
018     * @since v2.0
019     */
020    public interface Value extends Cloneable, Comparable, Serializable {
021    
022        /**
023         * Add the given value to this one, changing this value.
024         *
025         * @override Always
026         *
027         * @param v the value to be added.
028         */
029        public void addAccumulating(Value v);
030    
031        /**
032         * Subtract the given value from this one, changing this value.
033         *
034         * @override Always
035         *
036         * @param v the value to be subtracted.
037         */
038        public void subtractAccumulating(Value v);
039    
040        /**
041         * Multiply the given value by this one, changing this value.
042         *
043         * @override Always
044         *
045         * @param v the value to be multplied by.
046         */
047        public void multiplyAccumulating(Value v);
048    
049        /**
050         * Multiply this value by the given 'scalar', changing this value.
051         *
052         * @override Always
053         *
054         * @param dl the value by which to multiply.
055         */
056        public void multiplyAccumulating(double dl);
057    
058        /**
059         * Multiply this value by the given 'scalar', changing this value.
060         *
061         * @override Always
062         *
063         * @param fl the value by which to multiply.
064         */
065        public void multiplyAccumulating(float fl);
066    
067        /**
068         * Multiply this value by the given 'scalar', changing this value.
069         *
070         * @override Always
071         *
072         * @param l the value by which to multiply.
073         */
074        public void multiplyAccumulating(long l);
075    
076        /**
077         * Multiply this value by the given 'scalar', changing this value.
078         *
079         * @override Always
080         *
081         * @param n the value by which to multiply.
082         */
083        public void multiplyAccumulating(int n);
084    
085        /**
086         * Divide this value by the given one, changing this value.
087         *
088         * @override Always
089         *
090         * @param v the value by which to divide.
091         */
092        public void divideAccumulating(Value v);
093    
094        /**
095         * Add the given value to this one, and return the result.
096         *
097         * @override Always
098         *
099         * @param v the value to be added.
100         */
101        public Value add(Value v);
102    
103        /**
104         * Subtract the given value from this one, and return the result.
105         *
106         * @override Always
107         *
108         * @param v the value to be subtracted.
109         */
110        public Value subtract(Value v);
111    
112        /**
113         * Multiply this value by the given one, and return the result.
114         *
115         * @override Always
116         *
117         * @param v the value by which to multiply.
118         */
119        public Value multiply(Value v);
120    
121        /**
122         * Multiply this value by the given 'scalar', and return the result.
123         *
124         * @override Always
125         *
126         * @param dl the 'scalar' by which to multiply.
127         */
128        public Value multiply(double dl);
129    
130        /**
131         * Multiply this value by the given 'scalar', and return the result.
132         *
133         * @override Always
134         *
135         * @param fl the 'scalar' by which to multiply.
136         */
137        public Value multiply(float fl);
138    
139        /**
140         * Multiply this value by the given 'scalar', and return the result.
141         *
142         * @override Always
143         *
144         * @param l the 'scalar' by which to multiply.
145         */
146        public Value multiply(long l);
147    
148        /**
149         * Multiply this value by the given 'scalar', and return the result.
150         *
151         * @override Always
152         *
153         * @param n the 'scalar' by which to multiply.
154         */
155        public Value multiply(int n);
156    
157        /**
158         * Divide this value by the given one, and return the result.
159         *
160         * @override Always
161         *
162         * @param v the value by which to divide.
163         */
164        public Value divide(Value v);
165    
166        /**
167         * Check whether this is the zero element with respect to addition.
168         *
169         * @override Always
170         *
171         * @return true if this is the zero element with respect to addition, i.e. if for any value <code>v</code>:
172         * <code>(v.getClass() == this.getClass()) -> ((v.add (this).equals (v)) && (this.add (v).equals (v)))</code>.
173         */
174        public boolean isAddZero();
175    
176        /**
177         * Check whether this is the zero element with respect to multiplication.
178         *
179         * @override Always
180         *
181         * @return true if this is the zero element with respect to multiplication, i.e. if for any value <code>v</code>:
182         * <code>(v.getClass() == this.getClass()) -> ((v.multiply (this).equals (this)) && (this.multiply (v).equals (this)))</code>.
183         */
184        public boolean isMulZero();
185    
186        /**
187         * Check whether this is the one element with respect to multiplication.
188         *
189         * @override Always
190         *
191         * @return true if this is the one element with respect to multiplication, i.e. if for any value <code>v</code>:
192         * <code>(v.getClass() == this.getClass()) -> ((v.multiply (this).equals (v)) && (this.multiply (v).equals (v)))</code>.
193         */
194        public boolean isMulOne();
195    
196        /**
197         * Clone this value.
198         *
199         * @override Always
200         */
201        public Object clone();
202    }