| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 part of initialize; | |
| 5 | |
| 6 /// Implement this class to create your own initializer. | |
| 7 /// | |
| 8 /// Hello world example: | |
| 9 /// | |
| 10 /// class Print implements Initializer<Type> { | |
| 11 /// final String message; | |
| 12 /// const Print(this.message); | |
| 13 /// | |
| 14 /// @override | |
| 15 /// initialize(Type t) => print('$t says `$message`'); | |
| 16 /// } | |
| 17 /// | |
| 18 /// @Print('hello world!') | |
| 19 /// class Foo {} | |
| 20 /// | |
| 21 /// Call [run] from your main and this will print 'Foo says `hello world!`' | |
| 22 /// | |
| 23 abstract class Initializer<T> { | |
| 24 dynamic initialize(T target); | |
| 25 } | |
| 26 | |
| 27 /// Typedef for a custom filter function. | |
| 28 typedef bool InitializerFilter(Initializer initializer); | |
| 29 | |
| 30 /// When annotating libraries, this is passed to the initializer. | |
| 31 class LibraryIdentifier { | |
| 32 // The qualified name of the library. | |
| 33 final Symbol name; | |
| 34 | |
| 35 // The package this library lives in. May be null if its the same as the root | |
| 36 // package. | |
| 37 final String package; | |
| 38 | |
| 39 // The path to the library. | |
| 40 final String path; | |
| 41 | |
| 42 const LibraryIdentifier(this.name, this.package, this.path); | |
| 43 | |
| 44 bool operator ==(LibraryIdentifier other) => | |
| 45 name == other.name && package == other.package && path == other.path; | |
| 46 | |
| 47 String toString() => '$name: $package:$path'; | |
| 48 } | |
| OLD | NEW |