Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DataLoadingCommandLookup implements IDataLoadingCommandLookup {
- private var _commandsByDataType:Dictionary;
- public function DataLoadingCommandLookup() {
- }
- //---------------------------------------
- // IDataLoadingCommandLookup Implementation
- //---------------------------------------
- public function mapCommandToClass(commandClazz:Class, dataClazz:Class):void
- {
- if(commandsByDataType[dataClazz] != null)
- {
- throw(new IllegalOperationError('Ambiguous mapping: This data class has already been mapped to a command class.'));
- }
- if(isNotACommand(commandClazz))
- {
- throw(new IllegalOperationError('The command class you passed is missing an execute method.'));
- }
- commandsByDataType[dataClazz] = commandClazz;
- }
- public function getCommandForClass(dataClazz:Class):Class
- {
- return commandsByDataType[dataClazz];
- }
- private function get commandsByDataType():Dictionary
- {
- return _commandsByDataType || (_commandsByDataType = new Dictionary());
- }
- private function isNotACommand(commandClazz:Class):Boolean
- {
- if(describeType(commandClazz).factory.method.(@name == "execute").length() > 0)
- {
- return false;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment