001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
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 org.kuali.rice.krad.uif.component;
017
018import java.lang.annotation.Documented;
019import java.lang.annotation.ElementType;
020import java.lang.annotation.Retention;
021import java.lang.annotation.RetentionPolicy;
022import java.lang.annotation.Target;
023import java.util.List;
024
025import org.kuali.rice.krad.datadictionary.Copyable;
026import org.kuali.rice.krad.uif.util.LifecycleAwareList;
027
028/**
029 * Annotation for {@link Copyable} fields to indicate that a delayed copy proxy should be used
030 * instead of the original component when performing a deep copying on the field.
031 * 
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034@Target({ElementType.FIELD})
035@Retention(RetentionPolicy.RUNTIME)
036@Documented
037public @interface DelayedCopy {
038
039    /**
040     * May be used to indicate the presence of this annotation on the field referring to the object
041     * should be used to determine if this field should be delayed.
042     * 
043     * <p>
044     * For example, {@link LifecycleAwareList} is a delegating list wrapper and since it implements
045     * the {@link List} interface is treated as a {@link List} rather than a {@link Copyable} when
046     * performing a deep copy. The presence of {@DelayedCopy} with {@link #inherit()}
047     * set to true on the delegate indicates that the items in the delegated list should be delayed
048     * only if the undelegated list reference also has the {@link DelayedCopy} annotation.
049     * </p>
050     * 
051     * @return True if the parent field determines whether or not to delay copying the field, false
052     *         to always delay copy of the annotated field.
053     */
054    boolean inherit() default false;
055
056}