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 { |
public interface OSBasedAction { |
||||||
void execute(); |
void execute(); |
||||||
} |
} |
||||||
|
|
@ -1,21 +1,20 @@ |
|||||||
package com.fr.design; |
package com.fr.design.os; |
||||||
|
|
||||||
import com.fr.invoke.Reflect; |
import com.fr.invoke.Reflect; |
||||||
|
|
||||||
import java.util.HashMap; |
import java.util.HashMap; |
||||||
import java.util.Map; |
import java.util.Map; |
||||||
|
|
||||||
public class OSSupportCenter { |
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){ |
public static void buildAction(OSBasedAction action, SupportOS supportOS){ |
||||||
if(supportOS.support()){ |
if(supportOS.support()){ |
||||||
action.execute(); |
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); |
OSBasedAction action = osBasedActionMap.get(clazz); |
||||||
if(action == null){ |
if(action == null){ |
||||||
action = Reflect.on(clazz).create().get(); |
action = Reflect.on(clazz).create().get(); |
||||||
osBasedActionMap.put(clazz,action); |
osBasedActionMap.put(clazz,action); |
@ -1,6 +1,6 @@ |
|||||||
package com.fr.design; |
package com.fr.design.os; |
||||||
|
|
||||||
public interface SupportOS { |
public interface SupportOS { |
||||||
//判断是否支持
|
//判断是否支持
|
||||||
boolean support(); |
boolean support(); |
||||||
} |
} |
Loading…
Reference in new issue