OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 part of initialize; | 4 part of initialize; |
5 | 5 |
6 /// Implement this class to create your own initializer. | 6 /// Implement this class to create your own initializer. |
7 /// | 7 /// |
8 /// Hello world example: | 8 /// Hello world example: |
9 /// | 9 /// |
10 /// class Print implements Initializer<Type> { | 10 /// class Print implements Initializer<Type> { |
11 /// final String message; | 11 /// final String message; |
12 /// const Print(this.message); | 12 /// const Print(this.message); |
13 /// | 13 /// |
14 /// @override | 14 /// @override |
15 /// initialize(Type t) => print('$t says `$message`'); | 15 /// initialize(Type t) => print('$t says `$message`'); |
16 /// } | 16 /// } |
17 /// | 17 /// |
18 /// @Print('hello world!') | 18 /// @Print('hello world!') |
19 /// class Foo {} | 19 /// class Foo {} |
20 /// | 20 /// |
21 /// Call [run] from your main and this will print 'Foo says `hello world!`' | 21 /// Call [run] from your main and this will print 'Foo says `hello world!`' |
22 /// | 22 /// |
23 abstract class Initializer<T> { | 23 abstract class Initializer<T> { |
24 dynamic initialize(T target); | 24 dynamic initialize(T target); |
25 } | 25 } |
26 | 26 |
27 /// Typedef for a custom filter function. | 27 /// Typedef for a custom filter function. |
28 typedef bool InitializerFilter(Initializer initializer); | 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 |