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() . These examples are extracted from open source projects. 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 Project: mybaties   File: MetaClass.java    License: 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 Project: mybatis   File: MetaClass.java    License: 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 Project: mybaties   File: MapWrapper.java    License: 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 Project: mybaties   File: MapWrapper.java    License: 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 Project: mybaties   File: BeanWrapper.java    License: 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 Project: mybaties   File: BeanWrapper.java    License: 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 Project: mybatis   File: MapWrapper.java    License: 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 Project: mybatis   File: MapWrapper.java    License: 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 Project: mybatis   File: BeanWrapper.java    License: 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 Project: mybatis   File: BeanWrapper.java    License: 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);
  }
}