org.codehaus.plexus.context.Context.contains()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(99)

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

Context.contains介绍

[英]Returns true if the map or the parent map contains the key.
[中]如果映射或父映射包含键,则返回true。

代码示例

代码示例来源:origin: org.codehaus.plexus/com.springsource.org.codehaus.plexus.container

/**
 * Returns true if the map or the parent map contains the key.
 *
 * @param key The key to search for.
 * @return Returns true if the key was found.
 */
public boolean contains( Object key )
{
  Object data = contextData.get( key );
  if ( null != data )
  {
    if ( data instanceof Hidden )
    {
      return false;
    }
    return true;
  }
  // If data was null, check the parent
  if ( null == parent )
  {
    return false;
  }
  return parent.contains( key );
}

代码示例来源:origin: org.codehaus.mojo/build-context

public static Map getContextContainerMap( String containerKey, Context context, boolean create )
{
  Map containerMap = null;
  if ( context.contains( containerKey ) )
  {
    try
    {
      containerMap = (Map) context.get( containerKey );
    }
    catch ( ContextException e )
    {
      throw new IllegalStateException( "Failed to retrieve BuildAdvisor "
              + "serialization map from context, though the context claims it exists. Error: "
              + e.getMessage() );
    }
  }
  else if ( create )
  {
    containerMap = new HashMap();
    context.put( containerKey, containerMap );
  }
  return containerMap;
}

代码示例来源:origin: org.wisdom-framework/wisdom-maven-plugin

/**
 * Gets the list of watchers from the given Plexus context.
 *
 * @param context the Plexus context
 * @return the list of watcher, empty if none. Modifying the resulting list, updates the stored list.
 */
static synchronized List<Watcher> get(Context context) {
  List<Watcher> watchers;
  if (context.contains(WATCHERS_KEY)) {
    try {
      watchers = (List<Watcher>) context.get(WATCHERS_KEY);
    } catch (ContextException e) {
      throw new IllegalStateException("Cannot extract the watcher from the context", e);
    }
  } else {
    watchers = new ArrayList<>();
    context.put(WATCHERS_KEY, watchers);
  }
  return watchers;
}

代码示例来源:origin: org.codehaus.plexus/plexus-appserver-host

public void contextualize( Context context )
  throws ContextException
{
  container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
  container.addContextValue( ApplicationServerConstants.APP_SERVER_CONTEXT_KEY, this );
  if ( context.contains( ApplicationServerConstants.APP_SERVER_HOME_KEY ) )
  {
    appServerHome = new File( (String) context.get( ApplicationServerConstants.APP_SERVER_HOME_KEY ) );
  }
  else if ( context.contains( "plexus.home" ) )
  {
    appServerHome = new File( (String) context.get( "plexus.home" ) );
  }
  if ( context.contains( ApplicationServerConstants.APP_SERVER_BASE_KEY ) )
  {
    appServerBase = new File( (String) context.get( ApplicationServerConstants.APP_SERVER_BASE_KEY ) );
  }
  else
  {
    appServerBase = appServerHome;
  }
}

代码示例来源:origin: org.eclipse.sisu/org.eclipse.sisu.plexus

private final Map<Object, Object> context()
{
  final Context context = new DefaultContext();
  context.put( "basedir", getBasedir() );
  // Per-test context customization
  customizeContext( context );
  // Provide 'plexus.home' fall-back
  if ( !context.contains( PLEXUS_HOME ) )
  {
    context.put( PLEXUS_HOME, plexusHome() );
  }
  return context.getContextData();
}

相关文章

微信公众号

最新文章

更多