001/**
002 * Copyright 2005-2016 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.data.provider.annotation;
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;
023
024import org.kuali.rice.krad.data.metadata.DataObjectCollection;
025
026/**
027 * Defines that the associated Collection field contains a collection of DataObjects.
028 *
029 * <p>Analog to the {@link DataObjectCollection} metadata.</p>
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033@Target(ElementType.FIELD)
034@Retention(RetentionPolicy.RUNTIME)
035@Documented
036public @interface CollectionRelationship {
037        /**
038         * The element type of the collection.
039     *
040     * <p>If the collection contains Generics, it will be derived automatically.</p>
041     *
042     * @return the element type of the collection.
043         */
044        Class<?> collectionElementClass() default Object.class;
045
046        /**
047         * The list of attribute relationships linking the parent object and the collection objects.
048     *
049     * @return list of attribute relationships linking the parent object and the collection objects.
050         */
051        AttributeRelationship[] attributeRelationships();
052
053        /**
054         * The default sort order for the collection.
055     *
056     * @return the default sort order for the collection.
057         */
058        CollectionSortAttribute[] sortAttributes() default {};
059
060    /**
061     * The minimum items that can appear in the collection.
062     *
063     * @return lhe minimum items that can appear in the collection.
064     */
065        long minItemsInCollection() default 0L;
066
067    /**
068     * The maximum items that can appear in the collection.
069     *
070     * @return lhe maximum items that can appear in the collection.
071     */
072        long maxItemsInCollection() default Long.MAX_VALUE;
073
074        /**
075         * Whether this collection uses an indirection table between the parent and collection objects.
076     *
077     * <p>This has no function at present, but is here for informational purposes.</p>
078     *
079     * @return whether this collection uses an indirection table between the parent and collection objects.
080         */
081        boolean indirectCollection() default false;
082
083        /**
084         * When needed, how to label each element of the collection.
085     *
086     * <p>This is usually singular.  Will default to the label of the contained element type.</p>
087     *
088     * @return how to label each element of the collection.
089         */
090        String elementLabel() default "";
091
092        /**
093         * The label of the collection itself.
094     *
095     * <p>This is usually plural.</p>
096     *
097     * @return the label of the collection itself.
098         */
099        String label() default "";
100}