View Javadoc
1   package fr.ifremer.tutti.persistence.entities.referential;
2   
3   /*
4    * #%L
5    * Tutti :: Persistence
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import org.nuiton.util.beans.Binder;
26  import org.nuiton.util.beans.BinderFactory;
27  
28  import javax.annotation.Generated;
29  import java.util.ArrayList;
30  import java.util.List;
31  
32  @Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanTransformer", date = "Wed Oct 02 14:29:49 CEST 2013")
33  public class GearWithOriginalRankOrders extends AbstractGearWithOriginalRankOrders {
34  
35      public static <BeanType extends GearWithOriginalRankOrder> BeanType newGearWithOriginalRankOrder(Integer id, Short rankOrder) {
36          BeanType result = (BeanType) newGearWithOriginalRankOrder();
37          result.setId(id);
38          result.setRankOrder(rankOrder);
39          return result;
40      }
41  
42      public static <BeanType extends GearWithOriginalRankOrder> BeanType newGearWithOriginalRankOrder(Gear source) {
43          Class<BeanType> sourceType = typeOfGearWithOriginalRankOrder();
44          Binder<Gear, BeanType> binder = BinderFactory.newBinder(Gear.class, sourceType);
45          BeanType result = (BeanType) newGearWithOriginalRankOrder();
46          binder.copy(source, result);
47          return result;
48      }
49  
50      public static List<GearWithOriginalRankOrder> toGearWithOriginalRankOrders(List<Gear> gears) {
51  
52          short rankOrder = 1;
53  
54          List<GearWithOriginalRankOrder> gearWithOriginalRankOrders = new ArrayList<>();
55          for (Gear gear : gears) {
56  
57              GearWithOriginalRankOrder gearWithOriginalRankOrder = GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
58              gearWithOriginalRankOrder.setRankOrder(rankOrder++);
59              gearWithOriginalRankOrders.add(gearWithOriginalRankOrder);
60          }
61  
62          return gearWithOriginalRankOrders;
63  
64      }
65  
66  }