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.selectmodel;
16  
17  import java.util.List;
18  
19  import org.apache.tapestry5.OptionGroupModel;
20  import org.apache.tapestry5.OptionModel;
21  import org.apache.tapestry5.SelectModel;
22  import org.apache.tapestry5.util.AbstractSelectModel;
23  
24  /**
25   * Simple {@link SelectModel} implementation. It doesnt't provide any {@link OptionGroupModel}.
26   * 
27   * @author Thiago H. de Paula Figueiredo
28   */
29  public class SimpleSelectModel extends AbstractSelectModel {
30  
31  	private List<OptionModel> optionModels;
32  
33  	/**
34  	 * Single constructor of this class.
35  	 * 
36  	 * @param optionModels a {@link List} of {@link OptionModel}s. It cannot be null.
37  	 */
38  	public SimpleSelectModel(List<OptionModel> optionModels) {
39  
40  		if (optionModels == null) {
41  			throw new IllegalArgumentException("Parameter optionModels cannot be null");
42  		}
43  
44  		this.optionModels = optionModels;
45  
46  	}
47  
48  	/**
49  	 * @see org.apache.tapestry.SelectModel#getOptionGroups()
50  	 */
51  	public List<OptionGroupModel> getOptionGroups() {
52  		return null;
53  	}
54  
55  	/**
56  	 * @see org.apache.tapestry.SelectModel#getOptions()
57  	 */
58  	public List<OptionModel> getOptions() {
59  		return optionModels;
60  	}
61  
62  }