pengda
5 years ago
14 changed files with 28 additions and 39 deletions
@ -1,6 +1,5 @@
|
||||
package com.fr.design; |
||||
package com.fr.design.os; |
||||
|
||||
public interface OSBasedAction { |
||||
void execute(); |
||||
} |
||||
|
@ -1,20 +1,19 @@
|
||||
package com.fr.design; |
||||
package com.fr.design.os; |
||||
|
||||
import com.fr.invoke.Reflect; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class OSSupportCenter { |
||||
|
||||
private static Map<Class,OSBasedAction> osBasedActionMap = new HashMap<Class,OSBasedAction>(); |
||||
private static Map<Class<? extends OSBasedAction>,OSBasedAction> osBasedActionMap = new HashMap<Class<? extends OSBasedAction>,OSBasedAction>(); |
||||
public static void buildAction(OSBasedAction action, SupportOS supportOS){ |
||||
if(supportOS.support()){ |
||||
action.execute(); |
||||
} |
||||
} |
||||
|
||||
public static <T extends OSBasedAction> T getAction(Class clazz) { |
||||
public static <T extends OSBasedAction> T getAction(Class<T> clazz) { |
||||
OSBasedAction action = osBasedActionMap.get(clazz); |
||||
if(action == null){ |
||||
action = Reflect.on(clazz).create().get(); |
@ -1,4 +1,4 @@
|
||||
package com.fr.design; |
||||
package com.fr.design.os; |
||||
|
||||
public interface SupportOS { |
||||
//判断是否支持
|
Loading…
Reference in new issue