Java 类org.jooq.lambda.tuple.Tuple 实例源码

项目:json2java4idea    文件:ValueTypeTest.java   
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, Class>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, null, JsonNull.class),
            Tuple.tuple(ValueType.BOOLEAN, true, JsonBoolean.class),
            Tuple.tuple(ValueType.INT, 42, JsonNumber.class),
            Tuple.tuple(ValueType.LONG, 42L, JsonNumber.class),
            Tuple.tuple(ValueType.FLOAT, 4.2f, JsonNumber.class),
            Tuple.tuple(ValueType.DOUBLE, 4.2d, JsonNumber.class),
            Tuple.tuple(ValueType.BIG_INTEGER, BigInteger.ONE, JsonNumber.class),
            Tuple.tuple(ValueType.BIG_DECIMAL, BigDecimal.ONE, JsonNumber.class),
            Tuple.tuple(ValueType.STRING, "foo", JsonString.class),
            Tuple.tuple(ValueType.ARRAY, Collections.emptyList(), JsonArray.class),
            Tuple.tuple(ValueType.OBJECT, Collections.emptyMap(), JsonObject.class)
    );
}
项目:json2java4idea    文件:ValueTypeTest.java   
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, String>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, "null", "Value 'null' is not a null"),
            Tuple.tuple(ValueType.BOOLEAN, null, "Value 'null' is not a boolean"),
            Tuple.tuple(ValueType.INT, null, "Value 'null' is not an int"),
            Tuple.tuple(ValueType.LONG, null, "Value 'null' is not a long"),
            Tuple.tuple(ValueType.FLOAT, null, "Value 'null' is not a float"),
            Tuple.tuple(ValueType.DOUBLE, null, "Value 'null' is not a double"),
            Tuple.tuple(ValueType.BIG_INTEGER, null, "Value 'null' is not a big integer"),
            Tuple.tuple(ValueType.BIG_DECIMAL, null, "Value 'null' is not a big decimal"),
            Tuple.tuple(ValueType.STRING, null, "Value 'null' is not a string"),
            Tuple.tuple(ValueType.ARRAY, null, "Value 'null' is not an array"),
            Tuple.tuple(ValueType.OBJECT, null, "Value 'null' is not an object")
    );
}
项目:georocket    文件:RemoteElasticsearchClientTest.java   
/**
 * Test if the client can insert multiple documents in one request
 * @param context the test context
 */
@Test
public void bulkInsert(TestContext context) {
  String url = "/" + INDEX + "/" + TYPE + "/_bulk";

  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(200)
          .withBody("{}")));

  List<Tuple2<String, JsonObject>> documents = new ArrayList<>();
  documents.add(Tuple.tuple("A", new JsonObject().put("name", "Elvis")));
  documents.add(Tuple.tuple("B", new JsonObject().put("name", "Max")));

  Async async = context.async();
  client.bulkInsert(TYPE, documents).subscribe(res -> {
    verify(postRequestedFor(urlEqualTo(url))
        .withRequestBody(equalToJson("{\"index\":{\"_id\":\"A\"}}\n" + 
            "{\"name\":\"Elvis\"}\n" + 
            "{\"index\":{\"_id\":\"B\"}}\n" + 
            "{\"name\":\"Max\"}\n")));
    context.assertEquals(0, res.size());
    async.complete();
  }, context::fail);
}
项目:georocket    文件:GeoJsonSplitterTest.java   
private List<Tuple2<GeoJsonChunkMeta, JsonObject>> split(String file)
    throws IOException {
  byte[] json = IOUtils.toByteArray(GeoJsonSplitterTest.class.getResource(file));
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = new ArrayList<>();
  StringWindow window = new StringWindow();
  GeoJsonSplitter splitter = new GeoJsonSplitter(window);
  Observable.just(json)
    .map(Buffer::buffer)
    .doOnNext(window::append)
    .lift(new JsonParserOperator())
    .flatMap(splitter::onEventObservable)
    .toBlocking()
    .forEach(result -> {
      JsonObject o = new JsonObject(result.getChunk());
      chunks.add(Tuple.tuple((GeoJsonChunkMeta)result.getMeta(), o));
    });
  return chunks;
}
项目:waltz    文件:AssetCostDao.java   
public List<Tuple2<Long, BigDecimal>> calculateCombinedAmountsForSelector(int year, Select<Record1<Long>> appIdSelector) {
    checkNotNull(appIdSelector, "appIdSelector cannot be null");

    Field<BigDecimal> totalAmount = DSL.sum(ASSET_COST.AMOUNT).as("total_amount");

    Condition condition = ASSET_COST.YEAR.eq(year)
            .and(APPLICATION.ID.in(appIdSelector));

    return dsl.select(APPLICATION.ID, totalAmount)
            .from(ASSET_COST)
            .innerJoin(APPLICATION)
            .on(APPLICATION.ASSET_CODE.eq(ASSET_COST.ASSET_CODE))
            .where(dsl.renderInlined(condition))
            .groupBy(APPLICATION.ID)
            .fetch(r -> Tuple.tuple(r.value1(), r.value2()));
}
项目:xml-stream-css    文件:CssMatcherTest.java   
@Test
public void testCss_Ancestor() throws Exception {

    List<Tuple2<Predicate<StreamContext>,Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.css("child4" ), 2),
            Tuple.tuple(Predicates.css("ancestor1 child4" ), 1),
            Tuple.tuple(Predicates.css("ancestor1 > parent1 > child4" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 + child5" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 + child5 + child6" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 ~ child5" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 ~ child6" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child1 ~ child3 ~ child5" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 ~ child6 grandchild1" ), 1),
            Tuple.tuple(Predicates.css("xml parent1 > child4 + child6" ), 0),
            Tuple.tuple(Predicates.css("xml parent1 > child6 ~ child4" ), 0),
            Tuple.tuple(Predicates.css("xml parent1 > child4 ~ grandchild1" ), 0),
            Tuple.tuple(Predicates.css("xml parent1 > child6 ~ grandchild1" ), 0),
            Tuple.tuple(Predicates.css("ancestor1 > child4" ), 0),


            Tuple.tuple(Predicates.css("child4 ~ child6" ), 2),
            Tuple.tuple(Predicates.css("xml grandchild1" ), 2)
    );
    test(list , "src/test/resources/css/children/children.xml");
}
项目:xml-stream-css    文件:CssMatcherTest.java   
@Test
public void testCss_PseudoClass() throws Exception {

    List<Tuple2<Predicate<StreamContext>,Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.css("child3:nth-child(2)" ), 0),
            Tuple.tuple(Predicates.css("child3:nth-child(3)" ), 1),
            Tuple.tuple(Predicates.css("child3:nth-child(4)" ), 1),
            Tuple.tuple(Predicates.css("child3:nth-child(5)" ), 0),

            Tuple.tuple(Predicates.css("child5:nth-of-type(2)" ), 1),

            Tuple.tuple(Predicates.css("child1:first-child" ), 1),
            Tuple.tuple(Predicates.css("child2:first-child" ), 0),

            Tuple.tuple(Predicates.css("child5:first-of-type" ), 1),

            Tuple.tuple(Predicates.css("grandchild2" ), 1),

            Tuple.tuple(Predicates.css("id#foo" ), 1)
    );

    test(list , "src/test/resources/css/pseudoclass/pseudoclass.xml");
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 10 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> Tuple10<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 11 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> Tuple11<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 12 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12> Tuple12<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11,
    Collector<? super T, A12, R12> collector12
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11, collector12));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 13 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> Tuple13<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11,
    Collector<? super T, A12, R12> collector12,
    Collector<? super T, A13, R13> collector13
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11, collector12, collector13));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 14 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14> Tuple14<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11,
    Collector<? super T, A12, R12> collector12,
    Collector<? super T, A13, R13> collector13,
    Collector<? super T, A14, R14> collector14
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11, collector12, collector13, collector14));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 15 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15> Tuple15<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11,
    Collector<? super T, A12, R12> collector12,
    Collector<? super T, A13, R13> collector13,
    Collector<? super T, A14, R14> collector14,
    Collector<? super T, A15, R15> collector15
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11, collector12, collector13, collector14, collector15));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 16 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16> Tuple16<R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8,
    Collector<? super T, A9, R9> collector9,
    Collector<? super T, A10, R10> collector10,
    Collector<? super T, A11, R11> collector11,
    Collector<? super T, A12, R12> collector12,
    Collector<? super T, A13, R13> collector13,
    Collector<? super T, A14, R14> collector14,
    Collector<? super T, A15, R15> collector15,
    Collector<? super T, A16, R16> collector16
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8, collector9, collector10, collector11, collector12, collector13, collector14, collector15, collector16));
}
项目:jOOL    文件:ConsumerTest.java   
@Test
public void testTupleConsumers() {
    int[] number = new int[1];
    String[] string = new String[1];

    number[0] = 0;
    Seq.of(Tuple.tuple(), Tuple.tuple(), Tuple.tuple())
       .forEach(Tuple.consumer(() -> number[0] = number[0] + 1));
    assertEquals(3, number[0]);

    number[0] = 0;
    Seq.of(Tuple.tuple(1), Tuple.tuple(2), Tuple.tuple(3))
       .forEach(Tuple.consumer(t -> number[0] = number[0] + t));
    assertEquals(6, number[0]);

    number[0] = 0;
    string[0] = "";
    Seq.of(Tuple.tuple(1, "A"), Tuple.tuple(2, "B"), Tuple.tuple(3, "C"))
       .forEach(Tuple.consumer((i, s) -> {
           number[0] = number[0] + i;
           string[0] = string[0] + s;
       }));

    assertEquals(6, number[0]);
    assertEquals("ABC", string[0]);
}
项目:jOOL    文件:SeqTest.java   
@Test
public void testGroupedWithCollector() throws Exception {
    List<Tuple2<Integer, List<Integer>>> l1 =
    Seq.of(1, 2, 3, 4)
       .grouped(x -> x % 2, Collectors.toList())
       .toList();

    assertEquals(asList(
        Tuple.tuple(1, Arrays.asList(1, 3)),
        Tuple.tuple(0, Arrays.asList(2, 4))
    ), l1);


    List<Tuple2<Integer, String>> l2 =
    Seq.of(1, 2, 3, 4)
       .grouped(x -> x % 2, Collectors.mapping(Object::toString, Collectors.joining(", ")))
       .toList();

    assertEquals(asList(
        Tuple.tuple(1, "1, 3"),
        Tuple.tuple(0, "2, 4")
    ), l2);
}
项目:json2java4idea    文件:ValueTypeTest.java   
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, Boolean>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, null, true),
            Tuple.tuple(ValueType.NULL, "null", false),
            Tuple.tuple(ValueType.BOOLEAN, true, true),
            Tuple.tuple(ValueType.BOOLEAN, "true", false),
            Tuple.tuple(ValueType.INT, 1024, true),
            Tuple.tuple(ValueType.INT, 1024L, false),
            Tuple.tuple(ValueType.LONG, 1024L, true),
            Tuple.tuple(ValueType.LONG, 1024, false),
            Tuple.tuple(ValueType.FLOAT, 1.0f, true),
            Tuple.tuple(ValueType.FLOAT, 1.0d, false),
            Tuple.tuple(ValueType.DOUBLE, 1.0d, true),
            Tuple.tuple(ValueType.DOUBLE, 1.0f, false),
            Tuple.tuple(ValueType.BIG_INTEGER, BigInteger.ONE, true),
            Tuple.tuple(ValueType.BIG_INTEGER, 1, false),
            Tuple.tuple(ValueType.BIG_DECIMAL, BigDecimal.ONE, true),
            Tuple.tuple(ValueType.BIG_DECIMAL, 1, false),
            Tuple.tuple(ValueType.STRING, "text", true),
            Tuple.tuple(ValueType.STRING, null, false),
            Tuple.tuple(ValueType.ARRAY, Collections.singletonList("test"), true),
            Tuple.tuple(ValueType.ARRAY, null, false),
            Tuple.tuple(ValueType.OBJECT, Collections.singletonMap("key", "test"), true),
            Tuple.tuple(ValueType.OBJECT, null, false)
    );
}
项目:jool-hands-on    文件:RangeTest.java   
public static void main(String[] args) {

        Range<Integer> range = new Range<>(20,30);
        Range<Integer> range2 = new Range<>(Tuple.tuple(20,30));

        System.out.println(range.intersect(22,40)); // returns intersecting tuple
        System.out.println(range.intersect(1,50)); // returns intersecting tuple
        System.out.println(range.overlaps(22,40)); // returns true if overlapping tuple
        System.out.println(range.overlaps(1,50)); // returns true if overlapping tuple
    }
项目:libcwfincore    文件:MutableProductSet.java   
@Override
public ProductId getRelatedProductId(AssetId baseAssetId, AssetId quoteAssetId) throws NoSuchProductException {
    Tuple2<AssetId, AssetId> assetKey = Tuple.tuple(baseAssetId, quoteAssetId);
    ProductId id = assetIdMap.get(assetKey);
    if (id == null) {
        throw new NoSuchProductException("no product found for assets " + baseAssetId + "/" + quoteAssetId);
    }
    return id;
}
项目:csvsum    文件:AccessMapper.java   
private static String parseTableMappings(List<ValueMapping> map, final Database db,
        JDefaultDict<String, ConcurrentMap<ValueMapping, Tuple2<String, String>>> foreignKeyMapping,
        ConcurrentMap<ValueMapping, Joiner> joiners) throws IOException {
    String originTable = map.isEmpty() ? null
            : db.getTable(CSVUtil.DOT_PATTERN.split(map.get(0).getInputField())[0]).getName();
    // for (final ValueMapping nextValueMapping : map) {
    // Must be a sequential mapping as ordering is important
    map.stream().sequential().forEach(Unchecked.consumer(nextValueMapping -> {
        if (nextValueMapping.getLanguage() == ValueMappingLanguage.ACCESS) {
            final String[] splitDBField = CSVUtil.DOT_PATTERN.split(nextValueMapping.getInputField());
            System.out.println(nextValueMapping.getInputField());
            final Table nextTable = db.getTable(splitDBField[0]);

            final String[] splitForeignDBField = CSVUtil.DOT_PATTERN.split(nextValueMapping.getMapping());
            final Table nextForeignTable = db.getTable(splitForeignDBField[0]);
            if (nextForeignTable == null) {
                throw new RuntimeException(
                        "Could not find table referenced by access mapping: " + nextValueMapping.getMapping());
            }
            foreignKeyMapping.get(splitForeignDBField[0]).put(nextValueMapping,
                    Tuple.tuple(nextTable.getName(), nextForeignTable.getName()));
            try {
                final Joiner create = Joiner.create(nextTable, nextForeignTable);
                if (create != null) {
                    joiners.put(nextValueMapping, create);
                    System.out.println("PK->FK: " + joiners.get(nextValueMapping).toFKString());
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }));
    return originTable;
}
项目:RankSys    文件:SimpleFeaturesReader.java   
@Override
public <I, F> Stream<Tuple3<I, F, Double>> read(InputStream in, Parser<I> ip, Parser<F> fp) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        String[] tokens = line.split("\t", 3);
        I item = ip.parse(tokens[0]);
        F feat = fp.parse(tokens[1]);

        return Tuple.tuple(item, feat, 1.0);
    });
}
项目:RankSys    文件:SimpleRatingPreferencesReader.java   
@Override
public <U, I> Stream<Tuple3<U, I, Double>> read(InputStream in, Parser<U> up, Parser<I> ip) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        CharSequence[] tokens = split(line, '\t', 4);
        U user = up.parse(tokens[0]);
        I item = ip.parse(tokens[1]);
        double value = parseDouble(tokens[2].toString());

        return Tuple.tuple(user, item, value);
    });
}
项目:RankSys    文件:SimpleBinaryPreferencesReader.java   
@Override
public <U, I> Stream<Tuple3<U, I, Double>> read(InputStream in, Parser<U> up, Parser<I> ip) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        CharSequence[] tokens = split(line, '\t', 3);
        U user = up.parse(tokens[0]);
        I item = ip.parse(tokens[1]);

        return Tuple.tuple(user, item, 1.0);
    });
}
项目:waltz    文件:ChangeInitiativeGenerator.java   
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    List<Long> groupIds = dsl.select(APPLICATION_GROUP.ID)
            .from(APPLICATION_GROUP)
            .fetch(APPLICATION_GROUP.ID);

    List<String> employeeIds = dsl
            .select(PERSON.EMPLOYEE_ID)
            .from(PERSON)
            .fetch(PERSON.EMPLOYEE_ID);

    List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID)
                .from(ORGANISATIONAL_UNIT)
                .fetch(ORGANISATIONAL_UNIT.ID);

    List<TableRecord<?>> records = LongStream.range(0, 400)
            .mapToObj(i -> {
                String name = randomPick(p1)
                        + " "
                        + randomPick(p2)
                        + " "
                        + randomPick(p3);
                Long ouId = randomPick(orgUnitIds.toArray(new Long[0]));
                return Tuple.tuple(i, name, ouId);
            })
            .map(t -> buildChangeInitiativeRecord(t))
            .flatMap(r -> Stream.concat(Stream.of(r), buildLinks(r, groupIds, employeeIds)))
            .collect(toList());


    System.out.println("-- deleting");
    dsl.deleteFrom(CHANGE_INITIATIVE).execute();
    System.out.println("-- inserting");
    dsl.batchInsert(records).execute();
    System.out.println(" -- done");


}
项目:waltz    文件:BusinessRegionProductHierarchyGenerator.java   
private static Set<String> readRegions() throws IOException {
    List<String> lines = readLines(OrgUnitGenerator.class.getResourceAsStream("/regions.csv"));
    Map<String, Map<String, Set<String>>> regionHierarchy = lines.stream()
            .skip(1)
            .map(line -> StringUtils.splitPreserveAllTokens(line, ","))
            .filter(cells -> notEmpty(cells[0]) && notEmpty(cells[6]) && notEmpty(cells[5]))
            .map(cells -> Tuple.tuple(cells[0], cells[6], cells[5]))
            .collect(groupingBy(
                    t -> t.v3,
                    groupingBy(t -> t.v2, mapping(t -> t.v1, toSet()))
            ));

    return regionHierarchy.keySet();
}
项目:waltz    文件:EntityRelationshipUtilities.java   
public static Optional<EntityRelationshipKey> mkEntityRelationshipKey(EntityReference entityA,
                                                                   EntityReference entityB,
                                                                   RelationshipKind relationshipKind) {
    checkNotNull(relationshipKind, "relationshipKind cannot be null");
    checkNotNull(entityA, "entityA cannot be null");
    checkNotNull(entityB, "entityB cannot be null");

    // given A, B and a relationship kind -> return the valid entity relationship
    Set<Tuple2<EntityKind, EntityKind>> allowedEntityKinds = relationshipKind.getAllowedEntityKinds();

    Tuple2<EntityKind, EntityKind> exact = Tuple.tuple(entityA.kind(), entityB.kind());
    Tuple2<EntityKind, EntityKind> opposite = Tuple.tuple(entityB.kind(), entityA.kind());

    if (allowedEntityKinds.contains(exact)) {
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityA)
                .b(entityB)
                .relationshipKind(relationshipKind)
                .build());
    } else if (allowedEntityKinds.contains(opposite)){
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityB)
                .b(entityA)
                .relationshipKind(relationshipKind)
                .build());
    } else {
        return Optional.empty();
    }
}
项目:waltz    文件:LogicalFlowDao.java   
public List<LogicalFlow> addFlows(List<LogicalFlow> flows, String user) {
    Condition condition = flows
            .stream()
            .map(t -> isSourceCondition(t.source())
                    .and(isTargetCondition(t.target()))
                    .and(LOGICAL_FLOW.IS_REMOVED.eq(true)))
            .reduce((a, b) -> a.or(b))
            .get();

    List<LogicalFlow> removedFlows = baseQuery()
            .where(condition)
            .fetch(TO_DOMAIN_MAPPER);

    if(removedFlows.size() > 0) {
        restoreFlows(removedFlows, user);
    }

    Map<Tuple2<EntityReference, EntityReference>, LogicalFlow> existing = removedFlows
            .stream()
            .collect(Collectors.toMap(f -> Tuple.tuple(f.source(), f.target()), f -> f));


    List<LogicalFlow> addedFlows = flows
            .stream()
            .filter(f -> !existing.containsKey(Tuple.tuple(f.source(), f.target())))
            .map(f -> {
                LogicalFlowRecord record = TO_RECORD_MAPPER.apply(f, dsl);
                record.store();
                return ImmutableLogicalFlow
                        .copyOf(f)
                        .withId(record.getId());
            })
            .collect(toList());


    addedFlows.addAll(removedFlows);
    return addedFlows;
}
项目:waltz    文件:UsageInfoUtilities.java   
public static SystemChangeSet<UsageInfo, UsageKind> mkChangeSet(Set<UsageInfo> base, Set<UsageInfo> replacements) {

        Set<UsageKind> baseKinds = SetUtilities.map(base, ui -> ui.kind());
        Set<UsageKind> replacementKinds = SetUtilities.map(replacements, ui -> ui.kind());

        Set<UsageKind> newKinds = SetUtilities.minus(replacementKinds, baseKinds);


        Set<UsageKind> deletes = replacements.stream()
                .filter(ui -> ! ui.kind().isReadOnly())
                .filter(ui -> ! ui.isSelected())  // if it is selected we can't delete
                .filter(ui -> StringUtilities.isEmpty(ui.description()))
                .map(r -> r.kind())
                .collect(Collectors.toSet());

        Set<UsageInfo> updates = intersection(baseKinds, replacementKinds)
                .stream()
                .map(potentiallyUpdatedKind -> Tuple.tuple(
                        find(ui -> ui.kind() == potentiallyUpdatedKind, base),
                        find(ui -> ui.kind() == potentiallyUpdatedKind, replacements)))
                .filter(t -> t.v1.isPresent() && t.v2.isPresent())
                .filter(t -> ! t.v1.get().equals(t.v2.get()))
                .map(t -> t.v2().get())
                .filter(ui -> ! deletes.contains(ui.kind()))
                .collect(Collectors.toSet());

        Collection<UsageInfo> inserts = replacements.stream()
                .filter(r -> newKinds.contains(r.kind()))
                .filter(r -> StringUtilities.notEmpty(r.description()) || r.isSelected())
                .collect(Collectors.toSet());

        return ImmutableSystemChangeSet.<UsageInfo, UsageKind>builder()
                .inserts(inserts)
                .updates(updates)
                .deletes(deletes)
                .build();
    }
项目:book-reading    文件:TuplePractice.java   
public static void main(String[] args) {
    Tuple2<Integer, Integer> tuple = Tuple.tuple(1, 2);
    System.out.println(tuple);

    int intValue = tuple.map((a, b) -> a + b).intValue();
    System.out.println(intValue);

    Range<Integer> range = Tuple.range(1, 10);
    range.list().forEach(System.out::println);

}
项目:xml-stream-css    文件:PredicateTest.java   
@Test
public void testElement() throws Exception {
    List<Tuple2<Predicate<StreamContext>, Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.element("foo"), 0),
            Tuple.tuple(Predicates.element("child1"), 2),
            Tuple.tuple(Predicates.element("child2"), 1),
            Tuple.tuple(Predicates.all(), 49),
            Tuple.tuple(Predicates.allElements(), 14)
    );
    test(list, "src/test/resources/predicate/children/children.xml");
}
项目:xml-stream-css    文件:PredicateTest.java   
@Test
public void testAttribute() throws Exception {
    List<Tuple2<Predicate<StreamContext>, Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.attributes("testExist"), 1),
            Tuple.tuple(Predicates.attributeValue("testEquals", "ok"), 1),
            Tuple.tuple(Predicates.attributeValue("testEquals", "nok"), 0)
    );
    test(list, "src/test/resources/predicate/attribute/attribute.xml");
}
项目:xml-stream-css    文件:CssMatcherTest.java   
@Test
public void testCss_Root() throws Exception {

    List<Tuple2<Predicate<StreamContext>,Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.css(":root") , 1),
            Tuple.tuple(Predicates.css("*:root" ), 1),
            Tuple.tuple(Predicates.css("rootElement:root" ), 1),
            Tuple.tuple(Predicates.css("foo:root" ), 0)
    );

    test(list , "src/test/resources/css/root/root.xml");
}
项目:xml-stream-css    文件:CssMatcherTest.java   
@Test
public void testCss_Attributes() throws Exception {
    List<Tuple2<Predicate<StreamContext>,Integer>> list = ImmutableList.of(
            Tuple.tuple(Predicates.css("a[testExist]" ), 1),
            Tuple.tuple(Predicates.css("a[testNotExist]" ), 0),
            Tuple.tuple(Predicates.css("a[testEquals=\"ok\"]" ), 1),
            Tuple.tuple(Predicates.css("a[testEquals=\"okok\"]" ), 0),
            Tuple.tuple(Predicates.css("a[testContains*=\"ips\"]" ), 1),
            Tuple.tuple(Predicates.css("a[testContains*=\"ipsd\"]" ), 0)
    );
    test(list , "src/test/resources/css/attribute/attribute.xml");
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 2 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, A1, A2> Tuple2<R1, R2> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2
) {
    return collect(Tuple.collectors(collector1, collector2));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 3 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, A1, A2, A3> Tuple3<R1, R2, R3> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3
) {
    return collect(Tuple.collectors(collector1, collector2, collector3));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 4 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, A1, A2, A3, A4> Tuple4<R1, R2, R3, R4> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 5 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, A1, A2, A3, A4, A5> Tuple5<R1, R2, R3, R4, R5> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 6 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, A1, A2, A3, A4, A5, A6> Tuple6<R1, R2, R3, R4, R5, R6> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 7 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, A1, A2, A3, A4, A5, A6, A7> Tuple7<R1, R2, R3, R4, R5, R6, R7> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7));
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 8 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, R5, R6, R7, R8, A1, A2, A3, A4, A5, A6, A7, A8> Tuple8<R1, R2, R3, R4, R5, R6, R7, R8> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4,
    Collector<? super T, A5, R5> collector5,
    Collector<? super T, A6, R6> collector6,
    Collector<? super T, A7, R7> collector7,
    Collector<? super T, A8, R8> collector8
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4, collector5, collector6, collector7, collector8));
}