Primitive Boxing ProblemHi All, I'm back with a new challenge to explain about one my project.
Like the previous post explain i'm working on this project (Object Query) to find a new way to write DBMS query directly in java.
So my idea is not so hard to implements until you are thinking in Object way, like almost all java think, but there are few things that in java are not object one of this are the primitives types, and this primitive types are common in an DDD domain that's mean if I'm not able to handle this problem my idea is died!
So now i have to start to think to a good solution:
What i've in my project is a pure java domain, and a proxy instance of a class of domain, so i can just start from this point to try to solve my problem.
Another start point for try to solve this problem is the java (from 1.5) behavior, that allow to to transfer primitive type values in an object way through code, wrapping it in an specific object(java.lang.Integer,java.lang.Long, ecc..) this is called boxing.
So i can try to create an my owned boxing object to use for handle primitive types, this i think is not hard just define an api that receive primitive type and return an object that represent the path of primitive type call. with a code like this:
Object primitiveBoxed = query.box(proxy.getHome().getWeight());Ok I can solve my problem, just because when i call the method getWeight on my proxy a create a fake value to associate to path "home.weight",
and the call box() i receive the previous value and from this value i can extract the associate path and after create a "Boxing" object with associate path.
after this operation i've an object with associate the path like a normal object.
So i found i way to solve the problem of primitive values .... and i just implemented it !!