001/* 002 * Copyright 2023 the original author or authors. 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.test.valueobjects.api.property; 017 018import static java.lang.annotation.ElementType.TYPE; 019import static java.lang.annotation.RetentionPolicy.RUNTIME; 020 021import java.lang.annotation.Repeatable; 022import java.lang.annotation.Retention; 023import java.lang.annotation.Target; 024 025import de.cuioss.test.generator.TypedGenerator; 026import de.cuioss.test.valueobjects.generator.dynamic.DynamicTypedGenerator; 027import de.cuioss.test.valueobjects.property.PropertyMetadata; 028import de.cuioss.test.valueobjects.property.util.AssertionStrategy; 029import de.cuioss.test.valueobjects.property.util.CollectionType; 030import de.cuioss.test.valueobjects.property.util.PropertyAccessStrategy; 031import de.cuioss.tools.property.PropertyMemberInfo; 032import de.cuioss.tools.property.PropertyReadWrite; 033 034/** 035 * While the test classes are capable of auto-detecting JavaProperties you need 036 * to adjust them from time to time. With this annotation you can do this. 037 * 038 * @author Oliver Wolff 039 */ 040@Retention(RUNTIME) 041@Target(TYPE) 042@Repeatable(PropertyConfigs.class) 043public @interface PropertyConfig { 044 045 /** 046 * Identifies the name of the property 047 * 048 * @return the actual name of the property, must never be null nor empty 049 * @see {@link PropertyMetadata#getName()}. 050 */ 051 String name(); 052 053 /** 054 * @return the type of the property. This can either be the actual type, in case 055 * {@link PropertyMetadata#getCollectionType()} is 056 * {@link CollectionType#NO_ITERABLE}, the component-type in case of 057 * {@link CollectionType#ARRAY_MARKER} or the type argument for a 058 * collection for the other {@link CollectionType}s, see 059 * {@link PropertyMetadata#next()} and 060 * {@link PropertyMetadata#resolveActualClass()} 061 * @see {@link PropertyMetadata#getPropertyClass()}. 062 */ 063 Class<?> propertyClass(); 064 065 /** 066 * @return the wrapped {@link TypedGenerator} to dynamically create properties. 067 * If it is not set {@link DynamicTypedGenerator} will be chosen 068 * @see {@link PropertyMetadata#getGenerator()}. 069 */ 070 @SuppressWarnings("rawtypes") 071 Class<? extends TypedGenerator> generator() default DynamicTypedGenerator.class; 072 073 /** 074 * @return boolean indicating whether the property defines a default value, 075 * defaults to false 076 * @see {@link PropertyMetadata#isDefaultValue()}. 077 */ 078 boolean defaultValue() default false; 079 080 /** 081 * @return boolean indicating whether the given property is required, defaults 082 * to false 083 * @see {@link PropertyMetadata#isRequired()}. 084 */ 085 boolean required() default false; 086 087 /** 088 * @return The {@link PropertyMemberInfo}, defaults to 089 * {@link PropertyMemberInfo#DEFAULT} 090 * @see {@link PropertyMetadata#getPropertyMemberInfo()}. 091 */ 092 PropertyMemberInfo propertyMemberInfo() default PropertyMemberInfo.DEFAULT; 093 094 /** 095 * In case there is a collectionType defined the generated values will 096 * implicitly wrapped in the corresponding collection class defined by that 097 * wrapper, defaults to {@link CollectionType#NO_ITERABLE}. 098 * 099 * @return the {@link CollectionType} 100 * @see {@link PropertyMetadata#getCollectionType()}. 101 */ 102 CollectionType collectionType() default CollectionType.NO_ITERABLE; 103 104 /** 105 * @return whether the property can be read or written, default to 106 * {@link PropertyReadWrite#READ_WRITE} 107 * @see {@link PropertyMetadata#getPropertyReadWrite()}. 108 */ 109 PropertyReadWrite propertyReadWrite() default PropertyReadWrite.READ_WRITE; 110 111 /** 112 * Defines different ways for reading / writing properties. 113 * 114 * @return the {@link PropertyAccessStrategy}, defaults to 115 * {@link PropertyAccessStrategy#BEAN_PROPERTY} 116 * @see {@link PropertyMetadata#getPropertyAccessStrategy()}. 117 */ 118 PropertyAccessStrategy propertyAccessStrategy() default PropertyAccessStrategy.BEAN_PROPERTY; 119 120 /** 121 * Defines the the way how to deal with equality regarding 122 * PropertySupport.assertValueSet(Object) 123 * 124 * @return the {@link AssertionStrategy}, defaults to 125 * {@link AssertionStrategy#DEFAULT} 126 */ 127 AssertionStrategy assertionStrategy() default AssertionStrategy.DEFAULT; 128}