TGLMAN

Primitive Boxing Problem

Hi 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) behaviour, 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, etc..) 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:
1        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 !!
wonderful!!
Done !!

Posts

Java Shell Script
13 May 2015
Tags: ,

Self Hosted Calendar Server With Radicale
2 May 2015
Tags:

New Blog
14 April 2014
Tags:

Primitive Boxing Problem
20 November 2012
Tags: ,

DDD Query Way
20 October 2012
Tags: , ,

Refs

Twitter
Github
StackOverflow
OpenHub
SourceForge

Projects

Object Query