Skip to content

Commit 2f182cb

Browse files
committed
refactor helper methods from BaseJavaModel.template.tt to TypeHelperJava.cs
1 parent 127d50c commit 2f182cb

File tree

55 files changed

+2054
-1946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2054
-1946
lines changed

Templates/Java/BaseJavaModel.template.tt

Lines changed: 23 additions & 1257 deletions
Large diffs are not rendered by default.

Templates/Java/models_extensions/BaseEntity.java.tt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = TypeName(c);#>
5+
<#host.TemplateName = c.TypeName();#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDefForEntity(host)#>
7+
<#=host.CreatePackageDefForEntity()#>
88

99
import com.google.gson.JsonObject;
1010
import com.google.gson.JsonElement;
1111
import com.google.gson.annotations.*;
1212
import java.util.HashMap;
1313
import java.util.Map;
1414

15-
<#=CreateClassDef(TypeName(c), BaseClassName(c), "IJsonBackedObject")#>
15+
<#=TypeHelperJava.CreateClassDef(c.TypeName(), c.BaseClassName(), "IJsonBackedObject")#>
1616

1717
<#
1818
if(((OdcmClass)c).Base == null){
@@ -31,7 +31,7 @@ import java.util.Map;
3131
}
3232
#>
3333

34-
<#=CreatePropertyDef(((OdcmClass)c).Properties, c is OdcmComplexClass)#>
35-
<#=CreateRawJsonObject()#>
36-
<#=UpdatePropertiesWithinSetRawObject(((OdcmClass)c).Properties, c is OdcmComplexClass)#>
37-
<#=PostProcess(TypeName(c))#>}
34+
<#=TypeHelperJava.CreatePropertyDef(((OdcmClass)c).Properties, c is OdcmComplexClass)#>
35+
<#=TypeHelperJava.CreateRawJsonObject()#>
36+
<#=TypeHelperJava.UpdatePropertiesWithinSetRawObject(((OdcmClass)c).Properties, c is OdcmComplexClass)#>
37+
<#=PostProcess(c.TypeName())#>}

Templates/Java/models_extensions/BaseMethodBody.java.tt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = TypeBody(c);#>
5+
<#host.TemplateName = c.TypeBody();#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDefinition(host)#>
7+
<#=host.CreatePackageDefinition()#>
88
import com.microsoft.graph.models.generated.*;
99
import com.google.gson.annotations.Expose;
1010
import com.google.gson.annotations.SerializedName;
1111
import com.google.gson.JsonObject;
1212
import com.microsoft.graph.serializer.ISerializer;
1313
import java.util.EnumSet;
1414

15-
<#=CreateClassDef(TypeBody(c))#>
15+
<#=TypeHelperJava.CreateClassDef(c.TypeBody())#>
1616

17-
<#=CreateParameterDef(c.AsOdcmMethod().Parameters)#>
18-
<#=CreateRawJsonObject()#>
17+
<#=TypeHelperJava.CreateParameterDef(c.AsOdcmMethod().Parameters)#>
18+
<#=TypeHelperJava.CreateRawJsonObject()#>
1919
}
2020
}

Templates/Java/models_extensions/IBaseClient.java.tt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
55
<#=writer.WriteHeader()#>
6-
<#=CreatePackageDef(host)#>
6+
<#=host.CreatePackageDef()#>
77

8-
<#=CreateInterfaceDef(IBaseClientType(c), "IBaseClient")#>
8+
<#=TypeHelperJava.CreateInterfaceDef(c.IBaseClientType(host), "IBaseClient")#>
99
<#
1010
foreach (var prop in model.EntityContainer.Properties)
1111
{
@@ -19,27 +19,27 @@ foreach (var prop in model.EntityContainer.Properties)
1919
*
2020
* @return the request builder for the collection of <#=propertyName#> objects
2121
*/
22-
<#=ITypeCollectionRequestBuilder(prop)#> <#=prop.Name#>();
22+
<#=prop.ITypeCollectionRequestBuilder()#> <#=prop.Name#>();
2323

2424
/**
2525
* Gets a single <#=propertyName#>
2626
*
2727
* @param id the id of the <#=propertyName#> to retrieve
2828
* @return the request builder for the <#=propertyName#> object
2929
*/
30-
<#=ITypeRequestBuilder(prop)#> <#=prop.Name#>(final String id);
30+
<#=prop.ITypeRequestBuilder()#> <#=prop.Name#>(final String id);
3131
<#
3232
}
3333
else
3434
{
3535
#>
3636

3737
/**
38-
* Gets the <#=TypeRequestBuilder(c)#>
38+
* Gets the <#=c.TypeRequestBuilder()#>
3939
*
4040
* @return the <#=prop.Projection.Type.GetTypeString()#>
4141
*/
42-
<#=ITypeRequestBuilder(prop)#> <#=prop.Name#>();
42+
<#=prop.ITypeRequestBuilder()#> <#=prop.Name#>();
4343
<#
4444
}
4545
}

Templates/Java/models_extensions/IClient.java.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = IClientType(c);#>
5+
<#host.TemplateName = c.IClientType(host);#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDef(host)#>
7+
<#=host.CreatePackageDef()#>
88
import com.google.gson.JsonObject;
99

10-
<#=CreateInterfaceDef(IClientType(c), IBaseClientType(c))#>
10+
<#=TypeHelperJava.CreateInterfaceDef(c.IClientType(host), c.IBaseClientType(host))#>
1111
<# if(host.TemplateName.Equals("IGraphServiceClient")){ #>
1212

1313
<T> CustomRequestBuilder<T> customRequest(final String url, final Class<T> responseType);

Templates/Java/models_generated/Enum.java.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
55
<#=writer.WriteHeader()#>
6-
<#=CreatePackageDefForEnum(host)#>
6+
<#=host.CreatePackageDefForEnum()#>
77

88
/**
99
* The Enum <#=c.Name.ToUpperFirstChar().SplitCamelCase()#>.

Templates/Java/requests_extensions/BaseClient.java.tt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
55
<#=writer.WriteHeader()#>
6-
<#=CreatePackageDef(host)#>
6+
<#=host.CreatePackageDef()#>
77

8-
<#=CreateClassDef(BaseClientType(c), "BaseClient", IBaseClientType(c))#>
8+
<#=TypeHelperJava.CreateClassDef(c.BaseClientType(host), "BaseClient", c.IBaseClientType(host))#>
99

1010
/**
1111
* The default endpoint for the Microsoft Graph Service
@@ -42,8 +42,8 @@ foreach (var prop in model.EntityContainer.Properties)
4242
*
4343
* @return the request builder for the collection of <#=propertyName#> objects
4444
*/
45-
public <#=ITypeCollectionRequestBuilder(prop)#> <#=prop.Name#>() {
46-
return new <#=TypeCollectionRequestBuilder(prop)#>(getServiceRoot() + "/<#=prop.Name#>", (<#=IClientType(c)#>)this, null);
45+
public <#=prop.ITypeCollectionRequestBuilder()#> <#=prop.Name#>() {
46+
return new <#=prop.TypeCollectionRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", (<#=c.IClientType(host)#>)this, null);
4747
}
4848

4949
/**
@@ -52,8 +52,8 @@ foreach (var prop in model.EntityContainer.Properties)
5252
* @param id the id of the <#=propertyName#> to retrieve
5353
* @return the request builder for the <#=propertyName#> object
5454
*/
55-
public <#=ITypeRequestBuilder(prop)#> <#=prop.Name#>(final String id) {
56-
return new <#=TypeRequestBuilder(prop)#>(getServiceRoot() + "/<#=prop.Name#>/" + id, (<#=IClientType(c)#>)this, null);
55+
public <#=prop.ITypeRequestBuilder()#> <#=prop.Name#>(final String id) {
56+
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>/" + id, (<#=c.IClientType(host)#>)this, null);
5757
}
5858
<#
5959
}
@@ -62,12 +62,12 @@ foreach (var prop in model.EntityContainer.Properties)
6262
#>
6363

6464
/**
65-
* Gets the <#=TypeRequestBuilder(c)#>
65+
* Gets the <#=c.TypeRequestBuilder()#>
6666
*
6767
* @return the <#=prop.Projection.Type.GetTypeString()#>
6868
*/
69-
public <#=ITypeRequestBuilder(prop)#> <#=prop.Name#>() {
70-
return new <#=TypeRequestBuilder(prop)#>(getServiceRoot() + "/<#=prop.Name#>", (<#=IClientType(c)#>)this, null);
69+
public <#=prop.ITypeRequestBuilder()#> <#=prop.Name#>() {
70+
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", (<#=c.IClientType(host)#>)this, null);
7171
}
7272
<#
7373
}

Templates/Java/requests_extensions/BaseEntityCollectionPage.java.tt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = TypeCollectionPage(c);#>
5+
<#host.TemplateName = c.TypeCollectionPage();#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDefForBaseEntityCollectionPage(host)#>
7+
<#=host.CreatePackageDefForBaseEntityCollectionPage()#>
88
import com.microsoft.graph.http.BaseCollectionPage;
99

10-
<#=CreateClassDef(TypeCollectionPage(c), "BaseCollectionPage" + CollectionPageGeneric(c), ITypeCollectionPage(c))#>
10+
<#=TypeHelperJava.CreateClassDef(c.TypeCollectionPage(), "BaseCollectionPage" + c.CollectionPageGeneric(), c.ITypeCollectionPage())#>
1111
<#
12-
String s = TypeName(c);
12+
String s = c.TypeName();
1313
#>
1414

1515
/**
16-
* A collection page for <#=TypeName(c)#>
16+
* A collection page for <#=c.TypeName()#>
1717
*
18-
* @param response the serialized <#=TypeCollectionResponse(c)#> from the service
18+
* @param response the serialized <#=c.TypeCollectionResponse()#> from the service
1919
* @param builder the request builder for the next collection page
2020
*/
21-
public <#=TypeCollectionPage(c)#>(final <#=TypeCollectionResponse(c)#> response, final <#=ITypeCollectionRequestBuilder(c)#> builder) {
21+
public <#=c.TypeCollectionPage()#>(final <#=c.TypeCollectionResponse()#> response, final <#=c.ITypeCollectionRequestBuilder()#> builder) {
2222
super(response.value, builder);
2323
}
2424
}

Templates/Java/requests_extensions/BaseEntityCollectionReferenceRequest.java.tt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = TypeCollectionReferenceRequest(c);#>
5+
<#host.TemplateName = c.TypeCollectionReferenceRequest();#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDef(host)#>
7+
<#=host.CreatePackageDef()#>
88

9-
<#=CreateClassDef(TypeCollectionReferenceRequest(c), "BaseCollectionRequest" + CollectionRequestGeneric(c), ITypeCollectionReferenceRequest(c))#>
9+
<#=TypeHelperJava.CreateClassDef(c.TypeCollectionReferenceRequest(), "BaseCollectionRequest" + c.CollectionRequestGeneric(), c.ITypeCollectionReferenceRequest())#>
1010

1111
/**
12-
* The request builder for this collection of <#=TypeName(c)#>
12+
* The request builder for this collection of <#=c.TypeName()#>
1313
*
1414
* @param requestUrl the request URL
1515
* @param client the service client
1616
* @param requestOptions the options for this request
1717
*/
18-
public <#=TypeCollectionReferenceRequest(c)#>(final String requestUrl, <#=IBaseClientType()#> client, final java.util.List<? extends Option> requestOptions) {
19-
super(requestUrl, client, requestOptions, <#=TypeCollectionResponse(c)#>.class, <#=ITypeCollectionPage(c)#>.class);
18+
public <#=c.TypeCollectionReferenceRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends Option> requestOptions) {
19+
super(requestUrl, client, requestOptions, <#=c.TypeCollectionResponse()#>.class, <#=c.ITypeCollectionPage()#>.class);
2020
}
2121

22-
public void post(final <#=TypeName(c)#> new<#=TypeName(c)#>, final ICallback<<#=TypeName(c)#>> callback) {
22+
public void post(final <#=c.TypeName()#> new<#=c.TypeName()#>, final ICallback<<#=c.TypeName()#>> callback) {
2323
<#
2424
var navigationProperty = c.AsOdcmProperty().GetServiceCollectionNavigationPropertyForPropertyType(((CustomT4Host)Host).CurrentModel);
2525
if (navigationProperty != null) {
@@ -32,18 +32,18 @@
3232
String prop = c.AsOdcmProperty().GetServiceCollectionNavigationPropertyForPropertyType(((CustomT4Host)Host).CurrentModel).Name;
3333
#>
3434
final String requestUrl = getBaseRequest().getRequestUrl().toString();
35-
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=TypeName(c)#>.id);
36-
new <#=TypeWithReferencesRequestBuilder(c)#>(requestUrl, getBaseRequest().getClient(), /* Options */ null)
35+
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=c.TypeName()#>.id);
36+
new <#=c.TypeWithReferencesRequestBuilder()#>(requestUrl, getBaseRequest().getClient(), /* Options */ null)
3737
.buildRequest(getBaseRequest().getOptions())
38-
.post(new<#=TypeName(c)#>, body, callback);
38+
.post(new<#=c.TypeName()#>, body, callback);
3939
}
4040

41-
public <#=TypeName(c)#> post(final <#=TypeName(c)#> new<#=TypeName(c)#>) throws ClientException {
41+
public <#=c.TypeName()#> post(final <#=c.TypeName()#> new<#=c.TypeName()#>) throws ClientException {
4242
final String requestUrl = getBaseRequest().getRequestUrl().toString();
43-
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=TypeName(c)#>.id);
44-
return new <#=TypeWithReferencesRequestBuilder(c)#>(requestUrl,getBaseRequest().getClient(), /* Options */ null)
43+
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=c.TypeName()#>.id);
44+
return new <#=c.TypeWithReferencesRequestBuilder()#>(requestUrl,getBaseRequest().getClient(), /* Options */ null)
4545
.buildRequest(getBaseRequest().getOptions())
46-
.post(new<#=TypeName(c)#>, body);
46+
.post(new<#=c.TypeName()#>, body);
4747
}
4848
<# }
4949
#>
@@ -54,9 +54,9 @@
5454
* @param value the expand clause
5555
* @return the updated request
5656
*/
57-
public <#=ITypeCollectionReferenceRequest(c)#> expand(final String value) {
57+
public <#=c.ITypeCollectionReferenceRequest()#> expand(final String value) {
5858
addQueryOption(new QueryOption("$expand", value));
59-
return (<#=TypeCollectionReferenceRequest(c)#>)this;
59+
return (<#=c.TypeCollectionReferenceRequest()#>)this;
6060
}
6161

6262
<# } #>
@@ -67,9 +67,9 @@
6767
* @param value the select clause
6868
* @return the updated request
6969
*/
70-
public <#=ITypeCollectionReferenceRequest(c)#> select(final String value) {
70+
public <#=c.ITypeCollectionReferenceRequest()#> select(final String value) {
7171
addQueryOption(new QueryOption("$select", value));
72-
return (<#=TypeCollectionReferenceRequest(c)#>)this;
72+
return (<#=c.TypeCollectionReferenceRequest()#>)this;
7373
}
7474

7575
<# } #>
@@ -80,9 +80,9 @@
8080
* @param value the max number of items to return
8181
* @return the updated request
8282
*/
83-
public <#=ITypeCollectionReferenceRequest(c)#> top(final int value) {
83+
public <#=c.ITypeCollectionReferenceRequest()#> top(final int value) {
8484
addQueryOption(new QueryOption("$top", value + ""));
85-
return (<#=TypeCollectionReferenceRequest(c)#>)this;
85+
return (<#=c.TypeCollectionReferenceRequest()#>)this;
8686
}
8787
<# } #>
8888
}

Templates/Java/requests_extensions/BaseEntityCollectionReferenceRequestBuilder.java.tt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
<#@ template debug="true" hostspecific="true" language="C#" #>
33
<#@ include file="BaseJavaModel.template.tt"#>
44
<#@ output extension="\\" #>
5-
<#host.TemplateName = TypeCollectionReferenceRequestBuilder(c);#>
5+
<#host.TemplateName = c.TypeCollectionReferenceRequestBuilder();#>
66
<#=writer.WriteHeader()#>
7-
<#=CreatePackageDef(host)#>
7+
<#=host.CreatePackageDef()#>
88

9-
<#=CreateClassDef(TypeCollectionReferenceRequestBuilder(c), "BaseRequestBuilder", ITypeCollectionReferenceRequestBuilder(c))#>
9+
<#=TypeHelperJava.CreateClassDef(c.TypeCollectionReferenceRequestBuilder(), "BaseRequestBuilder", c.ITypeCollectionReferenceRequestBuilder())#>
1010

1111
/**
12-
* The request builder for this collection of <#=ClassTypeName(c)#>
12+
* The request builder for this collection of <#=c.ClassTypeName()#>
1313
*
1414
* @param requestUrl the request URL
1515
* @param client the service client
1616
* @param requestOptions the options for this request
1717
*/
18-
public <#=TypeCollectionReferenceRequestBuilder(c)#>(final String requestUrl, final <#=IBaseClientType()#> client, final java.util.List<? extends Option> requestOptions) {
18+
public <#=c.TypeCollectionReferenceRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends Option> requestOptions) {
1919
super(requestUrl, client, requestOptions);
2020
}
2121

22-
public <#=ITypeCollectionReferenceRequest(c)#> buildRequest() {
22+
public <#=c.ITypeCollectionReferenceRequest()#> buildRequest() {
2323
return buildRequest(getOptions());
2424
}
2525

26-
public <#=ITypeCollectionReferenceRequest(c)#> buildRequest(final java.util.List<? extends Option> requestOptions) {
27-
return new <#=TypeCollectionReferenceRequest(c)#>(getRequestUrl(), getClient(), requestOptions);
26+
public <#=c.ITypeCollectionReferenceRequest()#> buildRequest(final java.util.List<? extends Option> requestOptions) {
27+
return new <#=c.TypeCollectionReferenceRequest()#>(getRequestUrl(), getClient(), requestOptions);
2828
}
2929
}

0 commit comments

Comments
 (0)