Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Type {
- final String name;
- final List<TypeGeneric> generics;
- const Type(this.name, [this.generics = const []]);
- TypeGeneric get generic => new TypeGeneric(type: this);
- String toString() => name + (generics.isNotEmpty ? '<' + generics.join(',') + '>' : '');
- static const Void = const Type('void');
- static const Boolean = const Type('boolean');
- static const Byte = const Type('byte');
- static const Short = const Type('short');
- static const Int = const Type('int');
- static const Long = const Type('long');
- static const Float = const Type('float');
- static const Double = const Type('double');
- static const Object = const Type('java.lang.Object');
- static const Wildcard = const Type('?');
- }
- class TypeGeneric {
- final Type type;
- TypeGeneric({this.type});
- String toString() => type.toString();
- }
- class BoundedTypeGeneric extends TypeGeneric {
- final bool isLowerBound;
- final Type bound;
- BoundedTypeGeneric({this.isLowerBound: false, this.bound}) : super(type: Type.Wildcard);
- String toString() => type.toString() + ' ' + (isLowerBound ? 'super' : 'extends') + ' ' + bound.toString();
- }
- class ClassGeneric {
- final String name;
- final List<Type> bounds;
- ClassGeneric({this.name, this.bounds: const []});
- String toString() => name + (bounds.isNotEmpty ? " extends " + bounds.join() : "");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement