1717package org .polypheny .jdbc .multimodel ;
1818
1919import java .util .ArrayList ;
20-
2120import java .util .Iterator ;
2221import java .util .List ;
2322import java .util .NoSuchElementException ;
@@ -41,29 +40,30 @@ public class GraphResult extends Result implements Iterable<PolyGraphElement> {
4140 private final List <PolyGraphElement > elements ;
4241
4342
44-
4543 public GraphResult ( Frame frame , PolyStatement polyStatement ) {
4644 super ( ResultType .GRAPH );
47- this .polyStatement = polyStatement ;
45+ this .polyStatement = polyStatement ;
4846 this .isFullyFetched = frame .getIsLast ();
4947 this .elements = new ArrayList <>();
50- addGraphElements (frame .getGraphFrame ());
48+ addGraphElements ( frame .getGraphFrame () );
5149 }
5250
51+
5352 private void addGraphElements ( GraphFrame graphFrame ) {
54- if (graphFrame .getNodesCount () > 0 ) {
55- graphFrame .getNodesList ().forEach ( n -> elements .add ( new PolyNode (n ) ) );
53+ if ( graphFrame .getNodesCount () > 0 ) {
54+ graphFrame .getNodesList ().forEach ( n -> elements .add ( new PolyNode ( n ) ) );
5655 return ;
5756 }
58- if (graphFrame .getEdgesCount () > 0 ) {
59- graphFrame .getEdgesList ().forEach ( n -> elements .add ( new PolyEdge (n ) ) );
57+ if ( graphFrame .getEdgesCount () > 0 ) {
58+ graphFrame .getEdgesList ().forEach ( n -> elements .add ( new PolyEdge ( n ) ) );
6059 return ;
6160 }
62- if (graphFrame .getPathsCount () > 0 ) {
63- graphFrame .getPathsList ().forEach ( n -> elements .add ( new PolyPath (n ) ) );
61+ if ( graphFrame .getPathsCount () > 0 ) {
62+ graphFrame .getPathsList ().forEach ( n -> elements .add ( new PolyPath ( n ) ) );
6463 }
6564 }
6665
66+
6767 private void fetchMore () throws PrismInterfaceServiceException {
6868 int id = polyStatement .getStatementId ();
6969 int timeout = getPolyphenyConnection ().getTimeout ();
@@ -78,6 +78,7 @@ private void fetchMore() throws PrismInterfaceServiceException {
7878 addGraphElements ( frame .getGraphFrame () );
7979 }
8080
81+
8182 private PolyConnection getPolyphenyConnection () {
8283 return polyStatement .getConnection ();
8384 }
@@ -87,12 +88,18 @@ private PrismInterfaceClient getPrismInterfaceClient() {
8788 return getPolyphenyConnection ().getPrismInterfaceClient ();
8889 }
8990
91+
9092 @ Override
91- public Iterator <PolyGraphElement > iterator () {return new GraphElementIterator ();}
93+ public Iterator <PolyGraphElement > iterator () {
94+ return new GraphElementIterator ();
95+ }
96+
9297
9398 class GraphElementIterator implements Iterator <PolyGraphElement > {
99+
94100 int index = -1 ;
95101
102+
96103 @ Override
97104 public boolean hasNext () {
98105 if ( index + 1 >= elements .size () ) {
@@ -108,15 +115,16 @@ public boolean hasNext() {
108115 return index + 1 < elements .size ();
109116 }
110117
118+
111119 @ Override
112120 public PolyGraphElement next () {
113121 if ( !hasNext () ) {
114122 throw new NoSuchElementException ( "There are no more graph elements" );
115123 }
116124 return elements .get ( ++index );
117125 }
118- }
119126
127+ }
120128
121129
122130}
0 commit comments