cascading.util.Util.hasInstanceMethod()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中cascading.util.Util.hasInstanceMethod()方法的一些代码示例,展示了Util.hasInstanceMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.hasInstanceMethod()方法的具体详情如下:
包路径:cascading.util.Util
类名称:Util
方法名:hasInstanceMethod

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;
 }

相关文章