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.valueobjects.property.PropertyMetadata;
026import de.cuioss.test.valueobjects.property.util.PropertyAccessStrategy;
027
028/**
029 * While the test classes are capable of auto-detecting JavaProperties you need
030 * to adjust them from time to time. With this annotation you can do this for
031 * builder specific properties. This annotation can only adjust an already
032 * existing {@link PropertyMetadata} and can not be used stand-alone
033 *
034 * @author Oliver Wolff
035 */
036@Retention(RUNTIME)
037@Target(TYPE)
038@Repeatable(PropertyBuilderConfigs.class)
039public @interface PropertyBuilderConfig {
040
041    /**
042     * @return the name of the property. Must not null nor empty. Must refer to an
043     *         already existing {@link PropertyMetadata}
044     */
045    String name();
046
047    /**
048     * Defines different ways for reading / writing properties.
049     *
050     * @return the {@link PropertyAccessStrategy}, defaults to
051     *         {@link PropertyAccessStrategy#BUILDER_DIRECT}
052     */
053    PropertyAccessStrategy propertyAccessStrategy() default PropertyAccessStrategy.BUILDER_DIRECT;
054
055    /**
056     * In case methodPrefix is not set the corresponding build method to be accessed
057     * for setting the value is the name of the attribute: propertyName(), in case
058     * it is a concrete value, e.g. 'with' it will taken into account:
059     * withPropertName().
060     *
061     * @return the method prefix, defaults to empty string
062     */
063    String methodPrefix() default "";
064
065    /**
066     * In case this builderMethodName is set it will be used directly for deriving
067     * the write-method.
068     *
069     * @return builderMethodName, defaults to empty string
070     */
071    String builderMethodName() default "";
072
073    /**
074     * Only needed for builder that deal with {@link Iterable} and single elements,
075     * see {@link PropertyAccessStrategy#BUILDER_COLLECTION_AND_SINGLE_ELEMENT} for
076     * details
077     *
078     * @return builderSingleAddMethodName, defaults to empty string
079     */
080    String builderSingleAddMethodName() default "";
081}