Search in sources :

Example 21 with CheckReturnValue

use of org.assertj.core.util.CheckReturnValue in project assertj-core by joel-costigliola.

the class AbstractDateAssert method usingComparator.

@Override
@CheckReturnValue
public SELF usingComparator(Comparator<? super Date> customComparator, String customComparatorDescription) {
    super.usingComparator(customComparator, customComparatorDescription);
    this.dates = new Dates(new ComparatorBasedComparisonStrategy(customComparator, customComparatorDescription));
    return myself;
}
Also used : Dates(org.assertj.core.internal.Dates) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) CheckReturnValue(org.assertj.core.util.CheckReturnValue)

Example 22 with CheckReturnValue

use of org.assertj.core.util.CheckReturnValue in project assertj-core by joel-costigliola.

the class AbstractDoubleAssert method usingComparator.

@Override
@CheckReturnValue
public SELF usingComparator(Comparator<? super Double> customComparator, String customComparatorDescription) {
    super.usingComparator(customComparator, customComparatorDescription);
    doubles = new Doubles(new ComparatorBasedComparisonStrategy(customComparator, customComparatorDescription));
    return myself;
}
Also used : Doubles(org.assertj.core.internal.Doubles) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) CheckReturnValue(org.assertj.core.util.CheckReturnValue)

Example 23 with CheckReturnValue

use of org.assertj.core.util.CheckReturnValue in project assertj-core by joel-costigliola.

the class AtomicLongAssert method usingComparator.

@Override
@CheckReturnValue
public AtomicLongAssert usingComparator(Comparator<? super AtomicLong> customComparator, String customComparatorDescription) {
    super.usingComparator(customComparator, customComparatorDescription);
    longs = new Longs(new ComparatorBasedComparisonStrategy(customComparator, customComparatorDescription));
    return myself;
}
Also used : Longs(org.assertj.core.internal.Longs) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) CheckReturnValue(org.assertj.core.util.CheckReturnValue)

Example 24 with CheckReturnValue

use of org.assertj.core.util.CheckReturnValue in project assertj-core by joel-costigliola.

the class AtomicReferenceArrayAssert method usingComparatorForType.

/**
 * Allows to set a specific comparator for the given type of elements or their fields.
 * Extends {@link #usingComparatorForElementFieldsWithType} by applying comparator specified for given type
 * to elements themselves, not only to their fields.
 * <p>
 * Usage of this method affects comparators set by next methods:
 * <ul>
 * <li>{@link #usingFieldByFieldElementComparator}</li>
 * <li>{@link #usingElementComparatorOnFields}</li>
 * <li>{@link #usingElementComparatorIgnoringFields}</li>
 * <li>{@link #usingRecursiveFieldByFieldElementComparator}</li>
 * </ul>
 * <p>
 * Example:
 * <pre><code class='java'> // assertion will pass
 * assertThat(new AtomicReferenceArray&lt;&gt;(new Object[] { "some", new BigDecimal("4.2") }))
 *       .usingComparatorForType(BIG_DECIMAL_COMPARATOR, BigDecimal.class)
 *       .contains(new BigDecimal("4.20"));
 * </code></pre>
 *
 * @param <C> the type to compare.
 * @param comparator the {@link java.util.Comparator} to use
 * @param type the {@link java.lang.Class} of the type of the element or element fields the comparator should be used for
 * @return {@code this} assertions object
 * @since 2.9.0 / 3.9.0
 */
@CheckReturnValue
public <C> AtomicReferenceArrayAssert<T> usingComparatorForType(Comparator<C> comparator, Class<C> type) {
    if (arrays.getComparator() == null) {
        usingElementComparator(new ExtendedByTypesComparator(getComparatorsByType()));
    }
    getComparatorsForElementPropertyOrFieldTypes().put(type, comparator);
    getComparatorsByType().put(type, comparator);
    return myself;
}
Also used : ExtendedByTypesComparator(org.assertj.core.internal.ExtendedByTypesComparator) CheckReturnValue(org.assertj.core.util.CheckReturnValue)

Aggregations

CheckReturnValue (org.assertj.core.util.CheckReturnValue)24 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)18 ExtendedByTypesComparator (org.assertj.core.internal.ExtendedByTypesComparator)3 Objects (org.assertj.core.internal.Objects)3 Tuple (org.assertj.core.groups.Tuple)2 Comparables (org.assertj.core.internal.Comparables)2 Integers (org.assertj.core.internal.Integers)2 Longs (org.assertj.core.internal.Longs)2 ObjectArrays (org.assertj.core.internal.ObjectArrays)2 AtomicReferenceArrayElementComparisonStrategy (org.assertj.core.internal.AtomicReferenceArrayElementComparisonStrategy)1 BigDecimals (org.assertj.core.internal.BigDecimals)1 BigIntegers (org.assertj.core.internal.BigIntegers)1 Bytes (org.assertj.core.internal.Bytes)1 Characters (org.assertj.core.internal.Characters)1 Dates (org.assertj.core.internal.Dates)1 Doubles (org.assertj.core.internal.Doubles)1 Floats (org.assertj.core.internal.Floats)1 IterableElementComparisonStrategy (org.assertj.core.internal.IterableElementComparisonStrategy)1 Iterables (org.assertj.core.internal.Iterables)1 Lists (org.assertj.core.internal.Lists)1