1 // Copyright 2008 Thiago H. de Paula Figueiredo
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package br.com.arsmachina.tapestrycrud.selectmodel;
16
17 import java.util.List;
18
19 import org.apache.tapestry5.SelectModel;
20
21 /**
22 * Interface that defines a factory of {@link SelectModel} instances for any given type, provided it
23 * has a configured {@link SingleTypeSelectModelFactory} for it.
24 *
25 * @author Thiago H. de Paula Figueiredo
26 * @see SelectModel
27 */
28 public interface SelectModelFactory {
29
30 /**
31 * Creates a {@link SelectModel} containing all the instances of a given type.
32 *
33 * @param clasz the {@link Class} that represents the wanted type. It cannot be
34 * <code>null</code>.
35 * @return a {@link SelectModel}.
36 */
37 SelectModel create(Class<?> clasz);
38
39 /**
40 * Creates a {@link SelectModel} containing some given instances of a given type.
41 *
42 * @param clasz the {@link Class} that represents the wanted type. It cannot be
43 * <code>null</code>.
44 * @param objects a {@link List} containing the objects used as options.
45 */
46 <T> SelectModel create(Class<T> clasz, List<T> objects);
47
48 }