Re: Still no typedef
"Lew" <lew@lewscanon.com> wrote in message
news:T7KdnXBHUtWgaMranZ2dnUVZ_tajnZ2d@comcast.com...
Andreas Leitgeb wrote:
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
Arnauld.Loyer@gmail.com writes:
typedef Entity<Node, RendererType> nodeEntity;
For Simplicity, I'll show how to do
typedef java.util.List<java.lang.String> StringList;
This can be done as follows:
class StringList extends java.util.ArrayList<java.lang.String>{}
This, however will still fail, if I wanted to save into
such a StringList-Variable an ArrayList<String> returned
from foreign code.
I guess I understand what people think typedef will do, but I just don't
have such a hard time using List <String>.
Abstraction is needed when the type expressions themselves become complex:
Map <NameId,Map<NameId,List<PrimaryActionDefinition>>> allPads
= new TreeMap <NameId,Map<NameId, List <PrimaryActionDefinition>>> ();
vs.
PrimaryActionTable = Map <NameId,Map<NameId,List<PrimaryActionDefinition>>;
PrimaryActionTable pat = new TreeMap <PrimaryActionTable> ();
I don't want to define a new class because doing so will bind the generic
expression to the base class. Using an interface is possible, but anonymous
instantiation always produces an inner class and naming the class results in
conflict between the unspecified generic type and the interface generic
type.
This works:
interface PrimaryActionTable extends
Map<NameId,Map<NameId,List<ElementalModelActionDefinition>>> {}
But this does not:
class PrimaryActionTableImpl extends TreeMap implements PrimaryActionTable
{ }
Cheers,
Matt Humphrey http://www.iviz.com/