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

The following examples show how to use org.apache.ibatis.reflection.wrapper.ObjectWrapper. 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);
  }
}
 
Example #3
Source File: JPAObjectWrapperFactory.java    From genericdao with Artistic License 2.0 5 votes vote down vote up
@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
    log.info("返回{}的objectWrapper对象。",object.getClass().getName());

    ObjectWrapper objectWrapper = new JpaBeanWrapper(metaObject , object) ;

    return objectWrapper ;
}
 
Example #4
Source File: MapWrapperFactory.java    From scaffold-cloud with MIT License 4 votes vote down vote up
@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
    return new MyMapWrapper(metaObject, (Map) object);
}
 
Example #5
Source File: MetaObject.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getObjectWrapper() {
  return objectWrapper;
}
 
Example #6
Source File: CustomObjectWrapperFactory.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
  return new org.apache.ibatis.submitted.custom_collection_handling.CustomObjectWrapper((CustomCollection) object);
}
 
Example #7
Source File: CustomBeanWrapperFactory.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
  return new CustomBeanWrapper(metaObject, object);
}
 
Example #8
Source File: MetaObject.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getObjectWrapper() {
  return objectWrapper;
}
 
Example #9
Source File: CustomObjectWrapperFactory.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
  return new org.apache.ibatis.submitted.custom_collection_handling.CustomObjectWrapper((CustomCollection) object);
}
 
Example #10
Source File: CustomBeanWrapperFactory.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
  return new CustomBeanWrapper(metaObject, object);
}