org.hibernate.testing.hamcrest.CollectionEmptinessMatcher Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of hibernate-testing Show documentation
                Show all versions of hibernate-testing Show documentation
Support for testing Hibernate ORM functionality
                
             The newest version!
        
        /*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate.testing.hamcrest;
import java.util.Collection;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
/**
 * @author Steve Ebersole
 */
public class CollectionEmptinessMatcher extends BaseMatcher {
	private final boolean emptyIsMatch;
	public CollectionEmptinessMatcher(boolean emptyIsMatch) {
		this.emptyIsMatch = emptyIsMatch;
	}
	@Override
	public boolean matches(Object item) {
		if ( emptyIsMatch ) {
			return ( (Collection) item ).isEmpty();
		}
		else {
			return ! ( (Collection) item ).isEmpty();
		}
	}
	@Override
	public void describeTo(Description description) {
		if ( emptyIsMatch ) {
			description.appendText( "" );
		}
		else {
			description.appendText( "" );
		}
	}
}
       © 2015 - 2025 Weber Informatics LLC | Privacy Policy