1 /** 2 * Copyright 2005-2015 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krad.data.provider; 17 18 import org.kuali.rice.krad.data.metadata.DataObjectMetadata; 19 20 import java.util.Collection; 21 import java.util.Map; 22 23 /** 24 * Defines metadata SPI for data providers. 25 * 26 * <p> 27 * These providers extract metadata from their sources (JPA Annotations, Custom krad-data anotations, Spring 28 * configuration, Message Services) to provide this information for use by the application and framework layers. 29 * </p> 30 * 31 * @author Kuali Rice Team (rice.collab@kuali.org) 32 */ 33 public interface MetadataProvider extends Provider { 34 35 /** 36 * Provides the metadata available from this provider for all of it's data objects. 37 * 38 * @return the metadata provided by this provider. 39 */ 40 Map<Class<?>, DataObjectMetadata> provideMetadata(); 41 42 /** 43 * Provides the metadata for the given types. 44 * 45 * @param types the list of types for which to get the metadata. 46 * @return a Map of the data object types to their metadata. 47 */ 48 Map<Class<?>, DataObjectMetadata> provideMetadataForTypes(Collection<Class<?>> types); 49 50 /** 51 * Obtains the metadata for a specific data type. 52 * 53 * @param dataObjectType the type for which to get the metadata. 54 * @return The metadata for the given data object or null if no metadata is available for the given type. 55 * @throws IllegalArgumentException if the data object type is null. 56 */ 57 DataObjectMetadata getMetadataForType(Class<?> dataObjectType); 58 59 /** 60 * Indicates whether or not this provider handles metadata for the given data object type. 61 * 62 * @param type the data object type to check. 63 * @return true if this provider will return any data for the given type, false otherwise 64 */ 65 boolean handles(Class<?> type); 66 67 /** 68 * Returns a complete list of the data object types which will return data from this provider. 69 * 70 * @return A non-null list of all the data object types supported by this provider. 71 */ 72 Collection<Class<?>> getSupportedTypes(); 73 74 /** 75 * Flag which allows the service to indicate that it requires knowledge of previously discovered persistable 76 * entities. 77 * 78 * <p> 79 * That is, the service is designed only to process existing objects and not to create new ones. 80 * </p> 81 * 82 * @return true if this provider will fail when passed an empty list of entity types 83 */ 84 boolean requiresListOfExistingTypes(); 85 86 }