Unverified Commit d5590765 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥
Browse files

fix: fixes to work with Titan DB 1.1.x

parent ace5dbf0
...@@ -15,15 +15,12 @@ ...@@ -15,15 +15,12 @@
*/ */
package com.syncleus.ferma; package com.syncleus.ferma;
import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Element; import org.apache.tinkerpop.gremlin.structure.Element;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
public class DefaultTraversable<PE, E> implements Traversable<PE, E>{ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{
final private GraphTraversal<PE, E> baseTraversal; final private GraphTraversal<PE, E> baseTraversal;
...@@ -59,18 +56,26 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{ ...@@ -59,18 +56,26 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{
@Override @Override
public <N> N nextOrDefault(final Class<N> kind, final N defaultValue) { public <N> N nextOrDefault(final Class<N> kind, final N defaultValue) {
if (baseTraversal.hasNext()) try {
return next(kind); if (baseTraversal.hasNext())
else return next(kind);
else
return defaultValue;
} catch (IllegalAccessError e) {
return defaultValue; return defaultValue;
}
} }
@Override @Override
public <N> N nextOrDefaultExplicit(final Class<N> kind, final N defaultValue) { public <N> N nextOrDefaultExplicit(final Class<N> kind, final N defaultValue) {
if (baseTraversal.hasNext()) try {
return nextExplicit(kind); if (baseTraversal.hasNext())
else return nextExplicit(kind);
else
return defaultValue;
} catch (IllegalAccessError e) {
return defaultValue; return defaultValue;
}
} }
@Override @Override
...@@ -125,22 +130,30 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{ ...@@ -125,22 +130,30 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{
@Override @Override
public <N> List<? extends N> next(final int amount, final Class<N> kind) { public <N> List<? extends N> next(final int amount, final Class<N> kind) {
return Lists.transform((List<Element>) this.baseTraversal.next(amount), new com.google.common.base.Function<Element, N>() { try {
@Override return Lists.transform((List<Element>) this.baseTraversal.next(amount), new com.google.common.base.Function<Element, N>() {
public N apply(final Element input) { @Override
return parentGraph.frameElement(input, kind); public N apply(final Element input) {
} return parentGraph.frameElement(input, kind);
}); }
});
} catch (IllegalAccessError e) {
return Collections.emptyList();
}
} }
@Override @Override
public <N> List<? extends N> nextExplicit(final int amount, final Class<N> kind) { public <N> List<? extends N> nextExplicit(final int amount, final Class<N> kind) {
return Lists.transform((List<Element>) this.baseTraversal.next(amount), new com.google.common.base.Function<Element, N>() { try {
@Override return Lists.transform((List<Element>) this.baseTraversal.next(amount), new com.google.common.base.Function<Element, N>() {
public N apply(final Element input) { @Override
return parentGraph.frameElementExplicit(input, kind); public N apply(final Element input) {
} return parentGraph.frameElementExplicit(input, kind);
}); }
});
} catch (IllegalAccessError e) {
return Collections.emptyList();
}
} }
@Override @Override
...@@ -175,22 +188,30 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{ ...@@ -175,22 +188,30 @@ public class DefaultTraversable<PE, E> implements Traversable<PE, E>{
@Override @Override
public <N> List<? extends N> toList(final Class<N> kind) { public <N> List<? extends N> toList(final Class<N> kind) {
return Lists.transform((List<Element>) this.baseTraversal.toList(), new com.google.common.base.Function<Element, N>() { try {
@Override return Lists.transform((List<Element>) this.baseTraversal.toList(), new com.google.common.base.Function<Element, N>() {
public N apply(final Element input) { @Override
return parentGraph.frameElement(input, kind); public N apply(final Element input) {
} return parentGraph.frameElement(input, kind);
}); }
});
} catch (IllegalAccessError e) {
return Collections.emptyList();
}
} }
@Override @Override
public <N> List<? extends N> toListExplicit(final Class<N> kind) { public <N> List<? extends N> toListExplicit(final Class<N> kind) {
return Lists.transform((List<Element>) this.baseTraversal.toList(), new com.google.common.base.Function<Element, N>() { try {
@Override return Lists.transform((List<Element>) this.baseTraversal.toList(), new com.google.common.base.Function<Element, N>() {
public N apply(final Element input) { @Override
return parentGraph.frameElementExplicit(input, kind); public N apply(final Element input) {
} return parentGraph.frameElementExplicit(input, kind);
}); }
});
} catch (IllegalAccessError e) {
return Collections.emptyList();
}
} }
@Override @Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment