之间有什么区别吗?
方法1:
TraversalDescription one = new TraversalDescriptionImpl();
one = one.breadthFirst()
.relationships(RelType.KNOWS, Direction.OUTGOING)
.evaluator(Evaluators.excludeStartPosition());
Traverser t1 = one.traverse(node);
方法2:
TraversalDescription two = Traversal.description()
.breadthFirst()
.relationships(RelType.KNOWS, Direction.OUTGOING)
.evaluator(Evaluators.excludeStartPosition());
Traverser t2 = one.traverse(node);
两个Traversers似乎都提供了相同的结果。有一种方法优于另一种方法吗?何时以及为何?
答案 0 :(得分:3)
类TraversalDescriptionImpl
的对象是工厂类Traversal
在调用Traversal.description()
时将返回的对象。从Traversal
类来源剪断:
public static TraversalDescription description() {
return new TraversalDescriptionImpl();
}
因此,
TraversalDescription one = new TraversalDescriptionImpl();
与
相同TraversalDescription two = Traversal.description()