Skip to content

Commit

Permalink
Merge pull request #278 from microsoftgraph/bugfix/java-stream-proper…
Browse files Browse the repository at this point in the history
…ties

java selective imports + a bunch of bugfixes + namespace fixes
  • Loading branch information
baywet authored Aug 28, 2020
2 parents 01701e3 + 824cfc5 commit b9d490f
Show file tree
Hide file tree
Showing 302 changed files with 2,511 additions and 2,069 deletions.
3 changes: 2 additions & 1 deletion Templates/Java/models_extensions/BaseEntity.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonElement;
import com.google.gson.annotations.*;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;
import java.util.Map;

Expand Down
9 changes: 3 additions & 6 deletions Templates/Java/models_extensions/BaseMethodBody.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
<#host.TemplateName = c.TypeBody();#>
<#=writer.WriteHeader()#>
<#=host.CreatePackageDefinition()#>
<#
var sb = new StringBuilder();
sb = TypeHelperJava.ImportClassesOfMethodParameters(c.AsOdcmMethod(), "import {0}.{1}.{2};", sb);
#>
<#=sb.ToString()#>
<#=TypeHelperJava.ImportClassesOfMethodParametersAsString(c.AsOdcmMethod())#>
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.google.gson.JsonObject;
import com.microsoft.graph.serializer.ISerializer;
import <#=importNamespace#>.serializer.ISerializer;
import java.util.EnumSet;

<#=TypeHelperJava.CreateClassDef(c.TypeBody())#>
Expand Down
2 changes: 2 additions & 0 deletions Templates/Java/models_extensions/IBaseClient.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<#@ output extension="\\" #>
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateInterfaceDef(c.IBaseClientType(host), "IBaseClient")#>
<#
Expand Down
4 changes: 4 additions & 0 deletions Templates/Java/models_extensions/IClient.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>
import com.google.gson.JsonObject;
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.<#=c.GetPackagePrefix()#>.<#=c.IBaseClientType(host)#>;
<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.CustomRequestBuilder;

<#=TypeHelperJava.CreateInterfaceDef(c.IClientType(host), c.IBaseClientType(host))#>
<# if(host.TemplateName.Equals("IGraphServiceClient")){ #>
Expand Down
2 changes: 1 addition & 1 deletion Templates/Java/models_generated/Enum.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public enum <#= c.Name.ToUpperFirstChar()#>
{
<#
foreach(var value in c.AsOdcmEnum().Members)
foreach(var value in c.AsOdcmEnum().Members.GroupBy(x => x.Name.ToUnderscore().ToUpper()).Select(x => x.First()).ToList())
{
#>
/**
Expand Down
11 changes: 7 additions & 4 deletions Templates/Java/requests_extensions/BaseClient.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
<#@ output extension="\\" #>
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.models.extensions.<#=c.IBaseClientType(host)#>;
import <#=importNamespace#>.core.BaseClient;

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

/**
* The default endpoint for the Microsoft Graph Service
*/
public static final String DEFAULT_GRAPH_ENDPOINT = "https://graph.microsoft.com/v1.0";
public static final String DEFAULT_GRAPH_ENDPOINT = "<#=ConfigurationService.Settings.DefaultBaseEndpointUrl#>";

/**
* The current endpoint
Expand Down Expand Up @@ -43,7 +46,7 @@ foreach (var prop in model.EntityContainer.Properties)
* @return the request builder for the collection of <#=propertyName#> objects
*/
public <#=prop.ITypeCollectionRequestBuilder()#> <#=prop.Name#>() {
return new <#=prop.TypeCollectionRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", (<#=c.IClientType(host)#>)this, null);
return new <#=prop.TypeCollectionRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", this, null);
}

/**
Expand All @@ -53,7 +56,7 @@ foreach (var prop in model.EntityContainer.Properties)
* @return the request builder for the <#=propertyName#> object
*/
public <#=prop.ITypeRequestBuilder()#> <#=prop.Name#>(final String id) {
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>/" + id, (<#=c.IClientType(host)#>)this, null);
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>/" + id, this, null);
}
<#
}
Expand All @@ -67,7 +70,7 @@ foreach (var prop in model.EntityContainer.Properties)
* @return the <#=prop.Projection.Type.GetTypeString()#>
*/
public <#=prop.ITypeRequestBuilder()#> <#=prop.Name#>() {
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", (<#=c.IClientType(host)#>)this, null);
return new <#=prop.TypeRequestBuilder()#>(getServiceRoot() + "/<#=prop.Name#>", this, null);
}
<#
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<#host.TemplateName = c.TypeCollectionPage();#>
<#=writer.WriteHeader()#>
<#=host.CreatePackageDefForBaseEntityCollectionPage()#>
import com.microsoft.graph.http.BaseCollectionPage;
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseCollectionPage;
<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.TypeCollectionPage()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.TypeCollectionResponse()#>;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionPage(), "BaseCollectionPage" + c.CollectionPageGeneric(), c.ITypeCollectionPage())#>
<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.options.QueryOption;
import <#=importNamespace#>.core.IBaseClient;
import <#=importNamespace#>.http.BaseCollectionRequest;
import <#=importNamespace#>.http.ReferenceRequestBody;
<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=c.GetPackagePrefix()#>.<#=c.TypeName()#>;

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

/**
Expand All @@ -15,7 +23,7 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionReferenceRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionReferenceRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, <#=c.TypeCollectionResponse()#>.class, <#=c.ITypeCollectionPage()#>.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseRequestBuilder;
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionReferenceRequestBuilder(), "BaseRequestBuilder", c.ITypeCollectionReferenceRequestBuilder())#>

/**
Expand All @@ -15,15 +19,15 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionReferenceRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionReferenceRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}

public <#=c.ITypeCollectionReferenceRequest()#> buildRequest() {
return buildRequest(getOptions());
}

public <#=c.ITypeCollectionReferenceRequest()#> buildRequest(final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.ITypeCollectionReferenceRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
return new <#=c.TypeCollectionReferenceRequest()#>(getRequestUrl(), getClient(), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.options.QueryOption;
import <#=importNamespace#>.core.IBaseClient;
import <#=importNamespace#>.http.BaseCollectionRequest;
import <#=importNamespace#>.concurrency.IExecutors;
<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionPage()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.TypeCollectionResponse()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionRequestBuilder()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionRequest()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.TypeCollectionPage()#>;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionRequest(), "BaseCollectionRequest" + c.CollectionRequestGeneric(), c.ITypeCollectionRequest())#>

/**
Expand All @@ -15,7 +27,7 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, <#=c.TypeCollectionResponse()#>.class, <#=c.ITypeCollectionPage()#>.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionRequestBuilder()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeRequestBuilder()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionRequest()#>;
<#
var currentTypeProjection = c.AsOdcmProperty().Projection.Type.AsOdcmClass();
if (currentTypeProjection != null) {
foreach (var method in currentTypeProjection.MethodsAndOverloads()) {
if (!method.IsBoundToCollection) {
continue;
}
if (method.IsCollection) {
#>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=method.ITypeCollectionRequestBuilder()#>;
<#
} else {
#>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=method.ITypeRequestBuilder()#>;
<#
}
}
}
#>
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseRequestBuilder;
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionRequestBuilder(), "BaseRequestBuilder", c.ITypeCollectionRequestBuilder())#>

/**
Expand All @@ -15,15 +42,15 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}

public <#=c.ITypeCollectionRequest()#> buildRequest() {
return buildRequest(getOptions());
}

public <#=c.ITypeCollectionRequest()#> buildRequest(final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.ITypeCollectionRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
return new <#=c.TypeCollectionRequest()#>(getRequestUrl(), getClient(), requestOptions);
}

Expand All @@ -40,7 +67,6 @@
<# } #>

<#
var currentTypeProjection = c.AsOdcmProperty().Projection.Type.AsOdcmClass();
if (currentTypeProjection != null) {
foreach (var method in currentTypeProjection.MethodsAndOverloads()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.microsoft.graph.serializer.AdditionalDataManager;
import com.microsoft.graph.serializer.IJsonBackedObject;
import com.microsoft.graph.serializer.ISerializer;
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.serializer.AdditionalDataManager;
import <#=importNamespace#>.serializer.IJsonBackedObject;
import <#=importNamespace#>.serializer.ISerializer;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionResponse(), null, "IJsonBackedObject")#>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var mainNamespace = host.CurrentNamespace(); #>
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionRequestBuilder()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.ITypeCollectionWithReferencesPage()#>;
import <#=mainNamespace#>.<#=TypeHelperJava.GetPrefixForRequests()#>.<#=c.TypeCollectionResponse()#>;
import <#=mainNamespace#>.<#=c.GetPackagePrefix()#>.<#=c.TypeName()#>;
import com.google.gson.JsonObject;
import com.google.gson.annotations.*;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseCollectionPage;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionWithReferencesPage(), "BaseCollectionPage" + c.CollectionPageWithReferencesGeneric(), c.ITypeCollectionWithReferencesPage())#>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.options.QueryOption;
import <#=importNamespace#>.core.IBaseClient;
import <#=importNamespace#>.http.BaseCollectionRequest;
import <#=importNamespace#>.concurrency.IExecutors;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionWithReferencesRequest(), "BaseCollectionRequest" + c.CollectionRequestGeneric(), c.ITypeCollectionWithReferencesRequest())#>

/**
Expand All @@ -15,7 +21,7 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionWithReferencesRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionWithReferencesRequest()#>(final String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, <#=c.TypeCollectionResponse()#>.class, <#=c.ITypeCollectionPage()#>.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseRequestBuilder;
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateClassDef(c.TypeCollectionWithReferencesRequestBuilder(), "BaseRequestBuilder", c.ITypeCollectionWithReferencesRequestBuilder())#>

/**
Expand All @@ -15,15 +19,15 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeCollectionWithReferencesRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeCollectionWithReferencesRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}

public <#=c.ITypeCollectionWithReferencesRequest()#> buildRequest() {
return buildRequest(getOptions());
}

public <#=c.ITypeCollectionWithReferencesRequest()#> buildRequest(final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.ITypeCollectionWithReferencesRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
return new <#=c.TypeCollectionWithReferencesRequest()#>(getRequestUrl(), getClient(), requestOptions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.options.QueryOption;
import <#=importNamespace#>.http.BaseRequest;
import <#=importNamespace#>.http.HttpMethod;
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateClassDef(c.TypeReferenceRequest(), "BaseRequest", c.ITypeReferenceRequest())#>

/**
Expand All @@ -15,7 +21,7 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeReferenceRequest()#>(String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeReferenceRequest()#>(String requestUrl, <#=TypeHelperJava.IBaseClientType()#> client, java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions, <#=c.ClassTypeName()#>.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<#=writer.WriteHeader()#>
<#=host.CreatePackageDef()#>

<# var importNamespace = host.CurrentModel.GetNamespace().AddPrefix(); #>
import <#=importNamespace#>.http.BaseRequestBuilder;
import <#=importNamespace#>.core.IBaseClient;

<#=TypeHelperJava.CreateClassDef(c.TypeReferenceRequestBuilder(), "BaseRequestBuilder", c.ITypeReferenceRequestBuilder())#>

/**
Expand All @@ -16,7 +20,7 @@
* @param client the service client
* @param requestOptions the options for this request
*/
public <#=c.TypeReferenceRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.TypeReferenceRequestBuilder()#>(final String requestUrl, final <#=TypeHelperJava.IBaseClientType()#> client, final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
super(requestUrl, client, requestOptions);
}

Expand All @@ -35,7 +39,7 @@
* @param requestOptions the options for this request
* @return the <#=c.ITypeReferenceRequest()#> instance
*/
public <#=c.ITypeReferenceRequest()#> buildRequest(final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
public <#=c.ITypeReferenceRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions) {
return new <#=c.TypeReferenceRequest()#>(getRequestUrl(), getClient(), requestOptions);
}
}
Loading

0 comments on commit b9d490f

Please sign in to comment.