001/**
002 * Copyright 2005-2015 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;
017
018import org.kuali.rice.krad.data.metadata.DataObjectMetadata;
019
020import java.util.Collection;
021import java.util.Map;
022
023/**
024 * Defines metadata SPI for data providers.
025 *
026 * <p>
027 * These providers extract metadata from their sources (JPA Annotations, Custom krad-data anotations, Spring
028 * configuration, Message Services) to provide this information for use by the application and framework layers.
029 * </p>
030 * 
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public interface MetadataProvider extends Provider {
034
035    /**
036     * Provides the metadata available from this provider for all of it's data objects.
037     *
038     * @return the metadata provided by this provider.
039     */
040        Map<Class<?>, DataObjectMetadata> provideMetadata();
041
042        /**
043         * Provides the metadata for the given types.
044         * 
045         * @param types the list of types for which to get the metadata.
046         * @return a Map of the data object types to their metadata.
047         */
048        Map<Class<?>, DataObjectMetadata> provideMetadataForTypes(Collection<Class<?>> types);
049
050    /**
051     * Obtains the metadata for a specific data type.
052     *
053     * @param dataObjectType the type for which to get the metadata.
054     * @return The metadata for the given data object or null if no metadata is available for the given type.
055     * @throws IllegalArgumentException if the data object type is null.
056     */
057        DataObjectMetadata getMetadataForType(Class<?> dataObjectType);
058
059        /**
060         * Indicates whether or not this provider handles metadata for the given data object type.
061         * 
062         * @param type the data object type to check.
063         * @return true if this provider will return any data for the given type, false otherwise
064         */
065        boolean handles(Class<?> type);
066
067        /**
068         * Returns a complete list of the data object types which will return data from this provider.
069         * 
070         * @return A non-null list of all the data object types supported by this provider.
071         */
072        Collection<Class<?>> getSupportedTypes();
073
074        /**
075         * Flag which allows the service to indicate that it requires knowledge of previously discovered persistable
076         * entities.
077     *
078     * <p>
079     * That is, the service is designed only to process existing objects and not to create new ones.
080     * </p>
081         * 
082         * @return true if this provider will fail when passed an empty list of entity types
083         */
084        boolean requiresListOfExistingTypes();
085
086}