-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
289 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...va/com/microsoft/typespec/http/client/generator/fluent/TypeSpecFluentTemplateFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.typespec.http.client.generator.fluent; | ||
|
||
import com.microsoft.typespec.http.client.generator.core.template.EnumTemplate; | ||
import com.microsoft.typespec.http.client.generator.mgmt.template.FluentTemplateFactory; | ||
import com.microsoft.typespec.http.client.generator.template.TypeSpecEnumTemplate; | ||
|
||
/** | ||
* TypeSpec mgmt template factory. | ||
*/ | ||
public class TypeSpecFluentTemplateFactory extends FluentTemplateFactory { | ||
@Override | ||
public EnumTemplate getEnumTemplate() { | ||
return TypeSpecEnumTemplate.getInstance(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...c/main/java/com/microsoft/typespec/http/client/generator/mapper/TypeSpecChoiceMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.microsoft.typespec.http.client.generator.mapper; | ||
|
||
import com.microsoft.typespec.http.client.generator.core.extension.model.codemodel.ChoiceSchema; | ||
import com.microsoft.typespec.http.client.generator.core.mapper.ChoiceMapper; | ||
import com.microsoft.typespec.http.client.generator.core.mapper.MapperUtils; | ||
import com.microsoft.typespec.http.client.generator.core.mapper.Mappers; | ||
import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClassType; | ||
import com.microsoft.typespec.http.client.generator.core.model.clientmodel.IType; | ||
|
||
public class TypeSpecChoiceMapper extends ChoiceMapper { | ||
private static TypeSpecChoiceMapper INSTANCE = new TypeSpecChoiceMapper(); | ||
|
||
public static TypeSpecChoiceMapper getInstance() { | ||
return INSTANCE; | ||
} | ||
private TypeSpecChoiceMapper() { | ||
} | ||
|
||
@Override | ||
public IType map(ChoiceSchema enumType) { | ||
IType elementType = Mappers.getSchemaMapper().map(enumType.getChoiceType()); | ||
boolean isStringEnum = elementType == ClassType.STRING; | ||
if (isStringEnum) { | ||
return MapperUtils.createEnumType(enumType, true, true); | ||
} else { | ||
return MapperUtils.createEnumType(enumType, true, true, "getValue", "fromValue"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.