Java Code Examples for org.apache.ibatis.reflection.property.PropertyTokenizer#getIndex()

The following examples show how to use org.apache.ibatis.reflection.property.PropertyTokenizer#getIndex() . 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: MetaClass.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private Class<?> getGetterType(PropertyTokenizer prop) {
  Class<?> type = reflector.getGetterType(prop.getName());
  if (prop.getIndex() != null && Collection.class.isAssignableFrom(type)) {
    Type returnType = getGenericGetterType(prop.getName());
    if (returnType instanceof ParameterizedType) {
      Type[] actualTypeArguments = ((ParameterizedType) returnType).getActualTypeArguments();
      if (actualTypeArguments != null && actualTypeArguments.length == 1) {
        returnType = actualTypeArguments[0];
        if (returnType instanceof Class) {
          type = (Class<?>) returnType;
        } else if (returnType instanceof ParameterizedType) {
          type = (Class<?>) ((ParameterizedType) returnType).getRawType();
        }
      }
    }
  }
  return type;
}
 
Example 2
Source File: MetaClass.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private Class<?> getGetterType(PropertyTokenizer prop) {
  Class<?> type = reflector.getGetterType(prop.getName());
  if (prop.getIndex() != null && Collection.class.isAssignableFrom(type)) {
    Type returnType = getGenericGetterType(prop.getName());
    if (returnType instanceof ParameterizedType) {
      Type[] actualTypeArguments = ((ParameterizedType) returnType).getActualTypeArguments();
      if (actualTypeArguments != null && actualTypeArguments.length == 1) {
        returnType = actualTypeArguments[0];
        if (returnType instanceof Class) {
          type = (Class<?>) returnType;
        } else if (returnType instanceof ParameterizedType) {
          type = (Class<?>) ((ParameterizedType) returnType).getRawType();
        }
      }
    }
  }
  return type;
}
 
Example 3
Source File: MapWrapper.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Override
public Object get(PropertyTokenizer prop) {
    //如果有index,说明是集合,那就要分解集合,调用的是BaseWrapper.resolveCollection 和 getCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, map);
    return getCollectionValue(prop, collection);
  } else {
    return map.get(prop.getName());
  }
}
 
Example 4
Source File: MapWrapper.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Override
public void set(PropertyTokenizer prop, Object value) {
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, map);
    setCollectionValue(prop, collection, value);
  } else {
    map.put(prop.getName(), value);
  }
}
 
Example 5
Source File: BeanWrapper.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Override
public Object get(PropertyTokenizer prop) {
    //如果有index(有中括号),说明是集合,那就要解析集合,调用的是BaseWrapper.resolveCollection 和 getCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, object);
    return getCollectionValue(prop, collection);
  } else {
      //否则,getBeanProperty
    return getBeanProperty(prop, object);
  }
}
 
Example 6
Source File: BeanWrapper.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Override
public void set(PropertyTokenizer prop, Object value) {
    //如果有index,说明是集合,那就要解析集合,调用的是BaseWrapper.resolveCollection 和 setCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, object);
    setCollectionValue(prop, collection, value);
  } else {
      //否则,setBeanProperty
    setBeanProperty(prop, object, value);
  }
}
 
Example 7
Source File: MapWrapper.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Override
public Object get(PropertyTokenizer prop) {
    //如果有index,说明是集合,那就要分解集合,调用的是BaseWrapper.resolveCollection 和 getCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, map);
    return getCollectionValue(prop, collection);
  } else {
    return map.get(prop.getName());
  }
}
 
Example 8
Source File: MapWrapper.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Override
public void set(PropertyTokenizer prop, Object value) {
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, map);
    setCollectionValue(prop, collection, value);
  } else {
    map.put(prop.getName(), value);
  }
}
 
Example 9
Source File: BeanWrapper.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Override
public Object get(PropertyTokenizer prop) {
    //如果有index(有中括号),说明是集合,那就要解析集合,调用的是BaseWrapper.resolveCollection 和 getCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, object);
    return getCollectionValue(prop, collection);
  } else {
      //否则,getBeanProperty
    return getBeanProperty(prop, object);
  }
}
 
Example 10
Source File: BeanWrapper.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Override
public void set(PropertyTokenizer prop, Object value) {
    //如果有index,说明是集合,那就要解析集合,调用的是BaseWrapper.resolveCollection 和 setCollectionValue
  if (prop.getIndex() != null) {
    Object collection = resolveCollection(prop, object);
    setCollectionValue(prop, collection, value);
  } else {
      //否则,setBeanProperty
    setBeanProperty(prop, object, value);
  }
}