本文整理了Java中cascading.util.Util.hasInstanceMethod()
方法的一些代码示例,展示了Util.hasInstanceMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.hasInstanceMethod()
方法的具体详情如下:
包路径:cascading.util.Util
类名称:Util
方法名:hasInstanceMethod
暂无
代码示例来源:origin: cwensel/cascading
public static <C> C copyConfiguration( C parent )
{
if( parent == null )
throw new IllegalArgumentException( "parent may not be null" );
if( !( parent instanceof Configuration ) )
throw new IllegalArgumentException( "parent must be of type Configuration" );
Configuration conf = (Configuration) parent;
// see https://github.com/Cascading/cascading/pull/21
// The JobConf(JobConf) constructor causes derived JobConfs to share Credentials. We want to avoid this, in
// case those Credentials are mutated later on down the road (which they will be, during job submission, in
// separate threads!). Using the JobConf(Configuration) constructor avoids Credentials-sharing.
Configuration configurationCopy = new Configuration( conf );
Configuration copiedConf = callCopyConstructor( parent.getClass(), configurationCopy );
if( Util.hasInstanceMethod( parent, "getCredentials", null ) )
{
Object result = invokeInstanceMethod( parent, "getCredentials", null, null );
Object credentials = invokeInstanceMethod( copiedConf, "getCredentials", null, null );
invokeInstanceMethod( credentials, "addAll", new Object[]{result}, new Class[]{credentials.getClass()} );
}
return (C) copiedConf;
}
代码示例来源:origin: cascading/cascading-hadoop2-io
public static <C> C copyConfiguration( C parent )
{
if( parent == null )
throw new IllegalArgumentException( "parent may not be null" );
if( !( parent instanceof Configuration ) )
throw new IllegalArgumentException( "parent must be of type Configuration" );
Configuration conf = (Configuration) parent;
// see https://github.com/Cascading/cascading/pull/21
// The JobConf(JobConf) constructor causes derived JobConfs to share Credentials. We want to avoid this, in
// case those Credentials are mutated later on down the road (which they will be, during job submission, in
// separate threads!). Using the JobConf(Configuration) constructor avoids Credentials-sharing.
Configuration configurationCopy = new Configuration( conf );
Configuration copiedConf = callCopyConstructor( parent.getClass(), configurationCopy );
if( Util.hasInstanceMethod( parent, "getCredentials", null ) )
{
Object result = invokeInstanceMethod( parent, "getCredentials", null, null );
Object credentials = invokeInstanceMethod( copiedConf, "getCredentials", null, null );
invokeInstanceMethod( credentials, "addAll", new Object[]{result}, new Class[]{credentials.getClass()} );
}
return (C) copiedConf;
}
内容来源于网络,如有侵权,请联系作者删除!