001    /*
002     * Created on Mar 30, 2009
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the License
010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011     * or implied. See the License for the specific language governing permissions and limitations under
012     * the License.
013     *
014     * Copyright @2009-2011 the original author or authors.
015     */
016    package org.fest.assertions;
017    
018    /**
019     * A finite increment in a variable.
020     *
021     * @author Alex Ruiz
022     *
023     * @since 1.1
024     */
025    public final class Delta {
026    
027      /**
028       * Creates a new <code>{@link Delta}</code>.
029       * @param value the value of the delta.
030       * @return the created <code>Delta</code>.
031       */
032      public static Delta delta(double value) {
033        return new Delta(value);
034      }
035    
036      /**
037       * Creates a new <code>{@link Delta}</code>.
038       * @param value the value of the delta.
039       * @return the created <code>Delta</code>.
040       */
041      public static Delta delta(float value) {
042        return new Delta(value);
043      }
044    
045      private final Double value;
046    
047      private Delta(double value) {
048        this.value = value;
049      }
050    
051      /**
052       * Returns the value of this delta.
053       * @return the value of this delta.
054       * @deprecated use <code>{@link #doubleValue()}</code> instead.
055       */
056      @Deprecated
057      public double value() {
058        return doubleValue();
059      }
060    
061      /**
062       * Returns the value of this delta as a {@code double}.
063       * @return the value of this delta as a {@code double}.
064       * @since 1.2
065       */
066      public double doubleValue() {
067        return value.doubleValue();
068      }
069    
070      /**
071       * Returns the value of this delta as a {@code float}.
072       * @return the value of this delta as a {@code float}.
073       * @since 1.2
074       */
075      public float floatValue() {
076        return value.floatValue();
077      }
078    }