本文整理汇总了Java中org.parboiled.common.Tuple2类的典型用法代码示例。如果您正苦于以下问题:Java Tuple2类的具体用法?Java Tuple2怎么用?Java Tuple2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tuple2类属于org.parboiled.common包,在下文中一共展示了Tuple2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertForeignKeys
import org.parboiled.common.Tuple2; //导入依赖的package包/类
public static void assertForeignKeys(GraphDatabaseService neo4j, Neo4jVersionerCore neo4jVersionerCore, Map<Tuple2<String, String>, Map<String, String>> relationships) {
ResourceIterator<Optional<Node>> tablesStateList = neo4j.findNodes(Label.label("Table")).map(table -> neo4jVersionerCore.findStateNode(table.getId()));
List<Relationship> foreignKeysList = tablesStateList.stream()
.map(tableStateOpt -> tableStateOpt.get().getRelationships(Direction.OUTGOING, RelationshipType.withName("RELATION")))
.flatMap(list -> StreamSupport.stream(list.spliterator(), false))
.collect(toList());
assertThat(foreignKeysList)
.hasSize(relationships.size());
relationships.forEach((keys, description) -> assertThat(foreignKeysList).anySatisfy(foreignKey -> {
assertThat(foreignKey.getStartNode().hasProperty(keys.a)).isTrue();
assertThat(foreignKey.getEndNode().hasProperty(keys.b)).isTrue();
assertThat(foreignKey.getAllProperties()).containsAllEntriesOf(description);
}));
}
示例2: shouldInitCorrectlyTheGraph
import org.parboiled.common.Tuple2; //导入依赖的package包/类
@Test
public void shouldInitCorrectlyTheGraph() throws SQLException {
initMocks(mockedDatabaseImporter,
FULLDATABASE.DATABASE(),
FULLDATABASE.SCHEMAS(),
FULLDATABASE.TABLES(),
FULLDATABASE.TABLES_COLUMNS(),
FULLDATABASE.FOREIGN_KEYS());
neo4j.getGraphDatabaseService().execute("CALL sql.versioner.init('" + MOCKED_DATABASE_NAME + "', '', 0, '', '', '')");
//Test database
assertDatabaseNode(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("databaseType", MOCKED_DATABASE_NAME, "name", "testDatabase"), 1);
//Test schema
assertSchemaNode(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("name", "testSchema"), 2);
//Test table
assertTables(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("testTable1", newHashMap("testTable1Column1", new String[]{"PRIMARY KEY", "NOT NULL"}),
"testTable2", newHashMap("testTable2Column1", new String[]{"PRIMARY KEY", "NOT NULL"},
"testTable2Column2", new String[]{"NOT NULL"})));
//Test foreign keys
assertForeignKeys(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap(
new Tuple2<>("testTable2Column2", "testTable1Column1"), newHashMap("constraint", "testConstraintName", "source_column", "testTable2Column2", "destination_column", "testTable1Column1")
));
}
示例3: Definition
import org.parboiled.common.Tuple2; //导入依赖的package包/类
public Rule Definition() {
return Sequence(
push(new Tuple2(false, true)),Identifier(),
LEFTARROW(),
Expression(), push(new DefinitionNode((ExpressionNode) pop(), (IdentifierNode) pop()))
);
}
示例4: Primary
import org.parboiled.common.Tuple2; //导入依赖的package包/类
public Rule Primary() {
return Sequence(FirstOf(
Sequence(push(new Tuple2(false,false)), Identifier(), TestNot(LEFTARROW())),
Sequence(OPEN(), Expression(), CLOSE()),
Literal(),
Class(),
DOT(),
EMPTY(),
NOTHING(),
EndOfFile()
), push(new PrimaryNode((SuperNode)pop())));
}
示例5: Identifier
import org.parboiled.common.Tuple2; //导入依赖的package包/类
@SuppressSubnodes
public Rule Identifier() {
Var<StringBuilder> id = new Var<>(new StringBuilder());
Var<ArgumentsNode> optional = new Var<>();
return Sequence(
IdentStart(), (id.get().append(match())!=null),
ZeroOrMore(IdentCont(), (id.get().append(match())!=null)),
Optional(Arguments(), optional.set((ArgumentsNode)pop())),
push(new IdentifierNode(id.get().toString(), optional.get(), (Tuple2)pop())),
Spacing()
);
}
示例6: Arguments
import org.parboiled.common.Tuple2; //导入依赖的package包/类
public Rule Arguments() {
Var<List<SuperNode>> args = new Var<>(new ArrayList<>());
return Sequence(
AOPEN(),
OneOrMore(FirstOf(Sequence(push(new Tuple2(true, ((Tuple2)peek()).b)),Identifier()), Literal()), args.get().add((SuperNode)pop())),
ACLOSE(),
push(new ArgumentsNode<>(args.get()))
);
}
示例7: lines
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all input in the given range of input lines.
*
* @param firstLine the number of the first input line to generate tracing message for
* @param lastLine the number of the last input line to generate tracing message for
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> lines(final int firstLine, final int lastLine) {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
int line = tuple.a.getInputBuffer().getPosition(tuple.a.getCurrentIndex()).line;
return firstLine <= line && line <= lastLine;
}
};
}
示例8: fromLine
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all input in the given range of input lines.
*
* @param firstLine the number of the first input line to generate tracing message for
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> fromLine(final int firstLine) {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
return tuple.a.getInputBuffer().getPosition(tuple.a.getCurrentIndex()).line >= firstLine;
}
};
}
示例9: untilLine
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all input in the given range of input lines.
*
* @param lastLine the number of the last input line to generate tracing message for
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> untilLine(final int lastLine) {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
return tuple.a.getInputBuffer().getPosition(tuple.a.getCurrentIndex()).line <= lastLine;
}
};
}
示例10: onlyRules
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all given rules (without their sub rules).
*
* @param rules the rules to generate tracing message for
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> onlyRules(final Rule... rules) {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
for (Rule rule : rules) if (tuple.a.getMatcher() == rule) return true;
return false;
}
};
}
示例11: rulesBelow
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all sub rules of the given rules.
*
* @param rules the rules whose sub rules to generate tracing message for
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> rulesBelow(final Rule... rules) {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
MatcherPath path = tuple.a.getPath();
for (Rule rule : rules) {
Matcher matcher = (Matcher) rule;
if (tuple.a.getMatcher() != matcher && path.contains(matcher)) return true;
}
return false;
}
};
}
示例12: onlyMatches
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all matched rules.
*
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> onlyMatches() {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
return tuple.b;
}
};
}
示例13: onlyMismatches
import org.parboiled.common.Tuple2; //导入依赖的package包/类
/**
* A predicate usable as a filter (element) of a {@link org.parboiled.parserunners.TracingParseRunner}.
* Enables printing of rule tracing log messages for all mismatched rules.
*
* @return a predicate
*/
public static Predicate<Tuple2<Context<?>, Boolean>> onlyMismatches() {
return new Predicate<Tuple2<Context<?>, Boolean>>() {
public boolean apply(Tuple2<Context<?>, Boolean> tuple) {
return !tuple.b;
}
};
}
示例14: shouldReloadCorrectlyTheGraphWithANewTable
import org.parboiled.common.Tuple2; //导入依赖的package包/类
@Test
public void shouldReloadCorrectlyTheGraphWithANewTable() throws SQLException {
initMocks(mockedDatabaseImporter,
FULLDATABASE.DATABASE(),
FULLDATABASE.SCHEMAS(),
FULLDATABASE.TABLES(),
FULLDATABASE.TABLES_COLUMNS(),
FULLDATABASE.FOREIGN_KEYS());
neo4j.getGraphDatabaseService().execute("CALL sql.versioner.init('" + MOCKED_DATABASE_NAME + "', '', 0, '', '', '')");
List<Table> newTables = FULLDATABASE.TABLES();
newTables.add(Table.builder()
.name("testTable3")
.foreignKeys(newArrayList())
.columns(newArrayList())
.build());
Map<String, List<TableColumn>> newTableColumns = FULLDATABASE.TABLES_COLUMNS();
newTableColumns.put("testTable3", newArrayList(TableColumn.builder()
.name("testTable3Column1")
.attributes(newArrayList("NOT NULL"))
.build()));
//TODO add relationship to table1
initMocks(mockedDatabaseImporter,
FULLDATABASE.DATABASE(),
FULLDATABASE.SCHEMAS(),
newTables,
newTableColumns,
FULLDATABASE.FOREIGN_KEYS());
neo4j.getGraphDatabaseService().execute("CALL sql.versioner.reload('', 0, '', '')");
//Test database
assertDatabaseNode(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("databaseType", MOCKED_DATABASE_NAME, "name", "testDatabase"), 1);
//Test schema
assertSchemaNode(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("name", "testSchema"), 3);
//Test table
assertTables(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap("testTable1", newHashMap("testTable1Column1", new String[]{"PRIMARY KEY", "NOT NULL"}),
"testTable2", newHashMap("testTable2Column1", new String[]{"PRIMARY KEY", "NOT NULL"},
"testTable2Column2", new String[]{"NOT NULL"}),
"testTable3", newHashMap("testTable3Column1", new String[]{"NOT NULL"})));
//Test foreign keys
assertForeignKeys(neo4j.getGraphDatabaseService(), neo4jVersionerCore,
newHashMap(
new Tuple2<>("testTable2Column2", "testTable1Column1"), newHashMap("constraint", "testConstraintName", "source_column", "testTable2Column2", "destination_column", "testTable1Column1")
));
}
示例15: IdentifierNode
import org.parboiled.common.Tuple2; //导入依赖的package包/类
public IdentifierNode(String id, ArgumentsNode args, Tuple2<Boolean,Boolean> argdef) {
super(args);
this.id = id;
this.argument = argdef.a;
this.definition = argdef.b;
}