Esempio n. 1
1
  @SuppressWarnings("unchecked")
  public ResidentConverter(List<ObjectConverter.ColumnInfo> allColumns) throws java.io.IOException {
    Optional<ObjectConverter.ColumnInfo> column;

    final java.util.List<ObjectConverter.ColumnInfo> columns =
        allColumns
            .stream()
            .filter(
                it ->
                    "mixinReference".equals(it.typeSchema) && "Resident_entity".equals(it.typeName))
            .collect(Collectors.toList());
    columnCount = columns.size();

    readers = new ObjectConverter.Reader[columnCount];
    for (int i = 0; i < readers.length; i++) {
      readers[i] = (instance, rdr, ctx) -> StringConverter.skip(rdr, ctx);
    }

    final java.util.List<ObjectConverter.ColumnInfo> columnsExtended =
        allColumns
            .stream()
            .filter(
                it ->
                    "mixinReference".equals(it.typeSchema)
                        && "-ngs_Resident_type-".equals(it.typeName))
            .collect(Collectors.toList());
    columnCountExtended = columnsExtended.size();

    readersExtended = new ObjectConverter.Reader[columnCountExtended];
    for (int i = 0; i < readersExtended.length; i++) {
      readersExtended[i] = (instance, rdr, ctx) -> StringConverter.skip(rdr, ctx);
    }

    column = columns.stream().filter(it -> "id".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'id' column in mixinReference Resident_entity. Check if DB is in sync");
    __index___id = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "id".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'id' column in mixinReference Resident. Check if DB is in sync");
    __index__extended_id = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "birth".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'birth' column in mixinReference Resident_entity. Check if DB is in sync");
    __index___birth = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "birth".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'birth' column in mixinReference Resident. Check if DB is in sync");
    __index__extended_birth = (int) column.get().order - 1;
  }
Esempio n. 2
0
  public static void main(String[] args) {

    Map<Integer, HashSet<String>> withSet =
        Stream.of("jon", "andrew", "harvey", "bil")
            .collect(Collectors.groupingBy(String::length, HashSet::new));
    out.println(withSet);
  }
 public List<InteractionClassFDD> getInteractions() {
   return interactions
       .stream()
       .filter(a -> a.isOn())
       .map(a -> a.interaction)
       .collect(Collectors.toList());
 }
Esempio n. 4
0
 public static Map filterLoadedValuesLambda(Map<String, String> in) {
   return in.entrySet()
       .stream()
       .collect(
           Collectors.toMap(
               e -> e.getKey().toString(), e -> Float.valueOf(e.getValue().toString())));
 }
Esempio n. 5
0
 @Override
 public void setTypeVariables(List<TypeVariable> typeVariables) {
   declaration.setTypeParameters(
       typeVariables
           .stream()
           .map(getContext()::unresolveTypeVariable)
           .collect(Collectors.toList()));
 }
Esempio n. 6
0
 public List<String> findPriceParallel(String product) {
   return shops
       .parallelStream()
       .map(shop -> shop.getPrice(product))
       .map(Quote::parse)
       .map(Discount::applyDiscount)
       .collect(Collectors.<String>toList());
 }
Esempio n. 7
0
 @Override
 public List<TypeVariable> getTypeVariables() {
   return declaration
       .getTypeParameters()
       .stream()
       .map(getContext()::resolveTypeVariable)
       .collect(Collectors.toList());
 }
Esempio n. 8
0
 @Override
 public List<Type> getInterfaceTypes() {
   return type.get()
       .getImplements()
       .stream()
       .map(getContext()::resolve)
       .collect(Collectors.toList());
 }
Esempio n. 9
0
 public static <T> void show(String title, Stream<T> stream) {
   final int SIZE = 10;
   List<T> firstElements = stream.limit(SIZE + 1).collect(Collectors.toList());
   System.out.print(title + ": ");
   if (firstElements.size() <= SIZE) System.out.println(firstElements);
   else {
     firstElements.remove(SIZE);
     String out = firstElements.toString();
     System.out.println(out.substring(0, out.length() - 1) + ", ...]");
   }
 }
Esempio n. 10
0
 @Override
 public List<Parameter> getParameters() {
   return declaration
       .getParameters()
       .stream()
       .map(
           (parameter) ->
               new Parameter(
                   getContext().resolve(parameter.getType()), parameter.getId().getName()))
       .collect(Collectors.toList());
 }
Esempio n. 11
0
  public static void main(String[] args) {
    // how many sales?
    long saleCount = saleStream().count();
    System.out.println("Count of sales: " + saleCount);

    // any sales over $100?
    Supplier<DoubleStream> totalStream = () -> saleStream().mapToDouble(Sale::total);
    boolean bigSaleDay = totalStream.get().anyMatch(total -> total > 100.00);
    System.out.println("Big sale day? " + bigSaleDay);

    // maximum sale amount?
    DoubleSummaryStatistics stats = totalStream.get().summaryStatistics();
    System.out.println("Max sale amount: " + stats.getMax());
    System.out.println("Stats on total: " + stats);

    // how many items were sold today?
    Supplier<Stream<Item>> itemStream = () -> saleStream().flatMap(sale -> sale.items.stream());
    long itemCount = itemStream.get().count();
    System.out.println("Count of items: " + itemCount);

    // which different items were sold today?
    String uniqueItems =
        itemStream.get().map(item -> item.identity).distinct().collect(Collectors.joining(" & "));
    System.out.println("Distinct items: " + uniqueItems);

    // summarize sales by store
    ConcurrentMap<String, DoubleSummaryStatistics> summary =
        saleStream()
            .parallel()
            .collect(
                Collectors.groupingByConcurrent(
                    sale -> Thread.currentThread().getName(),
                    Collectors.summarizingDouble(Sale::total)));
    System.out.println("Summary by thread: " + summary);
    summary
        .keySet()
        .stream()
        .sorted()
        .forEach(store -> System.out.println(store + " stats: " + summary.get(store)));
  }
Esempio n. 12
0
  public static void main(String[] args) {

    out.println("Gauss: " + MAX * (MAX + 1) / 2); // 500000500000

    long sum = 0L;
    for (long i = 0; i <= MAX; i++) {
      sum = sum + i;
    }
    out.println("For loop: " + sum);

    Long another =
        Stream.iterate(0L, l -> ++l).limit(MAX + 1).collect(Collectors.summingLong(l -> l));

    out.println("With a Stream of Long and Collectors.summingLong: " + another);
  }
Esempio n. 13
0
 public static void main(String[] args) {
   Set<String> distinctWords = Arrays.asList(args).stream().collect(Collectors.toSet());
   System.out.println(distinctWords.size() + " distinct words: " + distinctWords);
 }
Esempio n. 14
0
 private List<Annotation> getAnnotationsInternal(List<AnnotationExpr> l) {
   return l.stream()
       .map(AnnotationParser::annotationFromAnnotationExpr)
       .collect(Collectors.toList());
 }
Esempio n. 15
0
  @SuppressWarnings("unchecked")
  public Detail2Converter(List<ObjectConverter.ColumnInfo> allColumns) throws java.io.IOException {
    Optional<ObjectConverter.ColumnInfo> column;

    final java.util.List<ObjectConverter.ColumnInfo> columns =
        allColumns
            .stream()
            .filter(it -> "test".equals(it.typeSchema) && "Detail2_entity".equals(it.typeName))
            .collect(Collectors.toList());
    columnCount = columns.size();

    readers = new ObjectConverter.Reader[columnCount];
    for (int i = 0; i < readers.length; i++) {
      readers[i] =
          (instance, rdr, ctx) -> {
            StringConverter.skip(rdr, ctx);
            return instance;
          };
    }

    final java.util.List<ObjectConverter.ColumnInfo> columnsExtended =
        allColumns
            .stream()
            .filter(it -> "test".equals(it.typeSchema) && "-ngs_Detail2_type-".equals(it.typeName))
            .collect(Collectors.toList());
    columnCountExtended = columnsExtended.size();

    readersExtended = new ObjectConverter.Reader[columnCountExtended];
    for (int i = 0; i < readersExtended.length; i++) {
      readersExtended[i] =
          (instance, rdr, ctx) -> {
            StringConverter.skip(rdr, ctx);
            return instance;
          };
    }

    column = columns.stream().filter(it -> "u".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'u' column in test Detail2_entity. Check if DB is in sync");
    __index___u = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "u".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'u' column in test Detail2. Check if DB is in sync");
    __index__extended_u = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "dd".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'dd' column in test Detail2_entity. Check if DB is in sync");
    __index___dd = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "dd".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'dd' column in test Detail2. Check if DB is in sync");
    __index__extended_dd = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "EntityCompositeid".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'EntityCompositeid' column in test Detail2_entity. Check if DB is in sync");
    __index___EntityCompositeid = (int) column.get().order - 1;

    column =
        columnsExtended.stream().filter(it -> "EntityCompositeid".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'EntityCompositeid' column in test Detail2. Check if DB is in sync");
    __index__extended_EntityCompositeid = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "EntityIndex".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'EntityIndex' column in test Detail2_entity. Check if DB is in sync");
    __index___EntityIndex = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "EntityIndex".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'EntityIndex' column in test Detail2. Check if DB is in sync");
    __index__extended_EntityIndex = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "Index".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'Index' column in test Detail2_entity. Check if DB is in sync");
    __index___Index = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "Index".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'Index' column in test Detail2. Check if DB is in sync");
    __index__extended_Index = (int) column.get().order - 1;
  }
Esempio n. 16
0
 public List<Answer> find(Predicate<Answer> pred) {
   return answers.values().stream().filter(pred).collect(Collectors.toList());
 }
Esempio n. 17
0
  public List<String> findPrice(String product) {
    List<CompletableFuture<String>> priceFutures =
        findPriceStream(product).collect(Collectors.<CompletableFuture<String>>toList());

    return priceFutures.stream().map(CompletableFuture::join).collect(Collectors.<String>toList());
  }
Esempio n. 18
0
 public List<Contract> contracts() {
   return this.signs.stream().map(s -> s.contract()).collect(Collectors.toList());
 }