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

net.jqwik.api.SampleReportingFormat Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
package net.jqwik.api;

import java.util.*;

import org.apiguardian.api.*;

import static org.apiguardian.api.API.Status.*;

@API(status = MAINTAINED, since = "1.4.0")
public interface SampleReportingFormat extends Comparable {

	/**
	 * Use in {@linkplain SampleReportingFormat#report(Object)}
	 * if you just want to report a plain label and not a String in quotes.
	 *
	 * @param plain String to report
	 * @return an object that will be reported as a plain label
	 */
	static Object plainLabel(String plain) {
		return new Object() {
			@Override
			public String toString() {
				return plain;
			}
		};
	}

	/**
	 * @param value the value to format
	 * @return true if this format applies
	 */
	boolean appliesTo(Object value);

	/**
	 * Transform the value into one that will be handled by default mechanism,
	 * e.g. a Collection, a String, a Map.
	 *
	 * @param value the value to format
	 * @return the transformed value
	 */
	Object report(Object value);

	/**
	 * @param value the value to format
	 * @return an optional label prepended to a value's report
	 */
	default Optional label(Object value) {
		return Optional.empty();
	}

	/**
	 * @return priority with which to apply this format
	 */
	default int priority() {
		return 0;
	}

	@Override
	@API(status = INTERNAL)
	default int compareTo(SampleReportingFormat other) {
		return -Integer.compare(this.priority(), other.priority());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy