OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 | |
5 part of dart.core; | |
6 | |
7 /** | |
8 * The base class for all Dart objects. | |
9 * | |
10 * Because Object is the root of the Dart class hierarchy, | |
11 * every other Dart class is a subclass of Object. | |
12 * | |
13 * When you define a class, you should override [toString] | |
14 * to return a string describing an instance of that class. | |
15 * You might also need to define [hashCode] and [==], as described in the | |
16 * [Implementing map | |
17 * keys](https://www.dartlang.org/docs/dart-up-and-running/ch03.html#implementin
g-map-keys) | |
18 * section of the [library | |
19 * tour](http://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html). | |
20 */ | |
21 class Object { | |
22 /** | |
23 * Creates a new [Object] instance. | |
24 * | |
25 * [Object] instances have no meaningful state, and are only useful | |
26 * through their identity. An [Object] instance is equal to itself | |
27 * only. | |
28 */ | |
29 const Object(); | |
30 | |
31 /** | |
32 * The equality operator. | |
33 * | |
34 * The default behavior for all [Object]s is to return true if and | |
35 * only if [:this:] and [other] are the same object. | |
36 * | |
37 * Override this method to specify a different equality relation on | |
38 * a class. The overriding method must still be an equivalence relation. | |
39 * That is, it must be: | |
40 * | |
41 * * Total: It must return a boolean for all arguments. It should never throw | |
42 * or return `null`. | |
43 * | |
44 * * Reflexive: For all objects `o`, `o == o` must be true. | |
45 * | |
46 * * Symmetric: For all objects `o1` and `o2`, `o1 == o2` and `o2 == o1` must | |
47 * either both be true, or both be false. | |
48 * | |
49 * * Transitive: For all objects `o1`, `o2`, and `o3`, if `o1 == o2` and | |
50 * `o2 == o3` are true, then `o1 == o3` must be true. | |
51 * | |
52 * The method should also be consistent over time, so equality of two objects | |
53 * should not change over time, or at least only change if one of the objects | |
54 * was modified. | |
55 * | |
56 * If a subclass overrides the equality operator it should override | |
57 * the [hashCode] method as well to maintain consistency. | |
58 */ | |
59 bool operator ==(other) => identical(this, other); | |
60 | |
61 /** | |
62 * Get a hash code for this object. | |
63 * | |
64 * All objects have hash codes. Hash codes are guaranteed to be the | |
65 * same for objects that are equal when compared using the equality | |
66 * operator [:==:]. Other than that there are no guarantees about | |
67 * the hash codes. They will not be consistent between runs and | |
68 * there are no distribution guarantees. | |
69 * | |
70 * If a subclass overrides [hashCode] it should override the | |
71 * equality operator as well to maintain consistency. | |
72 */ | |
73 external int get hashCode; | |
74 | |
75 /** | |
76 * Returns a string representation of this object. | |
77 */ | |
78 external String toString(); | |
79 | |
80 /** | |
81 * Invoked when a non-existent method or property is accessed. | |
82 * | |
83 * Classes can override [noSuchMethod] to provide custom behavior. | |
84 * | |
85 * If a value is returned, it becomes the result of the original invocation. | |
86 * | |
87 * The default behavior is to throw a [NoSuchMethodError]. | |
88 */ | |
89 external dynamic noSuchMethod(Invocation invocation); | |
90 | |
91 /** | |
92 * A representation of the runtime type of the object. | |
93 */ | |
94 external Type get runtimeType; | |
95 } | |
OLD | NEW |