• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PropertyNamer类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.ibatis.reflection.property.PropertyNamer的典型用法代码示例。如果您正苦于以下问题:Java PropertyNamer类的具体用法?Java PropertyNamer怎么用?Java PropertyNamer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PropertyNamer类属于org.apache.ibatis.reflection.property包,在下文中一共展示了PropertyNamer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addGetMethods

点赞 3

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
private void addGetMethods(Class<?> cls) {
  Map<String, List<Method>> conflictingGetters = new HashMap<String, List<Method>>();
  Method[] methods = getClassMethods(cls);
  for (Method method : methods) {
    String name = method.getName();
    if (name.startsWith("get") && name.length() > 3) {
      if (method.getParameterTypes().length == 0) {
        name = PropertyNamer.methodToProperty(name);
        addMethodConflict(conflictingGetters, name, method);
      }
    } else if (name.startsWith("is") && name.length() > 2) {
      if (method.getParameterTypes().length == 0) {
        name = PropertyNamer.methodToProperty(name);
        addMethodConflict(conflictingGetters, name, method);
      }
    }
  }
  resolveGetterConflicts(conflictingGetters);
}
 

开发者ID:yuexiahandao,
项目名称:MybatisCode,
代码行数:20,
代码来源:Reflector.java

示例2: addGetMethods

点赞 3

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
private void addGetMethods(Class<?> cls) {
  Map<String, List<Method>> conflictingGetters = new HashMap<String, List<Method>>();
  //这里getter和setter都调用了getClassMethods,有点浪费效率了。不妨把addGetMethods,addSetMethods合并成一个方法叫addMethods
  Method[] methods = getClassMethods(cls);
  for (Method method : methods) {
    String name = method.getName();
    if (name.startsWith("get") && name.length() > 3) {
      if (method.getParameterTypes().length == 0) {
        name = PropertyNamer.methodToProperty(name);
        addMethodConflict(conflictingGetters, name, method);
      }
    } else if (name.startsWith("is") && name.length() > 2) {
      if (method.getParameterTypes().length == 0) {
        name = PropertyNamer.methodToProperty(name);
        addMethodConflict(conflictingGetters, name, method);
      }
    }
  }
  resolveGetterConflicts(conflictingGetters);
}
 

开发者ID:shurun19851206,
项目名称:mybaties,
代码行数:21,
代码来源:Reflector.java

示例3: addGetMethods

点赞 3

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
private void addGetMethods(Class<?> cls) {
  Map<String, List<Method>> conflictingGetters = new HashMap<String, List<Method>>();
  Method[] methods = getClassMethods(cls);
  for (Method method : methods) {
    if (method.getParameterTypes().length > 0) {
      continue;
    }
    String name = method.getName();
    if ((name.startsWith("get") && name.length() > 3)
        || (name.startsWith("is") && name.length() > 2)) {
      name = PropertyNamer.methodToProperty(name);
      addMethodConflict(conflictingGetters, name, method);
    }
  }
  resolveGetterConflicts(conflictingGetters);
}
 

开发者ID:mybatis,
项目名称:mybatis-3,
代码行数:17,
代码来源:Reflector.java

示例4: addSetMethods

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
private void addSetMethods(Class<?> cls) {
  Map<String, List<Method>> conflictingSetters = new HashMap<String, List<Method>>();
  Method[] methods = getClassMethods(cls);
  for (Method method : methods) {
    String name = method.getName();
    if (name.startsWith("set") && name.length() > 3) {
      if (method.getParameterTypes().length == 1) {
        name = PropertyNamer.methodToProperty(name);
        addMethodConflict(conflictingSetters, name, method);
      }
    }
  }
  resolveSetterConflicts(conflictingSetters);
}
 

开发者ID:yuexiahandao,
项目名称:MybatisCode,
代码行数:15,
代码来源:Reflector.java

示例5: invoke

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
@Override
public Object invoke(Object enhanced, Method method, Method methodProxy, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invoke(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:yuexiahandao,
项目名称:MybatisCode,
代码行数:37,
代码来源:JavassistProxyFactory.java

示例6: intercept

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:yuexiahandao,
项目名称:MybatisCode,
代码行数:37,
代码来源:CglibProxyFactory.java

示例7: invoke

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
@Override
public Object invoke(Object enhanced, Method method, Method methodProxy, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invoke(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:txazo,
项目名称:mybatis,
代码行数:37,
代码来源:JavassistProxyFactory.java

示例8: intercept

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:txazo,
项目名称:mybatis,
代码行数:37,
代码来源:CglibProxyFactory.java

示例9: intercept

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
    	//这里是关键,延迟加载就是调用ResultLoaderMap.loadAll()
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
          	//或者调用ResultLoaderMap.load()
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:shurun19851206,
项目名称:mybaties,
代码行数:39,
代码来源:CglibProxyFactory.java

示例10: invoke

点赞 2

import org.apache.ibatis.reflection.property.PropertyNamer; //导入依赖的package包/类
public final Object invoke(Object enhanced, Method method, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    if (WRITE_REPLACE_METHOD.equals(methodName)) {
      final Object original;
      if (constructorArgTypes.isEmpty()) {
        original = objectFactory.create(type);
      } else {
        original = objectFactory.create(type, constructorArgTypes, constructorArgs);
      }

      PropertyCopier.copyBeanProperties(type, enhanced, original);
      return this.newSerialStateHolder(original, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
    } else {
      synchronized (this.reloadingPropertyLock) {
        if (!FINALIZE_METHOD.equals(methodName) && PropertyNamer.isProperty(methodName) && !reloadingProperty) {
          final String property = PropertyNamer.methodToProperty(methodName);
          final String propertyKey = property.toUpperCase(Locale.ENGLISH);
          if (unloadedProperties.containsKey(propertyKey)) {
            final ResultLoaderMap.LoadPair loadPair = unloadedProperties.remove(propertyKey);
            if (loadPair != null) {
              try {
                reloadingProperty = true;
                loadPair.load(enhanced);
              } finally {
                reloadingProperty = false;
              }
            } else {
              /* I'm not sure if this case can really happen or is just in tests -
               * we have an unread property but no loadPair to load it. */
              throw new ExecutorException("An attempt has been made to read a not loaded lazy property '"
                      + property + "' of a disconnected object");
            }
          }
        }

        return enhanced;
      }
    }
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 

开发者ID:yuexiahandao,
项目名称:MybatisCode,
代码行数:44,
代码来源:AbstractEnhancedDeserializationProxy.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)