com.tngtech.jgiven.annotation.POJOFormat Maven / Gradle / Ivy
package com.tngtech.jgiven.annotation;
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.tngtech.jgiven.format.POJOAnnotationFormatter;
/**
* A special format annotation to format POJOs
* @since 0.15.0
*/
@Documented
@AnnotationFormat( value = POJOAnnotationFormatter.class )
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.PARAMETER, ElementType.ANNOTATION_TYPE } )
public @interface POJOFormat {
/**
* Enumeration of opening/closing brackets pair :
*
* - {@link #NONE} : no brackets
* - {@link #PARENTHESES} :
(...)
* - {@link #SQUARE} :
[...]
* - {@link #BRACES} :
{...}
* - {@link #POINTY} :
<...>
* - {@link #CHEVRONS} :
<<...>>
* - {@link #DOUBLE_QUOTE} :
"..."
* - {@link #SINGLE_QUOTE} :
'...'
*
*/
enum BracketsEnum {
NONE( "", "" ),
PARENTHESES( "(", ")" ),
SQUARE( "[", "]" ),
BRACES( "{", "}" ),
POINTY( "<", ">" ),
CHEVRONS( "<<", ">>" ),
DOUBLE_QUOTE( "\"", "\"" ),
SINGLE_QUOTE( "'", "'" ),
;
private String opening;
private String closing;
BracketsEnum( String opening, String closing ) {
this.opening = opening;
this.closing = closing;
}
public String getOpening() {
return opening;
}
public String getClosing() {
return closing;
}
}
/**
* Specifies which fields should be excluded in the report.
*
* If {@link #includeFields()} is set, then this attribute has no effect
*
*
*/
String[] excludeFields() default {};
/**
* Specifies which fields should be included in the report.
*
* All fields not in this list will be excluded.
*
*/
String[] includeFields() default {};
/**
* Whether or not columns with only {@code null} values are shown or not.
* Default is to not show them.
*
*/
boolean includeNullColumns() default false;
/**
* When set to true
, each formatted field value is prefixed by its field name
*/
boolean prefixWithFieldName() default false;
/**
* Specify a field separator
*/
String fieldSeparator() default ",";
/**
* Specify the opening/closing brackets pair to set POJO string representation apart of its parent (step) string representation.
*
*
* Default brackets pair is {@link BracketsEnum#SQUARE}.
* When no brackets is needed, consider specify {@link BracketsEnum#NONE}
*
*
* @See {@link BracketsEnum}
*/
BracketsEnum brackets() default BracketsEnum.SQUARE;
/**
* Specify a custom {@link NamedFormats} annotation
*
*
* The {@link NamedFormat} defined in this set will be used when formatting
* POJOs fields.
*
*
*/
Class extends Annotation> fieldFormatsAnnotation() default Annotation.class;
/**
* Specify an array of {@link NamedFormat} to use when formatting POJOs
* fields.
*
* When a {@link NamedFormat#name()} matches a field name, field value is
* formatted using this {@link NamedFormat}.
*
*
*
* Note: when set, has precedence over {@link #fieldFormatsAnnotation()}
*
*
* @See {@link #fieldFormatsAnnotation()}
*/
NamedFormat[] fieldFormats() default {};
}