View Javadoc

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.module;
16  
17  import org.apache.tapestry5.PrimaryKeyEncoder;
18  
19  import br.com.arsmachina.tapestrycrud.encoder.ActivationContextEncoder;
20  import br.com.arsmachina.tapestrycrud.encoder.Encoder;
21  import br.com.arsmachina.tapestrycrud.encoder.LabelEncoder;
22  
23  /**
24   * Interface that defines information about a module, whatever its conventions are.
25   * 
26   * @author Thiago H. de Paula Figueiredo
27   */
28  public interface TapestryCrudModule {
29  
30  	/**
31  	 * Returns the activation context encoder class corresponding to a given entity class.
32  	 * 
33  	 * @param <T> the entity type.
34  	 * @param entityClass a {@link Class} instance. It cannot be null.
35  	 * @return an {@link ActivationContextEncoder} or null (if no corresponding one is found).
36  	 */
37  	public <T> Class<? extends ActivationContextEncoder<T>> getActivationContextEncoderClass(
38  			Class<T> entityClass);
39  
40  	/**
41  	 * Returns the encoder class corresponding to a given entity class.
42  	 * 
43  	 * @param <T> the entity type.
44  	 * @param entityClass a {@link Class} instance. It cannot be null.
45  	 * @return an {@link Encoder} or null (if no corresponding one is found).
46  	 */
47  	public <T> Class<? extends Encoder<T, ?>> getEncoderClass(
48  			Class<T> entityClass);
49  
50  	/**
51  	 * Returns the label encoder class corresponding to a given entity class.
52  	 * 
53  	 * @param <T> the entity type.
54  	 * @param entityClass a {@link Class} instance. It cannot be null.
55  	 * @return a {@link LabelEncoder} or null (if no corresponding one is found).
56  	 */
57  	public <T> Class<? extends LabelEncoder<T>> getLabelEncoderClass(
58  			Class<T> entityClass);
59  
60  	/**
61  	 * Returns the label encoder class corresponding to a given entity class.
62  	 * 
63  	 * @param <T> the entity type.
64  	 * @param entityClass a {@link Class} instance. It cannot be null.
65  	 * @return a {@link PrimaryKeyEncoder} or null (if no corresponding one is found).
66  	 */
67  	public <T> Class<? extends PrimaryKeyEncoder<?, T>> getPrimaryKeyEncoderClass(
68  			Class<T> entityClass);
69  
70  	/**
71  	 * Returns the module name. Just used for logging and debugging purposes.
72  	 * 
73  	 * @return a {@link String}.
74  	 */
75  	public String getName();
76  
77  }