Re: What does this syntax say?

2011-07-29 Thread Scott Swank
This is called a "generic method", and you're just giving the type signature of the method. Here's an example from our code. public static > NumberField withMinimum(String id, T min) { NumberField f = new NumberField(id); f.add(new MinimumValidator(min));

RE: What does this syntax say?

2011-07-28 Thread Wilhelmsen Tor Iver
> public IWrapModel wrapOnInheritance(Component component,Class > type) The Class parameter is only needed if you intend to do "new W();" or the like in the method (the Class is then something the compiler can grab hold of for calling the constructor). For just passing the type parameter to oth

Re: What does this syntax say?

2011-07-28 Thread Dan Retzlaff
I actually meant the no-argument version of "of()". Since this is getting off-topic, I suggest you search around under "java type erasure." There are people far more expert than I to describe what's going on. :) On Thu, Jul 28, 2011 at 9:26 PM, Ben Tilford wrote: > Right but Model.of accepts an

Re: What does this syntax say?

2011-07-28 Thread Ben Tilford
Right but Model.of accepts an instance of the generic type so it's not lost and is available at runtime. static Model of(T instance) vs. public IWrapModel wrapOnInheritance(Component component) On Thu, Jul 28, 2011 at 6:33 PM, Dan Retzlaff wrote: > Generic types are lost by the time the method

Re: What does this syntax say?

2011-07-28 Thread Dan Retzlaff
Generic types are lost by the time the method is executed, so there's really nothing the method implementation could check. Another fun example is org.apache.wicket.model.Model#of(). The general subject is called type erasure, and is one of the more confusing aspects of Java generics. On Thu, Jul

Re: What does this syntax say?

2011-07-28 Thread Ben Tilford
Without a Class argument how is it returning/casting correctly? Shouldn't it be public IWrapModel wrapOnInheritance(Component component,Class type) to make W available within the method? On Thu, Jul 28, 2011 at 12:40 PM, Dan Retzlaff wrote: > The first let's the compiler know that the secon

Re: What does this syntax say?

2011-07-28 Thread Dan Retzlaff
The first let's the compiler know that the second is a generic type and not a reference to some class named W. It's just syntax. On Thu, Jul 28, 2011 at 10:48 AM, Niranjan Rao wrote: > Ok, I admit it - I don't understand this function at all defined in > IComponentInheritedModel > > public IW

Re: What does this syntax say?

2011-07-28 Thread Bas Gooren
This syntax is for use when you need a generic placeholder. In this case, it means that is determined by the call site: IModel model = OtherModel.wrapOnInheritance( Component ); The above means that W is checked to be "BusinessObject" for all occurrences of W. A better to understand example

What does this syntax say?

2011-07-28 Thread Niranjan Rao
Ok, I admit it - I don't understand this function at all defined in IComponentInheritedModel public IWrapModel wrapOnInheritance(Component component) I don't understand meaning of and IWrapModel. I know generics generally, but this syntax has been baffling me. Based on what eclipse is tryin