Java 8 Method - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Method class.

This code example shows how to use the following methods:invoke
                        + " injection has completed to use this object."); 
            } 
 
            try { 
                // This appears to be not test-covered 
                return method.invoke(delegate, args);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            } catch (IllegalArgumentException e) {
                throw new RuntimeException(e);
            } catch (InvocationTargetException e) {
                throw e.getTargetException();
            } 
        } 
 
        void setDelegate(T delegate) {
            this.delegate = delegate;
        } 
    } 
} 
10
CodeRank
This code example shows how to use the following methods:getName, getParameterTypes
        if (configuration.getBootstrapConfiguration().isExecutableValidationEnabled()) {
            final Set<ConstraintViolation<Object>> constraintViolations = Sets.newHashSet();
            final Method handlingMethod = resourceMethod.getHandlingMethod();
 
            final BeanDescriptor beanDescriptor = getConstraintsForClass(resource.getClass());
            final MethodDescriptor methodDescriptor = beanDescriptor.getConstraintsForMethod(handlingMethod.getName(),
                    handlingMethod.getParameterTypes());
 
            final Method definitionMethod = resourceMethod.getDefinitionMethod();
 
            if (methodDescriptor != null
                    && methodDescriptor.hasConstrainedReturnValue()
                    && validateOnExecutionHandler.validateMethod(resource.getClass(), definitionMethod, handlingMethod)) {
                constraintViolations.addAll(forExecutables().validateReturnValue(resource, handlingMethod, result));
 
                if (result instanceof Response) {
                    constraintViolations.addAll(forExecutables().validateReturnValue(resource, handlingMethod,
                            ((Response) result).getEntity()));
                } 
            } 

10
CodeRank
This code example shows how to use the following methods:getName, getParameterTypes
 
    private final int hashCode;
 
 
    public EJBBusinessMethod(Method method) {
        this(method.getName(), method.getParameterTypes());
    } 
 
    public EJBBusinessMethod(String methodName, Class<?>... methodParamTypes) {
        this(MethodIntf.BEAN, methodName, methodParamTypes);
    } 
 
    public EJBBusinessMethod(MethodIntf view, String methodName, Class<?>... paramTypes) {
        if (methodName == null) {
            throw MESSAGES.methodNameIsNull(); 
        } 
        this.methodName = methodName;
        this.methodParamTypes = paramTypes == null ? new Class<?>[0] : paramTypes;
        this.viewType = view == null ? MethodIntf.BEAN : view;
 
10
CodeRank
This code example shows how to use the following methods:invoke
                final Method oldMethod = context.getMethod();
                try { 
                    if (this.lifecycleMethod) {
                        // because InvocationContext#getMethod() is expected to return null for lifecycle methods 
                        context.setMethod(null);
                        return method.invoke(instance, context.getInvocationContext());
                    } else if (this.changeMethod) {
                        context.setMethod(method);
                        return method.invoke(instance, context.getInvocationContext());
                    } else { 
                        return method.invoke(instance, context.getInvocationContext());
                    } 
                } finally { 
                    // reset any changed method on the interceptor context 
                    context.setMethod(oldMethod);
                } 
            } else { 
                method.invoke(instance);
                return context.proceed();
            } 

10
CodeRank
This code example shows how to use the following methods:getName
	private int countThrows = 0;
 
	@Override 
	public void before(Method method, Object[] objects, Object o) throws Throwable {
		countBefore++;
		System.out.println("Method:"+method.getName());
	} 
 
	public void afterThrowing(Exception e) throws Throwable {
		countThrows++;
		System.out.println("***********************************************************************************");
		System.out.println("Exception caught:");
		System.out.println("***********************************************************************************");
		e.printStackTrace();
		throw e;
	} 
 
	public int getCountBefore() { 
		return countBefore;
	} 
10
CodeRank
This code example shows how to use the following methods:invoke
	   } 
	    
	   private static void setDatabaseEnabled(boolean e) throws IOException {
		   try 
		   { 
			   mWebSettings_setDatabaseEnabled.invoke(e);
		   } 
		   catch (InvocationTargetException ite) {
	           /* unpack original exception when possible */ 
	           Throwable cause = ite.getCause();
	           if (cause instanceof IOException) {
	               throw (IOException) cause;
	           } else if (cause instanceof RuntimeException) {
	               throw (RuntimeException) cause;
	           } else if (cause instanceof Error) {
	               throw (Error) cause;
	           } else { 
	               /* unexpected checked exception; wrap and re-throw */ 
	               throw new RuntimeException(ite);
	           } 
10
CodeRank
This code example shows how to use the following methods:getParameterTypes, invoke, isVarArgs
 
	@Override 
	public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException {
		try { 
			if (arguments != null) {
				this.argumentConversionOccurred = ReflectionHelper.convertArguments(context.getTypeConverter(), arguments, this.method, this.varargsPosition);
			} 
			if (this.method.isVarArgs()) {
				arguments = ReflectionHelper.setupArgumentsForVarargsInvocation(this.method.getParameterTypes(), arguments);
			} 
			ReflectionUtils.makeAccessible(this.method);
			Object value = this.method.invoke(target, arguments);
			return new TypedValue(value, new TypeDescriptor(new MethodParameter(this.method, -1)).narrow(value));
		} 
		catch (Exception ex) {
			throw new AccessException("Problem invoking method: " + this.method, ex);
		} 
	} 
 
} 
9
CodeRank
This code example shows how to use the following methods:getParameterTypes
            throw PojoMessages.MESSAGES.notValueConfig(previous);
 
        ValueConfig vc = (ValueConfig) previous;
        BeanInfo beanInfo = visitor.getBeanInfo();
        Method m = beanInfo.findMethod(methodName, Configurator.getTypes(parameters));
        return m.getParameterTypes()[vc.getIndex()];
    } 
 
    public String getMethodName() {
        return methodName;
    } 
 
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    } 
 
    public ValueConfig[] getParameters() { 
        return parameters;
    } 
 
9
CodeRank
This code example shows how to use the following methods:getName
	@Override 
	public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
 
		Object returnValue = null;
 
		if (method.getName().equals("getCreateAccountURL")) {
			HttpServletRequest httpServletRequest = (HttpServletRequest) arguments[0];
			ThemeDisplay themeDisplay = (ThemeDisplay) arguments[1];
			returnValue = getCreateAccountURL(httpServletRequest, themeDisplay);
		} 
		else { 
			returnValue = super.invoke(proxy, method, arguments);
		} 
 
		return returnValue;
	} 
 
	protected String getCreateAccountURL(HttpServletRequest request, ThemeDisplay themeDisplay) throws Exception {
 
		String portletName = "1_WAR_jsf2registrationportlet";
9
CodeRank
This code example shows how to use the following methods:invoke
	} 
 
	public static void apply(SharedPreferences.Editor editor) {
		if (sApplyMethod != null) {
			try { 
				sApplyMethod.invoke(editor);
				return; 
			} catch (InvocationTargetException unused) {
				// fall through 
			} catch (IllegalAccessException unused) {
				// fall through 
			} 
		} 
		editor.commit();
	} 
} 
10
CodeRank

Related Java 8 Method Questions & Answers:

See Code Examples for Java 8 Method Methods: