All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xojo-client.modelOneOf.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
#tag Class
Protected Class {{classname}}
	#tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}}
		{{#nonPublicApi}}Protected {{/nonPublicApi}}kind As Kind
	#tag EndProperty

{{#oneOf}}	#tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}}
		{{#nonPublicApi}}Protected {{/nonPublicApi}}{{{.}}} As {{{.}}}
	#tag EndProperty

{{/oneOf}}

	#tag Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}}
		{{#nonPublicApi}}Protected {{/nonPublicApi}}Function Deserialize(value As String) As Boolean
		  {{#oneOf}}Try
            Dim data As New {{{.}}}
		    Xoson.fromJSON(data, value.toText()) 'TODO here we would need the `strictness` feature of Xoson
            Me.{{{.}}} = data
            Return True
		  Catch e As JSONException
		    Return False 'early exit, since this is invalid JSON
		    
		    Catch e As Xoson.XosonException
		      'this was not the right oneOf, try next one
		    End Try{{/oneOf}}
          Return False
		End Function
	#tag EndMethod

	#tag Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}}
		{{#nonPublicApi}}Protected {{/nonPublicApi}}Function Serialize() As String
		  Select Case Me.Kind{{#oneOf}}
		    Case {{{.}}}
		      Return Xoson.toJSON(Me.{{{.}}}{{/oneOf}}
		  End Select
		  Return ""
		End Function
	#tag EndMethod

	#tag Enum, Name = Kind, Type = Integer, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}}
		{{#oneOf}}
        {{{.}}}{{/oneOf}}
	#tag EndEnum

	#tag ViewBehavior
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			Type="Integer"
			EditorType=""
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InitialValue=""
			Type="String"
			EditorType=""
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			Type="Integer"
			EditorType=""
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			Type="Integer"
			EditorType=""
		#tag EndViewProperty{{#allVars}}{{^isEnum}}{{^isByteArray}}
		#tag ViewProperty
			Name="{{{name}}}"
			Visible=false
			Group="Behavior"
			InitialValue=""
			Type="{{{datatype}}}"
			EditorType="{{#isStringSchema}}MultiLineEditor{{/isStringSchema}}"
		#tag EndViewProperty{{/isByteArray}}{{/isEnum}}{{/allVars}}
	#tag EndViewBehavior
End Class
#tag EndClass




© 2015 - 2024 Weber Informatics LLC | Privacy Policy