本文整理汇总了Java中com.mendix.systemwideinterfaces.core.IMendixObject.getType方法的典型用法代码示例。如果您正苦于以下问题:Java IMendixObject.getType方法的具体用法?Java IMendixObject.getType怎么用?Java IMendixObject.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mendix.systemwideinterfaces.core.IMendixObject
的用法示例。
在下文中一共展示了IMendixObject.getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProxy
import com.mendix.systemwideinterfaces.core.IMendixObject; //导入方法依赖的package包/类
public static <T> T createProxy(IContext c, Class<T> proxieClass, IMendixObject object) {
//Borrowed from nl.mweststrate.pages.MxQ package
if (object == null)
return null;
if (c == null || proxieClass == null)
throw new IllegalArgumentException("[CreateProxy] No context or proxieClass provided. ");
//jeuj, we expect IMendixObject's. Thats nice..
if (proxieClass == IMendixObject.class)
return proxieClass.cast(object); //.. since we can do a direct cast
try {
String entityType = object.getType();
if (!initializers.containsKey(entityType)) {
String[] entType = object.getType().split("\\.");
Class<?> realClass = Class.forName(entType[0].toLowerCase()+".proxies."+entType[1]);
initializers.put(entityType, realClass.getMethod("initialize", IContext.class, IMendixObject.class));
}
//find constructor
Method m = initializers.get(entityType);
//create proxy object
Object result = m.invoke(null, c, object);
//cast, but check first is needed because the actual type might be a subclass of the requested type
if (!proxieClass.isAssignableFrom(result.getClass()))
throw new IllegalArgumentException("The type of the object ('" + object.getType() + "') is not (a subclass) of '" + proxieClass.getName()+"'");
T proxie = proxieClass.cast(result);
return proxie;
}
catch (Exception e) {
throw new RuntimeException("Unable to instantiate proxie: " + e.getMessage(), e);
}
}