Refine search
/** * Intercepts a method call to a proxy. * * @param instance The proxied instance. * @param method The invoked method. * @param arguments The intercepted method arguments. * * @return The method's return value. * * @throws Throwable If the intercepted method raises an exception. */ @RuntimeType Object intercept(@This Object instance, @Origin Method method, @AllArguments Object[] arguments) throws Throwable; }
/** * Loads a method constant onto the operand stack. * * @param origin The origin annotation. * @param methodDescription The method description to load. * @return An appropriate stack manipulation. */ private static StackManipulation methodConstant(Origin origin, MethodDescription.InDefinedShape methodDescription) { MethodConstant.CanCache methodConstant = origin.privileged() ? MethodConstant.ofPrivileged(methodDescription) : MethodConstant.of(methodDescription); return origin.cache() ? methodConstant.cached() : methodConstant; }
@RuntimeType public static Set getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); return thiz.traverse(input -> { switch (direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).toSet(VertexFrame.class); } }
@RuntimeType public static Iterator getEdges(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: return thiz.traverse(input -> input.bothE(label)).frame(VertexFrame.class); case IN: return thiz.traverse(input -> input.inE(label)).frame(VertexFrame.class); case OUT: return thiz.traverse(input -> input.outE(label)).frame(VertexFrame.class); default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { throw new UnsupportedOperationException("Please use RLiveObjectService instance for this type of functions"); } }
@RuntimeType public ContextProperty getter(@Origin Method method, @This ViewContextBase that) { return that.properties().get(method.getName()); } }
public static void removeProperty(@This final ElementFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Property annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Property.class); final String propertyName = annotation.value(); Element element = thiz.getElement(); if (element instanceof Vertex) thiz.getGraph().getRawTraversal().V(element.id()).properties(propertyName).drop().iterate(); else thiz.getGraph().getRawTraversal().E(element.id()).properties(propertyName).drop().iterate(); thiz.getElement().property(propertyName).remove(); } }
public static void intercept(@This SebElement element, @Origin(cache = true) Method method, @AllArguments Object[] arguments) throws Exception { if (!method.isAnnotationPresent(DisableLazyInit.class)) { element.init(); } }
public static void removeProperty(@This final ElementFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Property annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Property.class); final String value = annotation.value(); thiz.getElement().property(value).remove(); } }
@RuntimeType public static Iterator getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); return thiz.traverse(input -> { switch(direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).frame(VertexFrame.class); } }
@RuntimeType public static Set getEdges(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: return thiz.traverse(input -> input.bothE(label)).toSet(VertexFrame.class); case IN: return thiz.traverse(input -> input.inE(label)).toSet(VertexFrame.class); case OUT: return thiz.traverse(input -> input.outE(label)).toSet(VertexFrame.class); default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { throw new UnsupportedOperationException("Please use RLiveObjectService instance for this type of functions"); } }
@RuntimeType public static Object getVertex(@This final EdgeFrame thiz, @Origin final Method method) { return thiz.traverse(GraphTraversal::inV).next(method.getReturnType()); } }
public static void removeProperty(@This final ElementFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Property annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Property.class); final String propertyName = annotation.value(); Element element = thiz.getElement(); if (element instanceof Vertex) thiz.getGraph().getRawTraversal().V(element.id()).properties(propertyName).drop().iterate(); else thiz.getGraph().getRawTraversal().E(element.id()).properties(propertyName).drop().iterate(); thiz.getElement().property(propertyName).remove(); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @This Object me, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { if (args.length >= 1 && String.class.isAssignableFrom(args[0].getClass())) { String name = ((String) args[0]).substring(0, 1).toUpperCase() + ((String) args[0]).substring(1); if ("get".equals(method.getName()) && args.length == 1) { try { return me.getClass().getMethod("get" + name).invoke(me); } catch (NoSuchMethodException noSuchMethodException) { throw new NoSuchFieldException((String) args[0]); } } else if ("set".equals(method.getName()) && args.length == 2) { Method m = ClassUtils.searchForMethod(me.getClass(), "set" + name, new Class[]{args[1].getClass()}); if (m != null) { return m.invoke(me, args[1]); } else { throw new NoSuchFieldException((String) args[0]); } } } throw new NoSuchMethodException(method.getName() + " has wrong signature"); } }
@RuntimeType public static List getVertexes(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class); final Direction direction = annotation.direction(); final String label = annotation.label(); return thiz.traverse(input -> { switch (direction) { case IN: return input.in(label); case OUT: return input.out(label); case BOTH: return input.both(label); default: throw new IllegalStateException("Direction not recognized."); } }).toList(VertexFrame.class); } }
@RuntimeType public static Set getEdges(@This final VertexFrame thiz, @Origin final Method method) { assert thiz instanceof CachesReflection; final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class); final Direction direction = annotation.direction(); final String label = annotation.label(); switch (direction) { case BOTH: return thiz.traverse(input -> input.bothE(label)).toSet(VertexFrame.class); case IN: return thiz.traverse(input -> input.inE(label)).toSet(VertexFrame.class); case OUT: return thiz.traverse(input -> input.outE(label)).toSet(VertexFrame.class); default: throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT."); } } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { Class<?>[] cls = new Class[args.length]; for (int i = 0; i < args.length; i++) { cls[i] = args[i].getClass(); } return ClassUtils.searchForMethod(RMap.class, method.getName(), cls).invoke(map, args); } }
@RuntimeType public static void removeEdge(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final EdgeFrame edge) { edge.remove(); } }
@RuntimeType public static Object intercept( @Origin Method method, @AllArguments Object[] args, @This Object me, @FieldValue("liveObjectLiveMap") RMap<?, ?> map ) throws Exception { if (args.length >= 1 && String.class.isAssignableFrom(args[0].getClass())) { String name = ((String) args[0]).substring(0, 1).toUpperCase() + ((String) args[0]).substring(1); if ("get".equals(method.getName()) && args.length == 1) { try { return me.getClass().getMethod("get" + name).invoke(me); } catch (NoSuchMethodException noSuchMethodException) { throw new NoSuchFieldException((String) args[0]); } } else if ("set".equals(method.getName()) && args.length == 2) { Method m = ClassUtils.searchForMethod(me.getClass(), "set" + name, new Class[]{args[1].getClass()}); if (m != null) { return m.invoke(me, args[1]); } else { throw new NoSuchFieldException((String) args[0]); } } } throw new NoSuchMethodException(method.getName() + " has wrong signature"); } }