Method getName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Method getName method.

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:getName
  /** 
   * Remove the prefix "get", if any, from the method name. Return the 
   * capacitalized method name." 
   */ 
  protected String getName(Method method) {
    String methodName = method.getName();
    if (methodName.startsWith("get")) {
      return StringUtils.capitalize(methodName.substring(3));
    } 
    return StringUtils.capitalize(methodName);
  } 
 
  protected MetricsInfo getInfo(Metric annotation, String defaultName) {
    String[] value = annotation.value();
    if (value.length == 2) {
      // Use name and description from the annotation 
      return Interns.info(value[0], value[1]);
    } 
    if (value.length == 1) {
      // Use description from the annotation and method name as metric name 
9
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:isAccessible, setAccessible, equals, getDeclaringClass, getName
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    { 
        if (constructed)
        { 
 
            String methodName = method.getName();
            int params = args.length;
 
            if (params == 0)
            { 
                if (isUninitialized() && method.equals(getIdentifierMethod))
                { 
                    return getIdentifier(); 
                } 
 
                else if ("getKunderaLazyInitializer".equals(methodName))
                { 
                    return this;
                } 
            } 

8
CodeRank
This code example shows how to use the following methods:getName
    public AnimalListener(StringBuilder sb) {
        this.sb = sb;
    } 
 
    public boolean beforeInvoke(Object obj, Method method, Object... args) {
        sb.append("B:").append(method.getName()).append(args.length).append(';');
        return true; 
    } 
 
    public Object afterInvoke(Object obj, Object returnObj, Method method, Object... args) {
        sb.append("A:").append(method.getName()).append(args.length).append(';');
        return returnObj;
    } 
 
    public boolean whenError(Throwable e, Object obj, Method method, Object... args) {
        sb.append("E:").append(method.getName()).append(';');
        return false; 
    } 
 
    public boolean whenException(Exception e, Object obj, Method method, Object... args) {
9
CodeRank
This code example shows how to use the following methods:equals, getName, getParameterTypes, isBridge
	 * consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged} 
	 * by the supplied {@link Method bridge Method}. This method performs inexpensive 
	 * checks and can be used quickly filter for a set of possible matches. 
	 */ 
	private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
		return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
				candidateMethod.getName().equals(bridgeMethod.getName()) &&
				candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
	} 
 
	/** 
	 * Searches for the bridged method in the given candidates. 
	 * @param candidateMethods the List of candidate Methods 
	 * @param bridgeMethod the bridge method 
	 * @return the bridged method, or {@code null} if none found 
	 */ 
	private static Method searchCandidates(List<Method> candidateMethods, Method bridgeMethod) {
		if (candidateMethods.isEmpty()) {
			return null; 
		} 
8
CodeRank
This code example shows how to use the following methods:getDeclaringClass, getModifiers, getName, getParameterTypes
		private final Method method;
 
		private final String identifier;
 
		public LifecycleElement(Method method) {
			if (method.getParameterTypes().length != 0) {
				throw new IllegalStateException("Lifecycle method annotation requires a no-arg method: " + method);
			} 
			this.method = method;
			this.identifier = (Modifier.isPrivate(method.getModifiers()) ?
					method.getDeclaringClass() + "." + method.getName() : method.getName());
		} 
 
		public Method getMethod() {
			return this.method;
		} 
 
		public String getIdentifier() {
			return this.identifier;
		} 
7
CodeRank
This code example shows how to use the following methods:getName, invoke
 
	@Override 
	public Object invoke(Object proxy, Method method, Object[] arguments)
		throws Throwable {
 
		String methodName = method.getName();
 
		try { 
			if (methodName.equals("getPrimaryTestSuiteName") ||
				methodName.equals("setPrimaryTestSuiteName")) {
			} 
			else if (methodName.equals("pauseLoggerCheck")) {
				_logger.pauseLoggerCheck(); 
			} 
			else if (methodName.equals("saveScreenshot")) {
				_logger.logScreenShots(); 
			} 
			else if (methodName.equals("sendActionDescriptionLogger")) {
				_logger.logActionDescription(arguments); 
			} 

7
CodeRank
This code example shows how to use the following methods:getName
	 * @see java.lang.Object#toString() 
	 */ 
	@Override 
	public String toString() {
		return (this.target == null ? "" : this.target.getClass().getName())+"."
		+ (this.method == null ? "" : this.method.getName()) + " with args "
		+ (this.args == null ? "null" : this.args);
	} 
	 
	 
} 
9
CodeRank
This code example shows how to use the following methods:getName, getParameterTypes
	 */ 
	private class ServiceLocatorInvocationHandler implements InvocationHandler {
 
		@Override 
		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
			if (ReflectionUtils.isEqualsMethod(method)) {
				// Only consider equal when proxies are identical. 
				return (proxy == args[0]); 
			} 
			else if (ReflectionUtils.isHashCodeMethod(method)) {
				// Use hashCode of service locator proxy. 
				return System.identityHashCode(proxy);
			} 
			else if (ReflectionUtils.isToStringMethod(method)) {
				return "Service locator: " + serviceLocatorInterface.getName();
			} 
			else { 
				return invokeServiceLocatorMethod(method, args);
			} 
		} 

7
CodeRank

Related Method getName Questions & Answers:

getName Method Overview
Returns the name of the method represented by this Method object, as a String.
See Code Examples for other Java 8 Method Methods: