001 /* 002 * Created on Feb 8, 2011 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 005 * 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 is distributed on 010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 011 * specific language governing permissions and limitations under the License. 012 * 013 * Copyright @2011 the original author or authors. 014 */ 015 package org.fest.assertions.api; 016 017 import java.math.BigDecimal; 018 import java.util.Comparator; 019 020 import org.fest.assertions.core.NumberAssert; 021 import org.fest.assertions.internal.BigDecimals; 022 import org.fest.util.*; 023 024 /** 025 * Assertion methods for <code>{@link BigDecimal}</code>s. 026 * <p> 027 * To create an instance of this class, invoke <code>{@link Assertions#assertThat(BigDecimal)}</code>. 028 * </p> 029 * 030 * @author David DIDIER 031 * @author Ted M. Young 032 * @author Yvonne Wang 033 * @author Alex Ruiz 034 * @author Joel Costigliola 035 */ 036 public class BigDecimalAssert extends AbstractUnevenComparableAssert<BigDecimalAssert, BigDecimal> implements 037 NumberAssert<BigDecimal> { 038 039 @VisibleForTesting BigDecimals bigDecimals = BigDecimals.instance(); 040 041 protected BigDecimalAssert(BigDecimal actual) { 042 super(actual, BigDecimalAssert.class); 043 } 044 045 /** {@inheritDoc} */ 046 public BigDecimalAssert isZero() { 047 bigDecimals.assertIsZero(info, actual); 048 return myself; 049 } 050 051 /** {@inheritDoc} */ 052 public BigDecimalAssert isNotZero() { 053 bigDecimals.assertIsNotZero(info, actual); 054 return myself; 055 } 056 057 /** {@inheritDoc} */ 058 public BigDecimalAssert isPositive() { 059 bigDecimals.assertIsPositive(info, actual); 060 return myself; 061 } 062 063 /** {@inheritDoc} */ 064 public BigDecimalAssert isNegative() { 065 bigDecimals.assertIsNegative(info, actual); 066 return myself; 067 } 068 069 @Override 070 public BigDecimalAssert usingComparator(Comparator<?> customComparator) { 071 super.usingComparator(customComparator); 072 this.bigDecimals = new BigDecimals(new ComparatorBasedComparisonStrategy(customComparator)); 073 return myself; 074 } 075 076 @Override 077 public BigDecimalAssert usingDefaultComparator() { 078 super.usingDefaultComparator(); 079 this.bigDecimals = BigDecimals.instance(); 080 return myself; 081 } 082 }