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()));
}
}
Aggregations