1 /* 2 * Copyright 2016 Function1. All Rights Reserved. 3 * 4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 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 tools.gsf.config; 17 18 /** 19 * Factory clas used to get and/or create objects. This can be used to 20 * configure an application, and is used internally by other components 21 * like the {@link tools.gsf.config.inject.InjectForRequestInjector}. 22 * 23 * @author Tony Field 24 * @since 2016-08-05 25 */ 26 public interface Factory { 27 28 /** 29 * Return an object with the type specified. If a name is provided, 30 * more than one variant of the specified type could be returned. 31 * 32 * @param name the name used to identify the variant of the class 33 * to be returned. If no name is specified, then the 34 * class name of the type specified is assumed. 35 * @param type the type of the oblject to return 36 * @param <T> the type of the object to return 37 * @return the matching object, or null if the factory does not 38 * know how to create the type specified. 39 */ 40 <T> T getObject(String name, Class<T> type); 41 42 }