Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/AdapterPlug.java @ 582:90df078d6418
Delegate cancel to original support, do not implement CancelSupport ourselves
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Mon, 22 Apr 2013 19:17:29 +0200 |
| parents | 1ee452f31187 |
| children |
comparison
equal
deleted
inserted
replaced
| 581:0890628ed51e | 582:90df078d6418 |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 TMate Software Ltd | 2 * Copyright (c) 2012-2013 TMate Software Ltd |
| 3 * | 3 * |
| 4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
| 5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
| 6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
| 7 * | 7 * |
| 35 private final List<Class<?>> adapterUses = new ArrayList<Class<?>>(); | 35 private final List<Class<?>> adapterUses = new ArrayList<Class<?>>(); |
| 36 | 36 |
| 37 public <T> void attachAdapter(Class<T> adapterClass, T instance) { | 37 public <T> void attachAdapter(Class<T> adapterClass, T instance) { |
| 38 adapters.put(adapterClass, instance); | 38 adapters.put(adapterClass, instance); |
| 39 } | 39 } |
| 40 | |
| 41 @SuppressWarnings("unchecked") | |
| 42 public <T> T detachAdapter(Class<T> adapterClass) { | |
| 43 return (T) adapters.remove(adapterClass); | |
| 44 } | |
| 40 | 45 |
| 41 public <T> T getAdapter(Class<T> adapterClass) { | 46 public <T> T getAdapter(Class<T> adapterClass) { |
| 42 Object instance = adapters.get(adapterClass); | 47 Object instance = adapters.get(adapterClass); |
| 43 if (instance != null) { | 48 if (instance != null) { |
| 44 adapterUses.add(adapterClass); | 49 adapterUses.add(adapterClass); |
