Advertisement
PaleoCrafter

Untitled

Jul 11th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.36 KB | None | 0 0
  1. class Type {
  2.   final String name;
  3.   final List<TypeGeneric> generics;
  4.  
  5.   const Type(this.name, [this.generics = const []]);
  6.  
  7.   TypeGeneric get generic => new TypeGeneric(type: this);
  8.  
  9.   String toString() => name + (generics.isNotEmpty ? '<' + generics.join(',') + '>' : '');
  10.  
  11.   static const Void = const Type('void');
  12.   static const Boolean = const Type('boolean');
  13.   static const Byte = const Type('byte');
  14.   static const Short = const Type('short');
  15.   static const Int = const Type('int');
  16.   static const Long = const Type('long');
  17.   static const Float = const Type('float');
  18.   static const Double = const Type('double');
  19.   static const Object = const Type('java.lang.Object');
  20.   static const Wildcard = const Type('?');
  21. }
  22.  
  23. class TypeGeneric {
  24.   final Type type;
  25.  
  26.   TypeGeneric({this.type});
  27.  
  28.   String toString() => type.toString();
  29. }
  30.  
  31. class BoundedTypeGeneric extends TypeGeneric {
  32.   final bool isLowerBound;
  33.   final Type bound;
  34.  
  35.   BoundedTypeGeneric({this.isLowerBound: false, this.bound}) : super(type: Type.Wildcard);
  36.  
  37.   String toString() => type.toString() + ' ' + (isLowerBound ? 'super' : 'extends') + ' ' + bound.toString();
  38. }
  39.  
  40. class ClassGeneric {
  41.   final String name;
  42.   final List<Type> bounds;
  43.  
  44.   ClassGeneric({this.name, this.bounds: const []});
  45.  
  46.   String toString() => name + (bounds.isNotEmpty ? " extends " + bounds.join() : "");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement