Re: reducing generic verbosity

Noel Grandin <[email protected]> Thu, 01 Jul 2010 08:57:56 +0200
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
 Hi

Java 1.7 will have something called the "diamond constructor", which does type inference, so we'll be able to do this:

   SQuery<OrderWidebandMeasurementRecord> query = new SQuery<>(META);

But in the meantime, it would be nice if SimpleORM included some "sugar" to make the coding less verbose.

Regards, Noel

[email protected] wrote:
>  
>
> Could do, but it is pretty marginal. You could always write your own create method in a utility class.
>
> The real problem here is Java. Why cann't I write something like
>
> var query = new SQuery(META);
>
> Constructors should be able to specify return types and something like var is long overdue. (I have been using .Net
> recently.)
>
> Anthony
>
> At 06:46 PM 30/06/2010, Noel Grandin wrote:
> >
> >
> >Hi
> >
> >A method like this on SQuery:
> >
> > public static <T extends SRecordInstance> SQuery<T> create(SRecordMeta<T> recordMeta) {
> > return new SQuery<T>(recordMeta);
> > }
> >
> >would greatly help to reduce the verbosity of the instantiation of SQuery objects.
> >
> >For example, instead of this:
> >
> > SQuery<OrderWidebandMeasurementRecord> query = new SQuery<OrderWidebandMeasurementRecord>(META);
> >
> >I can do this:
> >
> > SQuery<OrderWidebandMeasurementRecord> query = SQuery.create(META);
> >
> >Regards,
> > Noel Grandin
> >
> >
> >
> >----------
> >Disclaimer: <http://www.peralex.com/disclaimer.html>http://www.peralex.com/disclaimer.html
> >
> >
>
> Spreadsheet Detective,
> Southern Cross Software Queensland Pty Limited
> 54 Gerler Street
> Bardon, Queensland 4065, Australia.
>
> Email: [email protected] <mailto:berglas%40spreadsheetdetective.com>
> www.SpreadsheetDetective.com
> Ph: +61 427 830248 (Australian Eastern Standard Time)
>
> "If the model seems correct only because the numbers look right,
> then why build the model in the first place?"
>
> 

Disclaimer: http://www.peralex.com/disclaimer.html