org.jgroups.util.Util.findMethod()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中org.jgroups.util.Util.findMethod()方法的一些代码示例,展示了Util.findMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.findMethod()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:findMethod

Util.findMethod介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

  1. public static Method findMethod(Object target,List<String> possible_names,Class<?>... parameter_types) {
  2. if(target == null)
  3. return null;
  4. return findMethod(target.getClass(),possible_names,parameter_types);
  5. }

代码示例来源:origin: wildfly/wildfly

  1. /** Finds an accessor for an attribute. Tries to find setAttrName(), attrName() methods. If not
  2. * found, tries to use reflection to set the value of attr_name. If still not found, creates a NullAccessor. */
  3. public static Accessor findSetter(Object target, String attr_name) {
  4. final String name=Util.attributeNameToMethodName(attr_name);
  5. final String fluent_name=toLowerCase(name);
  6. Class<?> clazz=target.getClass();
  7. Class<?> field_type=null;
  8. Field field=Util.getField(clazz, attr_name);
  9. field_type=field != null? field.getType() : null;
  10. String setter_name="set" + name;
  11. if(field_type != null) {
  12. Method method=Util.findMethod(target, Arrays.asList(fluent_name, setter_name), field_type);
  13. if(method != null && isSetMethod(method))
  14. return new MethodAccessor(method, target);
  15. }
  16. // Find all methods but don't include methods from Object class
  17. List<Method> methods=new ArrayList<>(Arrays.asList(clazz.getMethods()));
  18. methods.removeAll(OBJECT_METHODS);
  19. for(Method method: methods) {
  20. String method_name=method.getName();
  21. if((method_name.equals(name) || method_name.equals(fluent_name) || method_name.equals(setter_name)) && isSetMethod(method))
  22. return new MethodAccessor(method, target);
  23. }
  24. // Find a field last_name
  25. if(field != null)
  26. return new FieldAccessor(field, target);
  27. return null;
  28. }

代码示例来源:origin: wildfly/wildfly

  1. /** Finds an accessor for an attribute. Tries to find getAttrName(), isAttrName(), attrName() methods. If not
  2. * found, tries to use reflection to get the value of attr_name. If still not found, creates a NullAccessor. */
  3. protected static Accessor findGetter(Object target, String attr_name) {
  4. final String name=Util.attributeNameToMethodName(attr_name);
  5. Class<?> clazz=target.getClass();
  6. Method method=Util.findMethod(target, Arrays.asList("get" + name, "is" + name, toLowerCase(name)));
  7. if(method != null && (isGetMethod(method) || isIsMethod(method)))
  8. return new MethodAccessor(method, target);
  9. // 4. Find a field last_name
  10. Field field=Util.getField(clazz, attr_name);
  11. if(field != null)
  12. return new FieldAccessor(field, target);
  13. return new NoopAccessor();
  14. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public static Method findMethod(Object target,List<String> possible_names,Class<?>... parameter_types) {
  2. if(target == null)
  3. return null;
  4. return findMethod(target.getClass(),possible_names,parameter_types);
  5. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. /** Finds an accessor for an attribute. Tries to find setAttrName(), attrName() methods. If not
  2. * found, tries to use reflection to set the value of attr_name. If still not found, creates a NullAccessor. */
  3. public static Accessor findSetter(Object target, String attr_name) {
  4. final String name=Util.attributeNameToMethodName(attr_name);
  5. final String fluent_name=toLowerCase(name);
  6. Class<?> clazz=target.getClass();
  7. Class<?> field_type=null;
  8. Field field=Util.getField(clazz, attr_name);
  9. field_type=field != null? field.getType() : null;
  10. String setter_name="set" + name;
  11. if(field_type != null) {
  12. Method method=Util.findMethod(target, Arrays.asList(fluent_name, setter_name), field_type);
  13. if(method != null && isSetMethod(method))
  14. return new MethodAccessor(method, target);
  15. }
  16. // Find all methods but don't include methods from Object class
  17. List<Method> methods=new ArrayList<>(Arrays.asList(clazz.getMethods()));
  18. methods.removeAll(OBJECT_METHODS);
  19. for(Method method: methods) {
  20. String method_name=method.getName();
  21. if((method_name.equals(name) || method_name.equals(fluent_name) || method_name.equals(setter_name)) && isSetMethod(method))
  22. return new MethodAccessor(method, target);
  23. }
  24. // Find a field last_name
  25. if(field != null)
  26. return new FieldAccessor(field, target);
  27. return null;
  28. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. /** Finds an accessor for an attribute. Tries to find getAttrName(), isAttrName(), attrName() methods. If not
  2. * found, tries to use reflection to get the value of attr_name. If still not found, creates a NullAccessor. */
  3. protected static Accessor findGetter(Object target, String attr_name) {
  4. final String name=Util.attributeNameToMethodName(attr_name);
  5. Class<?> clazz=target.getClass();
  6. Method method=Util.findMethod(target, Arrays.asList("get" + name, "is" + name, toLowerCase(name)));
  7. if(method != null && (isGetMethod(method) || isIsMethod(method)))
  8. return new MethodAccessor(method, target);
  9. // 4. Find a field last_name
  10. Field field=Util.getField(clazz, attr_name);
  11. if(field != null)
  12. return new FieldAccessor(field, target);
  13. return new NoopAccessor();
  14. }

相关文章

Util类方法