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 the original author or authors.
015 */
016 package org.fest.assertions;
017
018 /**
019 * Understands a finite increment in a variable.
020 * @since 1.1
021 *
022 * @author Alex Ruiz
023 */
024 public final class Delta {
025
026 /**
027 * Creates a new <code>{@link Delta}</code>.
028 * @param value the value of the delta.
029 * @return the created <code>Delta</code>.
030 */
031 public static Delta delta(double value) {
032 return new Delta(value);
033 }
034
035 /**
036 * Creates a new <code>{@link Delta}</code>.
037 * @param value the value of the delta.
038 * @return the created <code>Delta</code>.
039 */
040 public static Delta delta(float value) {
041 return new Delta(value);
042 }
043
044 private final Double value;
045
046 private Delta(double value) {
047 this.value = value;
048 }
049
050 /**
051 * Returns the value of this delta.
052 * @return the value of this delta.
053 * @deprecated use <code>{@link #doubleValue()}</code> instead.
054 */
055 @Deprecated
056 public double value() {
057 return doubleValue();
058 }
059
060 /**
061 * Returns the value of this delta as a <code>double</code>.
062 * @return the value of this delta as a <code>double</code>.
063 * @since 1.2
064 */
065 public double doubleValue() {
066 return value.doubleValue();
067 }
068
069 /**
070 * Returns the value of this delta as a <code>float</code>.
071 * @return the value of this delta as a <code>float</code>.
072 * @since 1.2
073 */
074 public float floatValue() {
075 return value.floatValue();
076 }
077 }