org.intermine.metadata.Util.stripStart()方法的使用及代码示例

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

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

Util.stripStart介绍

[英]Strips the given string off the keys of the given Properties, and returns a new set of properties. The original properties are not altered.
For example, given the property:

  • database.name=production
    a call to stripStart("database", props) will produce:

  • name=production
    Note that a dot will be added to the prefix.
    [中]从给定属性的键中去除给定字符串,并返回一组新属性。原始属性没有改变。
    例如,给定属性:

  • database.name=production
    致电stripStart("database", props)将产生:

  • name=production
    请注意,前缀中将添加一个点。

代码示例

代码示例来源:origin: intermine/intermine

/**
 * Retrieve a map from key name to PrimaryKey object. The Map contains all the primary keys
 * that exist on a particular class, without performing any recursion.
 *
 * @param cld the ClassDescriptor to fetch primary keys for
 * @return the Map from key names to PrimaryKeys
 */
public static Map<String, PrimaryKey> getPrimaryKeys(ClassDescriptor cld) {
  Map<String, PrimaryKey> keyMap = primaryKeyCache.get(cld);
  if (keyMap == null) {
    keyMap = new LinkedHashMap<String, PrimaryKey>();
    Properties keys = getKeyProperties(cld.getModel().getName());
    String cldName = Util.unqualifiedName(cld.getName());
    Properties cldKeys = Util.getPropertiesStartingWith(cldName, keys);
    cldKeys = Util.stripStart(cldName, cldKeys);
    List<String> keyNames = new ArrayList<String>();
    for (Object key : cldKeys.keySet()) {
      if (key instanceof String) {
        keyNames.add((String) key);
      }
    }
    Collections.sort(keyNames);
    for (String keyName : keyNames) {
      PrimaryKey key = new PrimaryKey(keyName, (String) cldKeys.get(keyName), cld);
      keyMap.put(keyName, key);
    }
    primaryKeyCache.put(cld, keyMap);
  }
  return keyMap;
}

代码示例来源:origin: org.intermine/intermine-model

/**
 * Retrieve a map from key name to PrimaryKey object. The Map contains all the primary keys
 * that exist on a particular class, without performing any recursion.
 *
 * @param cld the ClassDescriptor to fetch primary keys for
 * @return the Map from key names to PrimaryKeys
 */
public static Map<String, PrimaryKey> getPrimaryKeys(ClassDescriptor cld) {
  Map<String, PrimaryKey> keyMap = primaryKeyCache.get(cld);
  if (keyMap == null) {
    keyMap = new LinkedHashMap<String, PrimaryKey>();
    Properties keys = getKeyProperties(cld.getModel().getName());
    String cldName = Util.unqualifiedName(cld.getName());
    Properties cldKeys = Util.getPropertiesStartingWith(cldName, keys);
    cldKeys = Util.stripStart(cldName, cldKeys);
    List<String> keyNames = new ArrayList<String>();
    for (Object key : cldKeys.keySet()) {
      if (key instanceof String) {
        keyNames.add((String) key);
      }
    }
    Collections.sort(keyNames);
    for (String keyName : keyNames) {
      PrimaryKey key = new PrimaryKey(keyName, (String) cldKeys.get(keyName), cld);
      keyMap.put(keyName, key);
    }
    primaryKeyCache.put(cld, keyMap);
  }
  return keyMap;
}

相关文章