org.apache.ibatis.reflection.wrapper.MapWrapper Java Examples

The following examples show how to use org.apache.ibatis.reflection.wrapper.MapWrapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetaObject.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.originalObject = object;
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;

  if (object instanceof ObjectWrapper) {
      //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper
    this.objectWrapper = (ObjectWrapper) object;
  } else if (objectWrapperFactory.hasWrapperFor(object)) {
      //如果有包装器,调用ObjectWrapperFactory.getWrapperFor
    this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object);
  } else if (object instanceof Map) {
      //如果是Map型,返回MapWrapper
    this.objectWrapper = new MapWrapper(this, (Map) object);
  } else if (object instanceof Collection) {
      //如果是Collection型,返回CollectionWrapper
    this.objectWrapper = new CollectionWrapper(this, (Collection) object);
  } else {
      //除此以外,返回BeanWrapper
    this.objectWrapper = new BeanWrapper(this, object);
  }
}
 
Example #2
Source File: MetaObject.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.originalObject = object;
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;

  if (object instanceof ObjectWrapper) {
      //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper
    this.objectWrapper = (ObjectWrapper) object;
  } else if (objectWrapperFactory.hasWrapperFor(object)) {
      //如果有包装器,调用ObjectWrapperFactory.getWrapperFor
    this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object);
  } else if (object instanceof Map) {
      //如果是Map型,返回MapWrapper
    this.objectWrapper = new MapWrapper(this, (Map) object);
  } else if (object instanceof Collection) {
      //如果是Collection型,返回CollectionWrapper
    this.objectWrapper = new CollectionWrapper(this, (Collection) object);
  } else {
      //除此以外,返回BeanWrapper
    this.objectWrapper = new BeanWrapper(this, object);
  }
}