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.contracts; 017 018import java.lang.annotation.ElementType; 019import java.lang.annotation.Retention; 020import java.lang.annotation.RetentionPolicy; 021import java.lang.annotation.Target; 022 023/** 024 * If used on ValueObjectTest this test verifies a copy-constructor. Depending 025 * on its configuration it tests the individual properties to be copied 026 * correctly and of course the {@link Object#equals(Object)} method, see 027 * {@link #useObjectEquals()}. It can only be used if at least one other 028 * verification contract is there. 029 * 030 * @author Oliver Wolff 031 */ 032@Retention(RetentionPolicy.RUNTIME) 033@Target({ ElementType.TYPE }) 034public @interface VerifyCopyConstructor { 035 036 /** 037 * @return an array of properties, identified by their names that are not to be 038 * considered for this test: black-list 039 */ 040 String[] exclude() default {}; 041 042 /** 043 * @return an array of properties, identified by their names that are to be 044 * considered for this test: white-list 045 */ 046 String[] of() default {}; 047 048 /** 049 * @return the actual type needed for the copy-constructor. It is only needed if 050 * it differs from the type of the bean under test. 051 * {@link VerifyCopyConstructor} acts as {@code null} value 052 */ 053 Class<?> argumentType() default VerifyCopyConstructor.class; 054 055 /** 056 * @return boolean indicating whether to {@link Object#equals(Object)} as well, 057 * defaults to {@code true} 058 */ 059 boolean useObjectEquals() default true; 060 061 /** 062 * @return boolean indicating whether to implicitly check whether the copy is a 063 * deep instead of a shallow copy, defaults to {@code true}. See 064 * {@link #verifyDeepCopyIgnore()} as well 065 */ 066 boolean verifyDeepCopy() default false; 067 068 /** 069 * @return an array of properties, identified by their names that are to be 070 * ignored by checking the deep copy, see {@link #verifyDeepCopy()} 071 */ 072 String[] verifyDeepCopyIgnore() default {}; 073}