Program: 33301
Project: 33301
Buggy source:
public UriResourceTypedImpl readResourcePathSegment(final PathSegmentContext ctx){
  final boolean checkFirst=context.contextUriInfo.getLastResourcePart() == null || context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl;
  String odi=ctx.vODI.getText();
  boolean searchInContainer=true;
  if (checkFirst && ctx.vNS == null && !context.contextTypes.empty()) {
    TypeInformation source=context.contextTypes.peek();
    if (source.type instanceof EdmStructuredType) {
      EdmStructuredType str=(EdmStructuredType)source.type;
      EdmElement property=str.getProperty(odi);
      if (property != null) {
        searchInContainer=false;
      }
    }
  }
  if (searchInContainer) {
    EdmEntitySet edmEntitySet=edmEntityContainer.getEntitySet(odi);
    if (edmEntitySet != null) {
      UriResourceEntitySetImpl uriResource=new UriResourceEntitySetImpl().setEntitSet(edmEntitySet);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmSingleton edmSingleton=edmEntityContainer.getSingleton(odi);
    if (edmSingleton != null) {
      UriResourceSingletonImpl uriResource=new UriResourceSingletonImpl().setSingleton(edmSingleton);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmActionImport edmActionImport=edmEntityContainer.getActionImport(odi);
    if (edmActionImport != null) {
      UriResourceActionImpl uriResource=new UriResourceActionImpl().setActionImport(edmActionImport);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmFunctionImport edmFunctionImport=edmEntityContainer.getFunctionImport(odi);
    if (edmFunctionImport != null) {
      if (ctx.vlNVO.isEmpty()) {
        throw wrap(new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.SYNTAX));
      }
      context.contextReadingFunctionParameters=true;
      @SuppressWarnings("String_Node_Str") List<UriParameterImpl> parameters=(List<UriParameterImpl>)ctx.vlNVO.get(0).accept(this);
      context.contextReadingFunctionParameters=false;
      ctx.vlNVO.remove(0);
      UriResourceFunctionImpl uriResource=new UriResourceFunctionImpl().setFunctionImport(edmFunctionImport,parameters);
      List<String> names=new ArrayList<String>();
      for (      UriParameterImpl item : parameters) {
        names.add(item.getName());
      }
      EdmFunction function=edmFunctionImport.getUnboundFunction(names);
      if (function == null) {
        String tmp="String_Node_Str";
        for (        String name : names) {
          tmp+=(tmp.length() != 0 ? "String_Node_Str" : "String_Node_Str") + name;
        }
        throw wrap(new UriParserSemanticException("String_Node_Str" + edmFunctionImport.getName() + "String_Node_Str"+ tmp+ "String_Node_Str",UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND,edmFunctionImport.getName(),tmp));
      }
      uriResource.setFunction(edmFunctionImport.getUnboundFunction(names));
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
  }
  final TypeInformation source;
  final UriResource lastResourcePart=context.contextUriInfo.getLastResourcePart();
  if (lastResourcePart == null) {
    if (context.contextTypes.empty()) {
      if (checkFirst && ctx.vNS == null) {
        throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_NOT_FOUND,odi));
      }
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS,odi));
    }
    source=context.contextTypes.peek();
  }
 else {
    source=getTypeInformation(lastResourcePart);
    if (source.type == null) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS,odi));
    }
  }
  if (ctx.vNS == null) {
    UriContext.LambdaVariables lVar=getLambdaVar(odi);
    if (lVar != null) {
      UriResourceLambdaVarImpl lambdaResource=new UriResourceLambdaVarImpl();
      lambdaResource.setVariableText(lVar.name);
      lambdaResource.setType(lVar.type);
      lambdaResource.setCollection(lVar.isCollection);
      context.contextUriInfo.addResourcePart(lambdaResource);
      return null;
    }
    if (!(source.type instanceof EdmStructuredType)) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE,odi));
    }
    if ((ctx.depth() <= 2 || lastResourcePart instanceof UriResourceTypedImpl || lastResourcePart instanceof UriResourceNavigationPropertyImpl) && source.isCollection) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION,odi));
    }
    EdmStructuredType structType=(EdmStructuredType)source.type;
    EdmElement property=structType.getProperty(odi);
    if (property == null) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str"+ structType.getFullQualifiedName().getFullQualifiedNameAsString()+ "String_Node_Str",ctx.depth() > 2 ? UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE : UriParserSemanticException.MessageKeys.PROPERTY_NOT_IN_TYPE,structType.getFullQualifiedName().getFullQualifiedNameAsString(),odi));
    }
    if (property instanceof EdmProperty) {
      if (((EdmProperty)property).isPrimitive()) {
        UriResourcePrimitivePropertyImpl simpleResource=new UriResourcePrimitivePropertyImpl().setProperty((EdmProperty)property);
        context.contextUriInfo.addResourcePart(simpleResource);
        return null;
      }
 else {
        UriResourceComplexPropertyImpl complexResource=new UriResourceComplexPropertyImpl().setProperty((EdmProperty)property);
        context.contextUriInfo.addResourcePart(complexResource);
        return null;
      }
    }
 else     if (property instanceof EdmNavigationProperty) {
      UriResourceNavigationPropertyImpl navigationResource=new UriResourceNavigationPropertyImpl().setNavigationProperty((EdmNavigationProperty)property);
      context.contextUriInfo.addResourcePart(navigationResource);
      return null;
    }
 else {
      throw wrap(new UriParserSemanticException("String_Node_Str" + property + "String_Node_Str",UriParserSemanticException.MessageKeys.UNKNOWN_PROPERTY_TYPE,property.getName()));
    }
  }
 else {
    FullQualifiedName fullFilterName=getFullNameFromContext(ctx.vNS,odi);
    if (source.type instanceof EdmEntityType) {
      EdmEntityType filterEntityType=edm.getEntityType(fullFilterName);
      if (filterEntityType != null) {
        if (!(filterEntityType.compatibleTo(source.type))) {
          throw wrap(new UriParserSemanticException("String_Node_Str" + fullFilterName.toString(),UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER,fullFilterName.toString()));
        }
        if (lastResourcePart == null) {
          UriResourceStartingTypeFilterImpl uriResource=new UriResourceStartingTypeFilterImpl().setType(filterEntityType).setCollection(source.isCollection);
          if (source.isCollection) {
            uriResource.setCollectionTypeFilter(filterEntityType);
          }
 else {
            uriResource.setEntryTypeFilter(filterEntityType);
          }
          context.contextUriInfo.addResourcePart(uriResource);
          return null;
        }
 else {
          if (lastResourcePart instanceof UriResourceWithKeysImpl) {
            UriResourceWithKeysImpl lastPartWithKeys=(UriResourceWithKeysImpl)lastResourcePart;
            if (!lastPartWithKeys.isCollection()) {
              if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnEntry())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnEntry()),getName(filterEntityType)));
              }
              lastPartWithKeys.setEntryTypeFilter(filterEntityType);
              return null;
            }
 else {
              if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnCollection())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnCollection()),getName(filterEntityType)));
              }
              lastPartWithKeys.setCollectionTypeFilter(filterEntityType);
              return null;
            }
          }
 else           if (lastResourcePart instanceof UriResourceTypedImpl) {
            UriResourceTypedImpl lastPartTyped=(UriResourceTypedImpl)lastResourcePart;
            if (lastPartTyped.getTypeFilter() != null) {
              throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartTyped.getTypeFilter())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartTyped.getTypeFilter()),getName(filterEntityType)));
            }
            lastPartTyped.setTypeFilter(filterEntityType);
            return null;
          }
 else {
            throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str",UriParserSemanticException.MessageKeys.PREVIOUS_PART_NOT_TYPED,getName(filterEntityType)));
          }
        }
      }
    }
 else     if (source.type instanceof EdmComplexType) {
      EdmComplexType filterComplexType=edm.getComplexType(fullFilterName);
      if (filterComplexType != null) {
        if (!(filterComplexType.compatibleTo(source.type))) {
          throw wrap(new UriParserSemanticException("String_Node_Str" + getName(source.type) + "String_Node_Str"+ getName(filterComplexType)+ "String_Node_Str",UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER,getName(source.type)));
        }
        if (lastResourcePart == null) {
          UriResourceStartingTypeFilterImpl uriResource=new UriResourceStartingTypeFilterImpl().setType(filterComplexType).setCollection(source.isCollection);
          if (source.isCollection) {
            uriResource.setCollectionTypeFilter(filterComplexType);
          }
 else {
            uriResource.setEntryTypeFilter(filterComplexType);
          }
          context.contextUriInfo.addResourcePart(uriResource);
          return null;
        }
 else {
          if (lastResourcePart instanceof UriResourceWithKeysImpl) {
            UriResourceWithKeysImpl lastPartWithKeys=(UriResourceWithKeysImpl)lastResourcePart;
            if (!lastPartWithKeys.isCollection()) {
              if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnEntry())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnEntry()),getName(filterComplexType)));
              }
              lastPartWithKeys.setEntryTypeFilter(filterComplexType);
              return null;
            }
 else {
              if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnCollection())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnCollection()),getName(filterComplexType)));
              }
              lastPartWithKeys.setCollectionTypeFilter(filterComplexType);
              return null;
            }
          }
 else           if (lastResourcePart instanceof UriResourceTypedImpl) {
            UriResourceTypedImpl lastPartTyped=(UriResourceTypedImpl)lastResourcePart;
            if (lastPartTyped.getTypeFilter() != null) {
              throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartTyped.getTypeFilter())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartTyped.getTypeFilter()),getName(filterComplexType)));
            }
            lastPartTyped.setTypeFilter(filterComplexType);
            return null;
          }
 else {
            throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str",UriParserSemanticException.MessageKeys.PREVIOUS_PART_NOT_TYPED,getName(filterComplexType)));
          }
        }
      }
    }
    FullQualifiedName fullBindingTypeName=new FullQualifiedName(source.type.getNamespace(),source.type.getName());
    EdmAction action=edm.getBoundAction(fullFilterName,fullBindingTypeName,source.isCollection);
    if (action != null) {
      UriResourceActionImpl pathInfoAction=new UriResourceActionImpl();
      pathInfoAction.setAction(action);
      context.contextUriInfo.addResourcePart(pathInfoAction);
      return null;
    }
    if (ctx.vlNVO.size() == 0) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + fullBindingTypeName.toString() + "String_Node_Str",UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED,fullBindingTypeName.toString()));
    }
    context.contextReadingFunctionParameters=true;
    @SuppressWarnings("String_Node_Str") List<UriParameterImpl> parameters=(List<UriParameterImpl>)ctx.vlNVO.get(0).accept(this);
    context.contextReadingFunctionParameters=false;
    List<String> names=new ArrayList<String>();
    for (    UriParameterImpl item : parameters) {
      names.add(item.getName());
    }
    EdmFunction function=edm.getBoundFunction(fullFilterName,fullBindingTypeName,source.isCollection,names);
    if (function != null) {
      UriResourceFunctionImpl pathInfoFunction=new UriResourceFunctionImpl().setFunction(function).setParameters(parameters);
      context.contextUriInfo.addResourcePart(pathInfoFunction);
      ctx.vlNVO.remove(0);
      return null;
    }
    function=edm.getUnboundFunction(fullFilterName,names);
    if (function != null) {
      UriResourceFunctionImpl pathInfoFunction=new UriResourceFunctionImpl().setFunction(function).setParameters(parameters);
      context.contextUriInfo.addResourcePart(pathInfoFunction);
      ctx.vlNVO.remove(0);
      return null;
    }
    throw wrap(new UriParserSemanticException("String_Node_Str" + fullFilterName.toString(),UriParserSemanticException.MessageKeys.UNKNOWN_PART,fullFilterName.toString()));
  }
}

Fixed version (ground truth):
public UriResourceTypedImpl readResourcePathSegment(final PathSegmentContext ctx){
  final boolean checkFirst=context.contextUriInfo.getLastResourcePart() == null || context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl;
  String odi=ctx.vODI.getText();
  boolean searchInContainer=true;
  if (checkFirst && ctx.vNS == null && !context.contextTypes.empty()) {
    TypeInformation source=context.contextTypes.peek();
    if (source.type instanceof EdmStructuredType) {
      EdmStructuredType str=(EdmStructuredType)source.type;
      EdmElement property=str.getProperty(odi);
      if (property != null) {
        searchInContainer=false;
      }
    }
  }
  if (searchInContainer) {
    EdmEntitySet edmEntitySet=edmEntityContainer.getEntitySet(odi);
    if (edmEntitySet != null) {
      UriResourceEntitySetImpl uriResource=new UriResourceEntitySetImpl().setEntitSet(edmEntitySet);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmSingleton edmSingleton=edmEntityContainer.getSingleton(odi);
    if (edmSingleton != null) {
      UriResourceSingletonImpl uriResource=new UriResourceSingletonImpl().setSingleton(edmSingleton);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmActionImport edmActionImport=edmEntityContainer.getActionImport(odi);
    if (edmActionImport != null) {
      UriResourceActionImpl uriResource=new UriResourceActionImpl().setActionImport(edmActionImport);
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
    EdmFunctionImport edmFunctionImport=edmEntityContainer.getFunctionImport(odi);
    if (edmFunctionImport != null) {
      if (ctx.vlNVO.isEmpty()) {
        throw wrap(new UriParserSyntaxException("String_Node_Str",UriParserSyntaxException.MessageKeys.SYNTAX));
      }
      context.contextReadingFunctionParameters=true;
      @SuppressWarnings("String_Node_Str") List<UriParameterImpl> parameters=(List<UriParameterImpl>)ctx.vlNVO.get(0).accept(this);
      context.contextReadingFunctionParameters=false;
      ctx.vlNVO.remove(0);
      UriResourceFunctionImpl uriResource=new UriResourceFunctionImpl().setFunctionImport(edmFunctionImport,parameters);
      List<String> names=new ArrayList<String>();
      for (      UriParameterImpl item : parameters) {
        names.add(item.getName());
      }
      EdmFunction function=edmFunctionImport.getUnboundFunction(names);
      if (function == null) {
        StringBuilder tmp=new StringBuilder();
        for (        String name : names) {
          tmp.append((tmp.length() != 0 ? "String_Node_Str" : "String_Node_Str")).append(name);
        }
        throw wrap(new UriParserSemanticException("String_Node_Str" + edmFunctionImport.getName() + "String_Node_Str"+ tmp.toString()+ "String_Node_Str",UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND,edmFunctionImport.getName(),tmp.toString()));
      }
      uriResource.setFunction(edmFunctionImport.getUnboundFunction(names));
      context.contextUriInfo.addResourcePart(uriResource);
      return null;
    }
  }
  final TypeInformation source;
  final UriResource lastResourcePart=context.contextUriInfo.getLastResourcePart();
  if (lastResourcePart == null) {
    if (context.contextTypes.empty()) {
      if (checkFirst && ctx.vNS == null) {
        throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_NOT_FOUND,odi));
      }
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS,odi));
    }
    source=context.contextTypes.peek();
  }
 else {
    source=getTypeInformation(lastResourcePart);
    if (source.type == null) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS,odi));
    }
  }
  if (ctx.vNS == null) {
    UriContext.LambdaVariables lVar=getLambdaVar(odi);
    if (lVar != null) {
      UriResourceLambdaVarImpl lambdaResource=new UriResourceLambdaVarImpl();
      lambdaResource.setVariableText(lVar.name);
      lambdaResource.setType(lVar.type);
      lambdaResource.setCollection(lVar.isCollection);
      context.contextUriInfo.addResourcePart(lambdaResource);
      return null;
    }
    if (!(source.type instanceof EdmStructuredType)) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE,odi));
    }
    if ((ctx.depth() <= 2 || lastResourcePart instanceof UriResourceTypedImpl || lastResourcePart instanceof UriResourceNavigationPropertyImpl) && source.isCollection) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str",UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION,odi));
    }
    EdmStructuredType structType=(EdmStructuredType)source.type;
    EdmElement property=structType.getProperty(odi);
    if (property == null) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + odi + "String_Node_Str"+ structType.getFullQualifiedName().getFullQualifiedNameAsString()+ "String_Node_Str",ctx.depth() > 2 ? UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE : UriParserSemanticException.MessageKeys.PROPERTY_NOT_IN_TYPE,structType.getFullQualifiedName().getFullQualifiedNameAsString(),odi));
    }
    if (property instanceof EdmProperty) {
      if (((EdmProperty)property).isPrimitive()) {
        UriResourcePrimitivePropertyImpl simpleResource=new UriResourcePrimitivePropertyImpl().setProperty((EdmProperty)property);
        context.contextUriInfo.addResourcePart(simpleResource);
        return null;
      }
 else {
        UriResourceComplexPropertyImpl complexResource=new UriResourceComplexPropertyImpl().setProperty((EdmProperty)property);
        context.contextUriInfo.addResourcePart(complexResource);
        return null;
      }
    }
 else     if (property instanceof EdmNavigationProperty) {
      UriResourceNavigationPropertyImpl navigationResource=new UriResourceNavigationPropertyImpl().setNavigationProperty((EdmNavigationProperty)property);
      context.contextUriInfo.addResourcePart(navigationResource);
      return null;
    }
 else {
      throw wrap(new UriParserSemanticException("String_Node_Str" + property + "String_Node_Str",UriParserSemanticException.MessageKeys.UNKNOWN_PROPERTY_TYPE,property.getName()));
    }
  }
 else {
    FullQualifiedName fullFilterName=getFullNameFromContext(ctx.vNS,odi);
    if (source.type instanceof EdmEntityType) {
      EdmEntityType filterEntityType=edm.getEntityType(fullFilterName);
      if (filterEntityType != null) {
        if (!(filterEntityType.compatibleTo(source.type))) {
          throw wrap(new UriParserSemanticException("String_Node_Str" + fullFilterName.toString(),UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER,fullFilterName.toString()));
        }
        if (lastResourcePart == null) {
          UriResourceStartingTypeFilterImpl uriResource=new UriResourceStartingTypeFilterImpl().setType(filterEntityType).setCollection(source.isCollection);
          if (source.isCollection) {
            uriResource.setCollectionTypeFilter(filterEntityType);
          }
 else {
            uriResource.setEntryTypeFilter(filterEntityType);
          }
          context.contextUriInfo.addResourcePart(uriResource);
          return null;
        }
 else {
          if (lastResourcePart instanceof UriResourceWithKeysImpl) {
            UriResourceWithKeysImpl lastPartWithKeys=(UriResourceWithKeysImpl)lastResourcePart;
            if (!lastPartWithKeys.isCollection()) {
              if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnEntry())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnEntry()),getName(filterEntityType)));
              }
              lastPartWithKeys.setEntryTypeFilter(filterEntityType);
              return null;
            }
 else {
              if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnCollection())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnCollection()),getName(filterEntityType)));
              }
              lastPartWithKeys.setCollectionTypeFilter(filterEntityType);
              return null;
            }
          }
 else           if (lastResourcePart instanceof UriResourceTypedImpl) {
            UriResourceTypedImpl lastPartTyped=(UriResourceTypedImpl)lastResourcePart;
            if (lastPartTyped.getTypeFilter() != null) {
              throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str"+ getName(lastPartTyped.getTypeFilter())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartTyped.getTypeFilter()),getName(filterEntityType)));
            }
            lastPartTyped.setTypeFilter(filterEntityType);
            return null;
          }
 else {
            throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterEntityType) + "String_Node_Str",UriParserSemanticException.MessageKeys.PREVIOUS_PART_NOT_TYPED,getName(filterEntityType)));
          }
        }
      }
    }
 else     if (source.type instanceof EdmComplexType) {
      EdmComplexType filterComplexType=edm.getComplexType(fullFilterName);
      if (filterComplexType != null) {
        if (!(filterComplexType.compatibleTo(source.type))) {
          throw wrap(new UriParserSemanticException("String_Node_Str" + getName(source.type) + "String_Node_Str"+ getName(filterComplexType)+ "String_Node_Str",UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER,getName(source.type)));
        }
        if (lastResourcePart == null) {
          UriResourceStartingTypeFilterImpl uriResource=new UriResourceStartingTypeFilterImpl().setType(filterComplexType).setCollection(source.isCollection);
          if (source.isCollection) {
            uriResource.setCollectionTypeFilter(filterComplexType);
          }
 else {
            uriResource.setEntryTypeFilter(filterComplexType);
          }
          context.contextUriInfo.addResourcePart(uriResource);
          return null;
        }
 else {
          if (lastResourcePart instanceof UriResourceWithKeysImpl) {
            UriResourceWithKeysImpl lastPartWithKeys=(UriResourceWithKeysImpl)lastResourcePart;
            if (!lastPartWithKeys.isCollection()) {
              if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnEntry())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnEntry()),getName(filterComplexType)));
              }
              lastPartWithKeys.setEntryTypeFilter(filterComplexType);
              return null;
            }
 else {
              if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartWithKeys.getTypeFilterOnCollection())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartWithKeys.getTypeFilterOnCollection()),getName(filterComplexType)));
              }
              lastPartWithKeys.setCollectionTypeFilter(filterComplexType);
              return null;
            }
          }
 else           if (lastResourcePart instanceof UriResourceTypedImpl) {
            UriResourceTypedImpl lastPartTyped=(UriResourceTypedImpl)lastResourcePart;
            if (lastPartTyped.getTypeFilter() != null) {
              throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str"+ getName(lastPartTyped.getTypeFilter())+ "String_Node_Str",UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE,getName(lastPartTyped.getTypeFilter()),getName(filterComplexType)));
            }
            lastPartTyped.setTypeFilter(filterComplexType);
            return null;
          }
 else {
            throw wrap(new UriParserSemanticException("String_Node_Str" + getName(filterComplexType) + "String_Node_Str",UriParserSemanticException.MessageKeys.PREVIOUS_PART_NOT_TYPED,getName(filterComplexType)));
          }
        }
      }
    }
    FullQualifiedName fullBindingTypeName=new FullQualifiedName(source.type.getNamespace(),source.type.getName());
    EdmAction action=edm.getBoundAction(fullFilterName,fullBindingTypeName,source.isCollection);
    if (action != null) {
      UriResourceActionImpl pathInfoAction=new UriResourceActionImpl();
      pathInfoAction.setAction(action);
      context.contextUriInfo.addResourcePart(pathInfoAction);
      return null;
    }
    if (ctx.vlNVO.size() == 0) {
      throw wrap(new UriParserSemanticException("String_Node_Str" + fullBindingTypeName.toString() + "String_Node_Str",UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED,fullBindingTypeName.toString()));
    }
    context.contextReadingFunctionParameters=true;
    @SuppressWarnings("String_Node_Str") List<UriParameterImpl> parameters=(List<UriParameterImpl>)ctx.vlNVO.get(0).accept(this);
    context.contextReadingFunctionParameters=false;
    List<String> names=new ArrayList<String>();
    for (    UriParameterImpl item : parameters) {
      names.add(item.getName());
    }
    EdmFunction function=edm.getBoundFunction(fullFilterName,fullBindingTypeName,source.isCollection,names);
    if (function != null) {
      UriResourceFunctionImpl pathInfoFunction=new UriResourceFunctionImpl().setFunction(function).setParameters(parameters);
      context.contextUriInfo.addResourcePart(pathInfoFunction);
      ctx.vlNVO.remove(0);
      return null;
    }
    function=edm.getUnboundFunction(fullFilterName,names);
    if (function != null) {
      UriResourceFunctionImpl pathInfoFunction=new UriResourceFunctionImpl().setFunction(function).setParameters(parameters);
      context.contextUriInfo.addResourcePart(pathInfoFunction);
      ctx.vlNVO.remove(0);
      return null;
    }
    throw wrap(new UriParserSemanticException("String_Node_Str" + fullFilterName.toString(),UriParserSemanticException.MessageKeys.UNKNOWN_PART,fullFilterName.toString()));
  }
}