DefautDao.java

  1. /*
  2.  * #%L
  3.  * *********************************************************************************************************************
  4.  *
  5.  * SteelBlue
  6.  * http://steelblue.tidalwave.it - git clone git@bitbucket.org:tidalwave/steelblue-src.git
  7.  * %%
  8.  * Copyright (C) 2015 - 2015 Tidalwave s.a.s. (http://tidalwave.it)
  9.  * %%
  10.  *
  11.  * *********************************************************************************************************************
  12.  *
  13.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  14.  * the License. You may obtain a copy of the License at
  15.  *
  16.  *     http://www.apache.org/licenses/LICENSE-2.0
  17.  *
  18.  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  19.  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  20.  * specific language governing permissions and limitations under the License.
  21.  *
  22.  * *********************************************************************************************************************
  23.  *
  24.  *
  25.  *
  26.  * *********************************************************************************************************************
  27.  * #L%
  28.  */
  29. package it.tidalwave.role.ui.javafx.example.large.data.impl;

  30. import javax.annotation.Nonnull;
  31. import java.util.Collection;
  32. import java.util.concurrent.atomic.AtomicInteger;
  33. import java.util.stream.IntStream;
  34. import it.tidalwave.role.ui.javafx.example.large.data.*;
  35. import static java.util.stream.Collectors.toList;

  36. /***********************************************************************************************************************
  37.  *
  38.  * @author  Fabrizio Giudici (Fabrizio.Giudici@tidalwave.it)
  39.  *
  40.  **********************************************************************************************************************/
  41. public class DefautDao implements Dao
  42.   {
  43.     @Override @Nonnull
  44.     public Collection<SimpleEntity> getSimpleEntities()
  45.       {
  46.         return IntStream.rangeClosed(1, 1000).mapToObj(Integer::toString).map(SimpleEntity::new).collect(toList());
  47.       }

  48.     @Override @Nonnull
  49.     public Collection<SimpleDciEntity> getDciEntities()
  50.       {
  51.         final AtomicInteger sequence = new AtomicInteger(3); // I know it's bad, it's just an example
  52.         return IntStream.rangeClosed(1, 1000).mapToObj(row ->
  53.           {
  54.             final int attr1 = sequence.getAndIncrement();
  55.             final int attr2 = sequence.getAndIncrement();
  56.             final String name = String.format("(%d ; %d)", attr1, attr2);
  57.             return new SimpleDciEntity(name, attr1, attr2);
  58.           }).collect(toList());
  59.       }
  60.   }