当前位置: 首页>>代码示例>>Java>>正文


Java IMendixObject.getType方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:42,代码来源:XPath.java


注:本文中的com.mendix.systemwideinterfaces.core.IMendixObject.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。