Skip to content

Commit 09e4ecc

Browse files
committed
- adds missing navigation properties on composable functions in java
1 parent 2c04586 commit 09e4ecc

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

Templates/Java/requests_extensions/BaseMethodRequestBuilder.java.tt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,37 @@ import com.google.gson.JsonElement;
7171
<# } #>
7272
return request;
7373
}
74+
<#
75+
var m = c as OdcmMethod;
76+
if(m != null && m.IsComposable && m.ReturnType != null && m.ReturnType is OdcmClass) {
77+
foreach(var prop in m.ReturnType.AsOdcmClass().NavigationProperties(true))
78+
{
79+
var propName = prop.Name.ToUpperFirstChar();
80+
var sanitizedProperty = propName.SanitizePropertyName().ToLowerFirstChar();
81+
var propRequestBuilder = prop.TypeRequestBuilder();
82+
if (prop.IsCollection()) {
83+
#>
84+
public <#=prop.ITypeCollectionRequestBuilder()#> <#=sanitizedProperty#>() {
85+
return new <#=prop.TypeCollectionRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>"), getClient(), null);
86+
}
87+
88+
public <#=prop.ITypeRequestBuilder()#> <#=sanitizedProperty#>(final String id) {
89+
return new <#=prop.TypeRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>") + "/" + id, getClient(), null);
90+
}
91+
<#
92+
} else {
93+
#>
94+
95+
/**
96+
* Gets the request builder for <#=prop.TypeName()#>
97+
*
98+
* @return the <#=prop.ITypeRequestBuilder()#> instance
99+
*/
100+
public <#=prop.ITypeRequestBuilder()#> <#=sanitizedProperty#>() {
101+
return new <#=prop.TypeRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>"), getClient(), null);
102+
}
103+
<#
104+
}
105+
}
106+
} #>
74107
}

Templates/Java/requests_extensions/IBaseMethodRequestBuilder.java.tt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,33 @@ import <#=importNamespace#>.http.IRequestBuilder;
2424
* @return the <#=c.ITypeRequest()#> instance
2525
*/
2626
<#=c.ITypeRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions);
27+
28+
<#
29+
var m = c as OdcmMethod;
30+
if(m != null && m.IsComposable && m.ReturnType != null && m.ReturnType is OdcmClass) {
31+
foreach(var prop in m.ReturnType.AsOdcmClass().NavigationProperties(true))
32+
{
33+
var propName = prop.Name.ToUpperFirstChar();
34+
var sanitizedName = prop.Name.SanitizePropertyName();
35+
var propRequestBuilder = prop.TypeRequestBuilder();
36+
if (prop.IsCollection()) {
37+
#>
38+
39+
<#=prop.ITypeCollectionRequestBuilder()#> <#=sanitizedName.ToLowerFirstChar()#>();
40+
41+
<#=prop.ITypeRequestBuilder()#> <#=prop.Name#>(final String id);
42+
<#
43+
} else {
44+
#>
45+
46+
/**
47+
* Gets the request builder for <#=prop.TypeName()#>
48+
*
49+
* @return the <#=prop.ITypeRequestBuilder()#> instance
50+
*/
51+
<#=prop.ITypeRequestBuilder()#> <#=sanitizedName.ToLowerFirstChar()#>();
52+
<#
53+
}
54+
}
55+
} #>
2756
}

0 commit comments

Comments
 (0)