Search in sources :

Example 1 with TFunction

use of org.oasisopen.odata.csdl.v4.TFunction in project odata-client by davidmoten.

the class Util method replaceAlias.

private static void replaceAlias(Schema schema, Object x) {
    if (schema.getAlias() == null) {
        return;
    }
    if (x instanceof TEntityType) {
        TEntityType p = (TEntityType) x;
        // mutate types to use alias
        p.setBaseType(replaceAlias(schema, p.getBaseType()));
        // 
        p.getKeyOrPropertyOrNavigationProperty().forEach(y -> replaceAlias(schema, y));
    } else if (x instanceof TComplexType) {
        TComplexType p = (TComplexType) x;
        // mutate types to use alias
        p.setBaseType(replaceAlias(schema, p.getBaseType()));
        // 
        p.getPropertyOrNavigationPropertyOrAnnotation().forEach(y -> replaceAlias(schema, y));
    } else if (x instanceof TAction) {
        TAction a = (TAction) x;
        // 
        a.getParameterOrAnnotationOrReturnType().forEach(y -> replaceAlias(schema, y));
    } else if (x instanceof TFunction) {
        TFunction a = (TFunction) x;
        // 
        a.getParameterOrAnnotation().forEach(y -> replaceAlias(schema, y));
        replaceAlias(schema, a.getReturnType());
    } else if (x instanceof TActionFunctionParameter) {
        TActionFunctionParameter p = (TActionFunctionParameter) x;
        replaceAlias(schema, p.getType());
    } else if (x instanceof TActionFunctionReturnType) {
        TActionFunctionReturnType p = (TActionFunctionReturnType) x;
        replaceAlias(schema, p.getType());
    } else if (x instanceof TProperty) {
        TProperty p = (TProperty) x;
        replaceAlias(schema, p.getType());
    } else if (x instanceof TNavigationProperty) {
        TNavigationProperty p = (TNavigationProperty) x;
        replaceAlias(schema, p.getType());
    } else if (x instanceof TAnnotations) {
        TAnnotations a = (TAnnotations) x;
        a.setTarget(replaceAlias(schema, a.getTarget()));
    } else if (x instanceof TEntityContainer) {
        TEntityContainer a = (TEntityContainer) x;
        Util.filter(a.getEntitySetOrActionImportOrFunctionImport(), TEntitySet.class).forEach(y -> replaceAlias(schema, y));
    } else if (x instanceof TEntitySet) {
        TEntitySet a = (TEntitySet) x;
        a.setEntityType(replaceAlias(schema, a.getEntityType()));
    }
}
Also used : TEntitySet(org.oasisopen.odata.csdl.v4.TEntitySet) TNavigationProperty(org.oasisopen.odata.csdl.v4.TNavigationProperty) Collection(java.util.Collection) TActionFunctionParameter(org.oasisopen.odata.csdl.v4.TActionFunctionParameter) Collectors(java.util.stream.Collectors) VisibleForTesting(com.github.davidmoten.guavamini.annotations.VisibleForTesting) TEntityContainer(org.oasisopen.odata.csdl.v4.TEntityContainer) List(java.util.List) Stream(java.util.stream.Stream) TAnnotations(org.oasisopen.odata.csdl.v4.TAnnotations) TActionFunctionReturnType(org.oasisopen.odata.csdl.v4.TActionFunctionReturnType) TFunction(org.oasisopen.odata.csdl.v4.TFunction) TAction(org.oasisopen.odata.csdl.v4.TAction) TComplexType(org.oasisopen.odata.csdl.v4.TComplexType) TProperty(org.oasisopen.odata.csdl.v4.TProperty) Pattern(java.util.regex.Pattern) Schema(org.oasisopen.odata.csdl.v4.Schema) TEntityType(org.oasisopen.odata.csdl.v4.TEntityType) TAnnotations(org.oasisopen.odata.csdl.v4.TAnnotations) TFunction(org.oasisopen.odata.csdl.v4.TFunction) TAction(org.oasisopen.odata.csdl.v4.TAction) TProperty(org.oasisopen.odata.csdl.v4.TProperty) TNavigationProperty(org.oasisopen.odata.csdl.v4.TNavigationProperty) TEntityType(org.oasisopen.odata.csdl.v4.TEntityType) TComplexType(org.oasisopen.odata.csdl.v4.TComplexType) TActionFunctionParameter(org.oasisopen.odata.csdl.v4.TActionFunctionParameter) TEntityContainer(org.oasisopen.odata.csdl.v4.TEntityContainer) TActionFunctionReturnType(org.oasisopen.odata.csdl.v4.TActionFunctionReturnType) TEntitySet(org.oasisopen.odata.csdl.v4.TEntitySet)

Aggregations

VisibleForTesting (com.github.davidmoten.guavamini.annotations.VisibleForTesting)1 Collection (java.util.Collection)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Schema (org.oasisopen.odata.csdl.v4.Schema)1 TAction (org.oasisopen.odata.csdl.v4.TAction)1 TActionFunctionParameter (org.oasisopen.odata.csdl.v4.TActionFunctionParameter)1 TActionFunctionReturnType (org.oasisopen.odata.csdl.v4.TActionFunctionReturnType)1 TAnnotations (org.oasisopen.odata.csdl.v4.TAnnotations)1 TComplexType (org.oasisopen.odata.csdl.v4.TComplexType)1 TEntityContainer (org.oasisopen.odata.csdl.v4.TEntityContainer)1 TEntitySet (org.oasisopen.odata.csdl.v4.TEntitySet)1 TEntityType (org.oasisopen.odata.csdl.v4.TEntityType)1 TFunction (org.oasisopen.odata.csdl.v4.TFunction)1 TNavigationProperty (org.oasisopen.odata.csdl.v4.TNavigationProperty)1 TProperty (org.oasisopen.odata.csdl.v4.TProperty)1