⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 methods.java

📁 一个关于java 的常用工具包
💻 JAVA
字号:
package org.jutil.java.reflect;import java.lang.reflect.*;import java.util.*;import org.jutil.java.collections.Filter;import org.jutil.java.collections.Accumulator;/** * Utility methods for method reflection. * * @path    $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/java/reflect/Methods.java,v $ * @version $Revision: 1.8 $ * @date    $Date: 2002/05/20 15:01:36 $ * @state   $State: Exp $ * @author  Jan Dockx * @release $Name:  $ */public class Methods {  	/* The revision of this class */	public final static String CVS_REVISION ="$Revision: 1.8 $";  /**   * <p>All methods that are usable in the class. These are all the methods   * declared in <class>, and all public, protected and package accessible   * methods defined in super types (classes or interfaces).</p>   * <p>Since the result is a set, overwritten methods only occur once.</p>   * <p>The term methods in this context includes instance and class methods,   * but not constructors.<p>   *   * @param  clazz   *         The class to get all applicable methods for.   * @return instances of java.lang.reflect.AccessibleObject   //JDJDJD Java 1.2   * @return instances of java.lang.reflect.Member   */ /*@   @ // The given Class must be effective.   @ pre clazz != null;   @   @ // The result is Member   @ post \result instanceof Member;   @*/  //MvDMvDMvD : ask Jan what this should do. I think it behaves weird.  static public Set getAllApplicableMethods(Class clazz) {    return (Set)new Accumulator() {                      public Object initialAccumulator() {                        return new HashSet();                      }                      public Object accumulate(Object element, Object acc) {                        Class clazzElement = (Class)element;                        Set allMethods = (Set)acc;                        Set declaredMethods = new HashSet(Arrays.asList(clazzElement.getDeclaredMethods()));                        allMethods.addAll(declaredMethods);                        return allMethods;                      }                    }.accumulate(Classes.getSuperTypes(clazz));  }  //MvDMvDMvD : spec and test this.    public static final Filter PUBLIC_ACCESS_FILTER =      new Filter() {            public boolean criterion(Object element) {              return (Modifier.isPublic(((Member)element).getModifiers()));            }          };  public static final Filter PROTECTED_ACCESS_FILTER =      new Filter() {            public boolean criterion(Object element) {              return (Modifier.isProtected(((Member)element).getModifiers()));            }          };  public static final Filter PACKAGE_ACCESS_FILTER =      new Filter() {            public boolean criterion(Object element) {              int modifiers = ((Member)element).getModifiers();              return (!(Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPublic(modifiers)));            }          };  public static final Filter PRIVATE_ACCESS_FILTER =      new Filter() {            public boolean criterion(Object element) {              return (Modifier.isPrivate(((Member)element).getModifiers()));            }          };  public static final Filter ABSTRACT_FILTER =      new Filter() {            public boolean criterion(Object element) {              return (Modifier.isAbstract(((Member)element).getModifiers()));            }          };}/*<copyright>Copyright (C) 1997-2001. This software is copyrighted by the people and entities mentioned after the "@author" tags above, on behalf of the JUTIL.ORG Project. The copyright is dated by the dates after the "@date" tags above. All rights reserved.This software is published under the terms of the JUTIL.ORG SoftwareLicense version 1.1 or later, a copy of which has been included withthis distribution in the LICENSE file, which can also be found athttp://org-jutil.sourceforge.net/LICENSE. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the JUTIL.ORG Software License for more details.For more information, please see http://org-jutil.sourceforge.net/</copyright>*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -