Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Check for byte array in model inferrer
Check for byte array in model inferrer [message #1806702] Tue, 14 May 2019 07:50
Nils Ehmke is currently offline Nils EhmkeFriend
Messages: 1
Registered: May 2019
Junior Member
Hi everyone,

I develop a Xbase-based DSL in which the developer can describe certain types with fields. At some point in the model inferrer, I want to check whether a field is of type "byte[]" - an array of primitive byte. I struggle a little bit with this check. I currently have the following:
if (member.type.isArray) {
	val componentType = (member.type as JvmGenericArrayTypeReference).componentType
	if (componentType.isPrimitive) {
		val primitiveType = componentType.type as JvmPrimitiveType
		if (primitiveType.simpleName == 'byte') {
			field.annotations += jpa.lob.annotationRef

This works. However, both type casts and the compare with the String "byte" just seem wrong to me. Is there a better way to do this?

Thanks a lot in advance.
Previous Topic:Serializing Instances based on the Domainmodel (15 minutes tutorial)
Next Topic:Sharing xtext generated projects to Git causes errors in ui and ui.tests
Goto Forum:

Current Time: Wed Nov 20 20:20:26 GMT 2019

Powered by FUDForum. Page generated in 0.02460 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top