All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.exparity.hamcrest.BeanComparators Maven / Gradle / Ivy

package org.exparity.hamcrest;

import java.util.Date;

import org.exparity.hamcrest.beans.TheSameAs.PropertyComparator;
import org.exparity.hamcrest.beans.comparators.Excluded;
import org.exparity.hamcrest.beans.comparators.Matches;
import org.exparity.hamcrest.beans.comparators.HasPattern;
import org.exparity.hamcrest.beans.comparators.IsComparable;
import org.exparity.hamcrest.beans.comparators.IsEqual;
import org.exparity.hamcrest.beans.comparators.IsEqualDate;
import org.exparity.hamcrest.beans.comparators.IsEqualDateTime;
import org.exparity.hamcrest.beans.comparators.IsEqualIgnoreCase;
import org.exparity.hamcrest.beans.comparators.IsEqualTimestamp;
import org.hamcrest.Matcher;

/**
 * Static repository of {@link PropertyComparator} for use with
 * {@link BeanMatchers}
 * 
 * @author Stewart Bissett
 */
public abstract class BeanComparators {

	/**
	 * Exclude the property, type, or path from comparison
	 */
	public static  PropertyComparator exclude(final Class type) {
		return new Excluded();
	}

	/**
	 * Match the property, type, or path with a hamcrest matcher
	 */
	public static  PropertyComparator matches(final Matcher matcher) {
		return new Matches(matcher);
	}

	/**
	 * Match the String property, type, or path against a regular expression
	 */
	public static PropertyComparator hasPattern(final String pattern) {
		return new HasPattern(pattern);
	}

	/**
	 * Match the property, type, or path using their comparison method
	 */
	public static > PropertyComparator isComparable(final Class type) {
		return new IsComparable();
	}

	/**
	 * Match the property, type, or path using their equals method
	 */
	public static  PropertyComparator isEqual(final Class type) {
		return new IsEqual();
	}

	/**
	 * Match the String property, type, or path using their equalsIgnoreCase
	 * method
	 */
	public static PropertyComparator isEqualIgnoreCase() {
		return new IsEqualIgnoreCase();
	}

	/**
	 * Match the Date property, type, or path using by the date and time portion
	 * with no millisecond
	 */
	public static PropertyComparator isEqualDateTime() {
		return new IsEqualDateTime();
	}

	/**
	 * Match the Date property, type, or path using by the date and no time
	 * portion
	 */
	public static PropertyComparator isEqualDate() {
		return new IsEqualDate();
	}

	/**
	 * Match the Date property, type, or path by comparing as dates down to the millisecond
	 */
	public static PropertyComparator isEqualTimestamp() {
		return new IsEqualTimestamp();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy