Skip to content

Commit a2d7210

Browse files
author
Caitlin Bales (MSFT)
committed
Return EnumSet if isFlags
1 parent 92dfebf commit a2d7210

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Templates/Android/BaseModel.template.tt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ import {0}.generated.*;
515515
import {0}.options.*;
516516
import {0}.serializer.*;
517517

518-
import java.util.Arrays;";
518+
import java.util.Arrays;
519+
import java.util.EnumSet;";
519520
return string.Format(format,
520521
host.CurrentModel.NamespaceName(),
521522
host.TemplateInfo.OutputParentDirectory);

src/GraphODataTemplateWriter/CodeHelpers/Android/TypeHelperAndroid.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public static string GetReservedPrefix(this OdcmType @type)
2727

2828
public static string GetTypeString(this OdcmType @type)
2929
{
30+
// If isFlags = true, return an EnumSet instead of an enum. This will be
31+
// serialized to and deserialized from a string
32+
if (String.Equals(@type.ToString(), "Vipr.Core.CodeModel.OdcmEnum") && @type.AsOdcmEnum().IsFlags)
33+
{
34+
return "EnumSet<" + @type.Name.ToUpperFirstChar() + ">";
35+
}
36+
3037
switch (@type.Name)
3138
{
3239
case "Int16":

0 commit comments

Comments
 (0)