View Javadoc
1   package fr.ifremer.dali.ui.swing.util;
2   
3   /*
4    * #%L
5    * Dali :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import fr.ifremer.quadrige3.ui.core.dto.QuadrigeBean;
27  import fr.ifremer.quadrige3.ui.swing.model.AbstractBeanUIModel;
28  import org.nuiton.util.beans.Binder;
29  
30  /**
31   * Abstract UI model to edit a bean.
32   *
33   * @param <B> type of Bean
34   * @param <M> type of model
35   * @author Ludovic Pecquot <ludovic.pecquot@e-is.pro>
36   * @since 0.1
37   * <p/>
38   * classes extending this must implement the E interface and delegate methods to delegateObject
39   */
40  public abstract class AbstractDaliBeanUIModel<B extends QuadrigeBean, M extends AbstractDaliBeanUIModel<B, M>>
41          extends AbstractBeanUIModel<B, M> {
42  
43      /**
44       * <p>Constructor for AbstractBeanUIModel.</p>
45       *
46       * @param fromBeanBinder a {@link Binder} object.
47       * @param toBeanBinder   a {@link Binder} object.
48       */
49      protected AbstractDaliBeanUIModel(Binder<B, M> fromBeanBinder, Binder<M, B> toBeanBinder) {
50          super(fromBeanBinder, toBeanBinder);
51      }
52  
53      /**
54       * <p>isCreate.</p>
55       *
56       * @return a boolean.
57       */
58      public boolean isCreate() {
59          return delegateObject.getId() == null;
60      }
61  
62      /**
63       * <p>getId.</p>
64       *
65       * @return a {@link java.lang.Integer} object.
66       */
67      public Integer getId() {
68          return delegateObject.getId();
69      }
70  
71      /**
72       * <p>setId.</p>
73       *
74       * @param id a {@link java.lang.Integer} object.
75       */
76      public void setId(Integer id) {
77          delegateObject.setId(id);
78      }
79  
80  }