Created
May 14, 2018 03:21
-
-
Save devoncarew/9aeeb1d97e1b7c43266912d30107253a to your computer and use it in GitHub Desktop.
Adaptable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
/** | |
* This library contains an implementation of the adaptable pattern. | |
*/ | |
library core.adaptable; | |
// TODO: Add a static `adaptTo` method, and a way to register adapter factories. | |
/** | |
* An [Adaptable] object can coerce itself into other object types. For | |
* instance, an `Context` type might be able to return an associated `Editor` | |
* object when asked, or an `Editor` object might be able to return an | |
* associated `File` object. | |
* | |
* The [Adaptable] pattern is good for when you know what kind of object you | |
* want to operate on, but you're not sure at call time which object you've | |
* been given. | |
*/ | |
abstract class Adaptable { | |
/** | |
* Returns an object which is an instance of the given [Type] associated with | |
* this object, or `null` if no such object can be found. | |
*/ | |
dynamic adapt(Type type); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment