|
|
Re: Xbase, Using XbaseBatchScopeProvider [message #1731411 is a reply to message #1731398] |
Thu, 05 May 2016 04:03 |
Dhivya Ramanujam Messages: 4 Registered: May 2016 |
Junior Member |
|
|
Hi Miguel,
I have a Java Class,
It is not a generated code, it is an existing POJO class.
Ex:
Class Person {
String firstName;
String LastName;
//getters
//setters
}
Class PersonVO{
String FullName;
// getters
//setters
}
WhatI want to do with my grammar is that, I want to concatenate firstName and lastName from Person Object to the FullName variable in PersonVO Object
That is I want to get attributes from Person and map it to Setter attributes in PersonVO obj.
DSL:
In my grammar, I want to make use of Xbase.( I have attached Domain.xtext)
My grammar is as follows:
..
'{'
(propertyMapping+=PropertyMapping)*
'}';
PropertyMapping:
source=XMemberFeatureCall MapsToToken destination=XMemberFeatureCall ('using' using=JvmTypeReference)? ';';
MapsToToken:
'=>';
.
What I am expecting is that, When I create a Domain Model, In propertyMapping I want the Source part to give me the getters (Person Obj) and the destination to give me Setters(PersonVO).
-
Attachment: Domain.xtext
(Size: 0.60KB, Downloaded 69 times) -
Attachment: sample.mydsl
(Size: 0.19KB, Downloaded 68 times)
|
|
|
|
|
|
Re: Xbase, Using XbaseBatchScopeProvider [message #1731433 is a reply to message #1731420] |
Thu, 05 May 2016 08:24 |
|
Well you have basically 4 Parts
1 the Target Type
2 a Member of the Target Type
(Can be handled with a JvmTypeReference and a reference to a jvm member- the Second one scoped with the members of the First one by a customization of the scoping)
3 a Source type
4 a Expressionismus that accesses members of the Source Type and has the Type of 2 as a result
So what about Inferring for 4 a Method with the Body set to the expression and returntype the Type of 2
Putting 3 as Method Parameter with name it
EG
from Person firstname.concat(Lastname) set PersonVo.fullname
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03517 seconds