org.neo4j.driver.v1.types.Node.labels()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中org.neo4j.driver.v1.types.Node.labels()方法的一些代码示例,展示了Node.labels()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.labels()方法的具体详情如下:
包路径:org.neo4j.driver.v1.types.Node
类名称:Node
方法名:labels

Node.labels介绍

[英]Return all labels.
[中]返回所有标签。

代码示例

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

  1. private Object toNode(Object value, boolean virtual, Map<Long, Object> nodesCache) {
  2. Value internalValue = ((InternalEntity) value).asValue();
  3. Node node = internalValue.asNode();
  4. if (virtual) {
  5. List<Label> labels = new ArrayList<>();
  6. node.labels().forEach(l -> labels.add(Label.label(l)));
  7. VirtualNode virtualNode = new VirtualNode(node.id(), labels.toArray(new Label[0]), node.asMap(), db);
  8. nodesCache.put(node.id(), virtualNode);
  9. return virtualNode;
  10. } else
  11. return Util.map("entityType", internalValue.type().name(), "labels", node.labels(), "id", node.id(), "properties", node.asMap());
  12. }

代码示例来源:origin: neo4j/neo4j-ogm

  1. public List<String> labels(Object value) {
  2. Node node = (Node) value;
  3. List<String> labels = new ArrayList<>();
  4. for (String label : node.labels()) {
  5. labels.add(label);
  6. }
  7. return labels;
  8. }

代码示例来源:origin: org.neo4j/neo4j-ogm-bolt-driver

  1. public List<String> labels(Object value) {
  2. Node node = (Node) value;
  3. List<String> labels = new ArrayList<>();
  4. for (String label : node.labels()) {
  5. labels.add(label);
  6. }
  7. return labels;
  8. }

代码示例来源:origin: neo4j/cypher-shell

  1. @Nonnull static String collectNodeLabels(@Nonnull Node node) {
  2. StringBuilder sb = new StringBuilder();
  3. node.labels().forEach(label -> sb.append(COLON).append(escape(label)));
  4. return sb.toString();
  5. }

代码示例来源:origin: net.iot-solutions.graphdb/jcypher

  1. @Override
  2. public List<GrLabel> getNodeLabels(long nodeId, int rowIndex) {
  3. List<GrLabel> labels = new ArrayList<GrLabel>();
  4. if (rowIndex >= 0) {
  5. Node nd = (Node) getPropertiesObject(nodeId, rowIndex, ElemType.NODE);
  6. for (String lab : nd.labels()) {
  7. GrLabel label = GrAccess.createLabel(lab);
  8. GrAccess.setState(label, SyncState.SYNC);
  9. labels.add(label);
  10. }
  11. }
  12. return labels;
  13. }

代码示例来源:origin: Wolfgang-Schuetzelhofer/jcypher

  1. @Override
  2. public List<GrLabel> getNodeLabels(long nodeId, int rowIndex) {
  3. List<GrLabel> labels = new ArrayList<GrLabel>();
  4. if (rowIndex >= 0) {
  5. Node nd = (Node) getPropertiesObject(nodeId, rowIndex, ElemType.NODE);
  6. for (String lab : nd.labels()) {
  7. GrLabel label = GrAccess.createLabel(lab);
  8. GrAccess.setState(label, SyncState.SYNC);
  9. labels.add(label);
  10. }
  11. }
  12. return labels;
  13. }

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

  1. public Neo4jBoltNode(Node value) {
  2. this.id = String.valueOf(value.id());
  3. this.types = Iterables.asList(value.labels());
  4. this.propertyContainer = new Neo4jBoltPropertyContainer(value.asMap());
  5. }

代码示例来源:origin: neo4j/cypher-shell

  1. @Test
  2. public void prettyPrintNode() throws Exception {
  3. // given
  4. BoltResult result = mock(BoltResult.class);
  5. Record record = mock(Record.class);
  6. Value value = mock(Value.class);
  7. Node node = mock(Node.class);
  8. HashMap<String, Object> propertiesAsMap = new HashMap<>();
  9. propertiesAsMap.put("prop1", "prop1_value");
  10. propertiesAsMap.put("prop2", "prop2_value");
  11. when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.NODE());
  12. when(value.asNode()).thenReturn(node);
  13. when(node.labels()).thenReturn(asList("label1", "label2"));
  14. when(node.asMap(anyObject())).thenReturn(unmodifiableMap(propertiesAsMap));
  15. when(record.keys()).thenReturn(asList("col1", "col2"));
  16. when(record.values()).thenReturn(asList(value));
  17. when(result.getRecords()).thenReturn(asList(record));
  18. when(result.getSummary()).thenReturn(mock(ResultSummary.class));
  19. // when
  20. String actual = plainPrinter.format(result);
  21. // then
  22. assertThat(actual, is("col1, col2\n" +
  23. "(:label1:label2 {prop2: prop2_value, prop1: prop1_value})"));
  24. }

代码示例来源:origin: neo4j/cypher-shell

  1. when(start.labels()).thenReturn(asList("start"));
  2. when(start.id()).thenReturn(1l);
  3. when(end.labels()).thenReturn(asList("end"));
  4. when(end.id()).thenReturn(2l);

代码示例来源:origin: neo4j/cypher-shell

  1. when(node.labels()).thenReturn(asList("label `1", "label2"));
  2. when(node.asMap(anyObject())).thenReturn(unmodifiableMap(nodeProp));

代码示例来源:origin: neo4j/cypher-shell

  1. when(start.labels()).thenReturn(asList("start"));
  2. when(start.id()).thenReturn(1l);
  3. when(second.labels()).thenReturn(asList("second"));
  4. when(second.id()).thenReturn(2l);
  5. when(third.labels()).thenReturn(asList("third"));
  6. when(third.id()).thenReturn(3l);
  7. when(end.labels()).thenReturn(asList("end"));
  8. when(end.id()).thenReturn(4l);

代码示例来源:origin: neo4j/cypher-shell

  1. HashMap<String, Object> startProperties = new HashMap<>();
  2. startProperties.put("prop1", "prop1_value");
  3. when(start.labels()).thenReturn(asList("start"));
  4. when(start.id()).thenReturn(1l);
  5. when(middle.labels()).thenReturn(asList("middle"));
  6. when(middle.id()).thenReturn(2l);
  7. HashMap<String, Object> endProperties = new HashMap<>();
  8. endProperties.put("prop2", "prop2_value");
  9. when(end.labels()).thenReturn(asList("end"));
  10. when(end.id()).thenReturn(3l);

代码示例来源:origin: neo4j/cypher-shell

  1. when(n1.id()).thenReturn(1L);
  2. List<String> labels = asList("L1");
  3. when(n1.labels()).thenReturn(labels);
  4. when(n1.asMap(anyObject())).thenReturn(Collections.emptyMap());
  5. when(n2.labels()).thenReturn(asList("L2"));
  6. when(n2.asMap(anyObject())).thenReturn(Collections.emptyMap());
  7. when(n3.labels()).thenReturn(asList("L3"));
  8. when(n3.asMap(anyObject())).thenReturn(Collections.emptyMap());

相关文章