@SuppressWarnings({ "unchecked", "rawtypes" })
  protected Object convertList(CachingPojoPath currentPath, PojoPathContext context, PojoPathState state, Object arrayOrCollection) {

    Object arrayOrList = arrayOrCollection;
    if (arrayOrCollection instanceof Collection) {
      if (!(arrayOrCollection instanceof List)) {
        // non-list collection (e.g. Set) - create Proxy-List
        if (state.cachingDisabled) {
          PojoPathCachingDisabledException cachingException = new PojoPathCachingDisabledException(currentPath.getPojoPath());
          throw new PojoPathAccessException(cachingException, currentPath.getPojoPath(), arrayOrCollection.getClass());
        }
        String collection2ListPath = currentPath.getPojoPath() + PATH_SUFFIX_COLLECTION_LIST;
        CachingPojoPath listPath = state.getCachedPath(collection2ListPath);
        if (listPath == null) {
          listPath = new CachingPojoPath(collection2ListPath);
          listPath.parent = currentPath;
          listPath.pojo = new CollectionList((Collection) arrayOrCollection);
          state.setCachedPath(collection2ListPath, listPath);
        }
        arrayOrList = listPath.pojo;
      }
    }
    return arrayOrList;
  }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) protected Object convertList ( CachingPojoPath currentPath , PojoPathContext context , PojoPathState state , Object arrayOrCollection ) { Object arrayOrList = arrayOrCollection ; if ( arrayOrCollection instanceof Collection ) { if ( ! ( arrayOrCollection instanceof List ) ) { if ( state . cachingDisabled ) { PojoPathCachingDisabledException cachingException = new PojoPathCachingDisabledException ( currentPath . getPojoPath ( ) ) ; throw new PojoPathAccessException ( cachingException , currentPath . getPojoPath ( ) , arrayOrCollection . getClass ( ) ) ; } String collection2ListPath = currentPath . getPojoPath ( ) + PATH_SUFFIX_COLLECTION_LIST ; CachingPojoPath listPath = state . getCachedPath ( collection2ListPath ) ; if ( listPath == null ) { listPath = new CachingPojoPath ( collection2ListPath ) ; listPath . parent = currentPath ; listPath . pojo = new CollectionList ( ( Collection ) arrayOrCollection ) ; state . setCachedPath ( collection2ListPath , listPath ) ; } arrayOrList = listPath . pojo ; } } return arrayOrList ; }
This method converts the given {@code arrayOrCollection} to a {@link List} as necessary.

@param currentPath is the current {@link CachingPojoPath} that lead to {@code arrayOrCollection}.
@param context is the {@link PojoPathContext context} for this operation.
@param state is the {@link #createState(Object, String, PojoPathMode, PojoPathContext) state} to use.
@param arrayOrCollection is the object to be accessed at a given index.
@return a {@link List} that adapts {@code arrayOrCollection} if it is a {@link Collection} but NOT a {@link List}.
Otherwise the given {@code arrayOrCollection} itself.