org.intermine.metadata.Util类的使用及代码示例

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

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

Util介绍

[英]Generic utility functions.
[中]通用实用函数。

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
  if (o instanceof PathExpressionField) {
    PathExpressionField pef = (PathExpressionField) o;
    return Util.equals(qope, pef.qope) && (fieldNumber == pef.fieldNumber);
  }
  return false;
}

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

/**
 * Returns the result of decomposeClass if that is a single class, or throws an exception if
 * there are more than one.
 *
 * @param clazz the class
 * @return the corresponding non-dynamic class
 */
@SuppressWarnings("unchecked")
public static Class<? extends FastPathObject> getSimpleClass(
    Class<? extends FastPathObject> clazz) {
  Set<Class<?>> decomposed = Util.decomposeClass(clazz);
  if (decomposed.size() > 1) {
    throw new IllegalArgumentException("No simple class for "
        + Util.getFriendlyName(clazz));
  }
  return (Class) decomposed.iterator().next();
}

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

/**
 * {@inheritDoc}
 */
@Override
public int hashCode() {
  return 2 * queryString.hashCode()
    + 3 * Util.hashCode(packageName)
    + 5 * Util.hashCode(parameters);
}

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

/**
 * Creates a friendly description of an object - that is, the class and the ID (if it has one).
 *
 * @param o the object to be described
 * @return a String description
 */
public static String getFriendlyDesc(Object o) {
  if (o instanceof InterMineObject) {
    return Util.getFriendlyName(o.getClass()) + ":" + ((InterMineObject) o).getId();
  } else {
    return o.toString();
  }
}

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

/**
 * Returns true if sup is a superclass of sub (or the same), taking into account dynamic
 * classes.
 *
 * @param sup the supposed superclass
 * @param sub the supposed subclass
 * @return a boolean
 */
public static boolean isAssignableFrom(Class<?> sup, Class<?> sub) {
  Set<Class<?>> classes = Util.decomposeClass(sup);
  for (Class<?> clazz : classes) {
    if (!clazz.isAssignableFrom(sub)) {
      return false;
    }
  }
  return true;
}

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

private void assignPartOf(String parent, String child) {
  if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) {
    Util.addToSetMap(partOfs, child, parent);
  }
}

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

/**
 * Takes two integers, and returns the lowest common multiple.
 *
 * @param a an integer
 * @param b an integer
 * @return the lcm of a and b
 */
public static int lcm(int a, int b) {
  return (a / gcd(a, b)) * b;
}

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

/**
 * Creates a friendly description of an object - that is, the class and the ID (if it has one).
 *
 * @param o the object to be described
 * @return a String description
 */
public static String getFriendlyDesc(Object o) {
  if (o instanceof InterMineObject) {
    return Util.getFriendlyName(o.getClass()) + ":" + ((InterMineObject) o).getId();
  } else {
    return o.toString();
  }
}

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

/**
 * Returns true if sup is a superclass of sub (or the same), taking into account dynamic
 * classes.
 *
 * @param sup the supposed superclass
 * @param sub the supposed subclass
 * @return a boolean
 */
public static boolean isAssignableFrom(Class<?> sup, Class<?> sub) {
  Set<Class<?>> classes = Util.decomposeClass(sup);
  for (Class<?> clazz : classes) {
    if (!clazz.isAssignableFrom(sub)) {
      return false;
    }
  }
  return true;
}

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

private void buildParentsMap() {
  parentToChildren = new HashMap<String, Set<String>>();
  for (String child : childToParents.keySet()) {
    Set<String> parents = childToParents.get(child);
    for (String parent : parents) {
      if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) {
        Util.addToSetMap(parentToChildren, parent, child);
      }
    }
  }
}

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

/**
 * Takes two integers, and returns the lowest common multiple.
 *
 * @param a an integer
 * @param b an integer
 * @return the lcm of a and b
 */
public static int lcm(int a, int b) {
  return (a / gcd(a, b)) * b;
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
  if (o instanceof PathExpressionField) {
    PathExpressionField pef = (PathExpressionField) o;
    return Util.equals(qope, pef.qope) && (fieldNumber == pef.fieldNumber);
  }
  return false;
}

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

/**
 * Constructs a QueryClass representing the specified set of classes and ObjectStoreBag.
 *
 * @param types the Set of classes
 * @param osb the ObjectStoreBag
 */
public QueryClassBag(Set<Class<?>> types, ObjectStoreBag osb) {
  Class<?> clazz;
  if (types.size() == 1) {
    clazz = types.iterator().next();
  } else {
    clazz = DynamicUtil.composeClass(types);
  }
  if (!InterMineObject.class.isAssignableFrom(clazz)) {
    throw new IllegalArgumentException("Cannot create a QueryClassBag with a class that"
        + " is not a subclass of InterMineObject: " + Util.getFriendlyName(
            clazz));
  }
  @SuppressWarnings("unchecked") Class<? extends InterMineObject> thisType = (Class) clazz;
  this.type = thisType;
  this.osb = osb;
  this.ids = null;
  this.bag = null;
}

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

private Set<String> getIgnorableFields(FastPathObject obj) {
  Set<String> ret = new HashSet<String>();
  for (Class<?> clazz: Util.decomposeClass(obj.getClass())) {
    if (ignoredFields.containsKey(clazz)) {
      ret.addAll(ignoredFields.get(clazz));
    }
  }
  return ret;
}

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

/**
 * Returns the result of decomposeClass if that is a single class, or throws an exception if
 * there are more than one.
 *
 * @param clazz the class
 * @return the corresponding non-dynamic class
 */
@SuppressWarnings("unchecked")
public static Class<? extends FastPathObject> getSimpleClass(
    Class<? extends FastPathObject> clazz) {
  Set<Class<?>> decomposed = Util.decomposeClass(clazz);
  if (decomposed.size() > 1) {
    throw new IllegalArgumentException("No simple class for "
        + Util.getFriendlyName(clazz));
  }
  return (Class) decomposed.iterator().next();
}

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

/**
 * {@inheritDoc}
 */
@Override
public int hashCode() {
  return 2 * queryString.hashCode()
    + 3 * Util.hashCode(packageName)
    + 5 * Util.hashCode(parameters);
}

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

private void setReverseReferences() {
  Map<String, Set<String>> partOfsCopy = new HashMap<String, Set<String>>(partOfs);
  for (Map.Entry<String, Set<String>> entry : partOfsCopy.entrySet()) {
    String oboTerm = entry.getKey();
    Set<String> parents = new HashSet<String>(entry.getValue());
    for (String parent : parents) {
      if (parent.equals(CHROMOSOME)) {
        continue;
      }
      if (!StringUtils.isEmpty(oboTerm) && !StringUtils.isEmpty(parent)) {
        Util.addToSetMap(reversePartOfs, parent, oboTerm);
      }
    }
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
  return (o instanceof Node)
    && Util.equals(type, ((Node) o).type)
    && Util.equals(parent, ((Node) o).parent)
    && Util.equals(fieldName, ((Node) o).fieldName);
}

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

/**
 * Constructs a QueryClass representing the specified set of classes and ObjectStoreBag.
 *
 * @param types the Set of classes
 * @param osb the ObjectStoreBag
 */
public QueryClassBag(Set<Class<?>> types, ObjectStoreBag osb) {
  Class<?> clazz;
  if (types.size() == 1) {
    clazz = types.iterator().next();
  } else {
    clazz = DynamicUtil.composeClass(types);
  }
  if (!InterMineObject.class.isAssignableFrom(clazz)) {
    throw new IllegalArgumentException("Cannot create a QueryClassBag with a class that"
        + " is not a subclass of InterMineObject: " + Util.getFriendlyName(
            clazz));
  }
  @SuppressWarnings("unchecked") Class<? extends InterMineObject> thisType = (Class) clazz;
  this.type = thisType;
  this.osb = osb;
  this.ids = null;
  this.bag = null;
}

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

private Set<String> getIgnorableFields(FastPathObject obj) {
  Set<String> ret = new HashSet<String>();
  for (Class<?> clazz: Util.decomposeClass(obj.getClass())) {
    if (ignoredFields.containsKey(clazz)) {
      ret.addAll(ignoredFields.get(clazz));
    }
  }
  return ret;
}

相关文章