/** * Implementers should not override this method. Note that this method utilizes reflection to check for * feature support. */ default boolean supports(final Class<? extends FeatureSet> featureClass, final String feature) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Object instance; if (featureClass.equals(GraphFeatures.class)) instance = this.graph(); else if (featureClass.equals(VariableFeatures.class)) instance = this.graph().variables(); else if (featureClass.equals(VertexFeatures.class)) instance = this.vertex(); else if (featureClass.equals(VertexPropertyFeatures.class)) instance = this.vertex().properties(); else if (featureClass.equals(EdgeFeatures.class)) instance = this.edge(); else if (featureClass.equals(EdgePropertyFeatures.class)) instance = this.edge().properties(); else if (featureClass.equals(PropertyFeatures.class)) throw new IllegalArgumentException(String.format( "Do not reference PropertyFeatures directly in tests, utilize a specific instance: %s, %s", EdgePropertyFeatures.class, VertexPropertyFeatures.class)); else throw new IllegalArgumentException(String.format( "Expecting featureClass to be a valid Feature instance and not %s", featureClass)); return (Boolean) featureClass.getMethod("supports" + feature).invoke(instance); } }
public static String featureString(final Graph.Features features) { final StringBuilder sb = new StringBuilder("FEATURES"); final Predicate<Method> supportMethods = (m) -> m.getModifiers() == Modifier.PUBLIC && m.getName().startsWith(featuresStartWith) && !m.getName().equals(featuresStartWith); sb.append(LINE_SEPARATOR); Stream.of(Pair.with(Graph.Features.GraphFeatures.class, features.graph()), Pair.with(Graph.Features.VariableFeatures.class, features.graph().variables()), Pair.with(Graph.Features.VertexFeatures.class, features.vertex()), Pair.with(Graph.Features.VertexPropertyFeatures.class, features.vertex().properties()), Pair.with(Graph.Features.EdgeFeatures.class, features.edge()), Pair.with(Graph.Features.EdgePropertyFeatures.class, features.edge().properties())).forEach(p -> { printFeatureTitle(p.getValue0(), sb); Stream.of(p.getValue0().getMethods()) .filter(supportMethods) .map(createTransform(p.getValue1())) .forEach(sb::append); }); return sb.toString(); }
/** * Implementers should not override this method. Note that this method utilizes reflection to check for * feature support. */ default boolean supports(final Class<? extends FeatureSet> featureClass, final String feature) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Object instance; if (featureClass.equals(GraphFeatures.class)) instance = this.graph(); else if (featureClass.equals(VariableFeatures.class)) instance = this.graph().variables(); else if (featureClass.equals(VertexFeatures.class)) instance = this.vertex(); else if (featureClass.equals(VertexPropertyFeatures.class)) instance = this.vertex().properties(); else if (featureClass.equals(EdgeFeatures.class)) instance = this.edge(); else if (featureClass.equals(EdgePropertyFeatures.class)) instance = this.edge().properties(); else if (featureClass.equals(PropertyFeatures.class)) throw new IllegalArgumentException(String.format( "Do not reference PropertyFeatures directly in tests, utilize a specific instance: %s, %s", EdgePropertyFeatures.class, VertexPropertyFeatures.class)); else throw new IllegalArgumentException(String.format( "Expecting featureClass to be a valid Feature instance and not %s", featureClass)); return (Boolean) featureClass.getMethod("supports" + feature).invoke(instance); } }
public static String featureString(final Graph.Features features) { final StringBuilder sb = new StringBuilder("FEATURES"); final Predicate<Method> supportMethods = (m) -> m.getModifiers() == Modifier.PUBLIC && m.getName().startsWith(featuresStartWith) && !m.getName().equals(featuresStartWith); sb.append(LINE_SEPARATOR); Stream.of(Pair.with(Graph.Features.GraphFeatures.class, features.graph()), Pair.with(Graph.Features.VariableFeatures.class, features.graph().variables()), Pair.with(Graph.Features.VertexFeatures.class, features.vertex()), Pair.with(Graph.Features.VertexPropertyFeatures.class, features.vertex().properties()), Pair.with(Graph.Features.EdgeFeatures.class, features.edge()), Pair.with(Graph.Features.EdgePropertyFeatures.class, features.edge().properties())).forEach(p -> { printFeatureTitle(p.getValue0(), sb); Stream.of(p.getValue0().getMethods()) .filter(supportMethods) .map(createTransform(p.getValue1())) .forEach(sb::append); }); return sb.toString(); }
@Before public void innerSetup() { final Graph.Features f = graph.features(); edgeFeatures = f.edge(); edgePropertyFeatures = edgeFeatures.properties(); graphFeatures = f.graph(); variablesFeatures = graphFeatures.variables(); vertexFeatures = f.vertex(); vertexPropertyFeatures = vertexFeatures.properties(); }
@Before public void innerSetup() { final Graph.Features f = graph.features(); edgeFeatures = f.edge(); edgePropertyFeatures = edgeFeatures.properties(); graphFeatures = f.graph(); variablesFeatures = graphFeatures.variables(); vertexFeatures = f.vertex(); vertexPropertyFeatures = vertexFeatures.properties(); }