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

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

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

Util介绍

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

代码示例

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean equals(Object o) {
  6. if (o instanceof PathExpressionField) {
  7. PathExpressionField pef = (PathExpressionField) o;
  8. return Util.equals(qope, pef.qope) && (fieldNumber == pef.fieldNumber);
  9. }
  10. return false;
  11. }

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

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

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public int hashCode() {
  6. return 2 * queryString.hashCode()
  7. + 3 * Util.hashCode(packageName)
  8. + 5 * Util.hashCode(parameters);
  9. }

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

  1. /**
  2. * Creates a friendly description of an object - that is, the class and the ID (if it has one).
  3. *
  4. * @param o the object to be described
  5. * @return a String description
  6. */
  7. public static String getFriendlyDesc(Object o) {
  8. if (o instanceof InterMineObject) {
  9. return Util.getFriendlyName(o.getClass()) + ":" + ((InterMineObject) o).getId();
  10. } else {
  11. return o.toString();
  12. }
  13. }

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

  1. /**
  2. * Returns true if sup is a superclass of sub (or the same), taking into account dynamic
  3. * classes.
  4. *
  5. * @param sup the supposed superclass
  6. * @param sub the supposed subclass
  7. * @return a boolean
  8. */
  9. public static boolean isAssignableFrom(Class<?> sup, Class<?> sub) {
  10. Set<Class<?>> classes = Util.decomposeClass(sup);
  11. for (Class<?> clazz : classes) {
  12. if (!clazz.isAssignableFrom(sub)) {
  13. return false;
  14. }
  15. }
  16. return true;
  17. }

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

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

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

  1. /**
  2. * Takes two integers, and returns the lowest common multiple.
  3. *
  4. * @param a an integer
  5. * @param b an integer
  6. * @return the lcm of a and b
  7. */
  8. public static int lcm(int a, int b) {
  9. return (a / gcd(a, b)) * b;
  10. }

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

  1. /**
  2. * Creates a friendly description of an object - that is, the class and the ID (if it has one).
  3. *
  4. * @param o the object to be described
  5. * @return a String description
  6. */
  7. public static String getFriendlyDesc(Object o) {
  8. if (o instanceof InterMineObject) {
  9. return Util.getFriendlyName(o.getClass()) + ":" + ((InterMineObject) o).getId();
  10. } else {
  11. return o.toString();
  12. }
  13. }

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

  1. /**
  2. * Returns true if sup is a superclass of sub (or the same), taking into account dynamic
  3. * classes.
  4. *
  5. * @param sup the supposed superclass
  6. * @param sub the supposed subclass
  7. * @return a boolean
  8. */
  9. public static boolean isAssignableFrom(Class<?> sup, Class<?> sub) {
  10. Set<Class<?>> classes = Util.decomposeClass(sup);
  11. for (Class<?> clazz : classes) {
  12. if (!clazz.isAssignableFrom(sub)) {
  13. return false;
  14. }
  15. }
  16. return true;
  17. }

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

  1. private void buildParentsMap() {
  2. parentToChildren = new HashMap<String, Set<String>>();
  3. for (String child : childToParents.keySet()) {
  4. Set<String> parents = childToParents.get(child);
  5. for (String parent : parents) {
  6. if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) {
  7. Util.addToSetMap(parentToChildren, parent, child);
  8. }
  9. }
  10. }
  11. }

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

  1. /**
  2. * Takes two integers, and returns the lowest common multiple.
  3. *
  4. * @param a an integer
  5. * @param b an integer
  6. * @return the lcm of a and b
  7. */
  8. public static int lcm(int a, int b) {
  9. return (a / gcd(a, b)) * b;
  10. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean equals(Object o) {
  6. if (o instanceof PathExpressionField) {
  7. PathExpressionField pef = (PathExpressionField) o;
  8. return Util.equals(qope, pef.qope) && (fieldNumber == pef.fieldNumber);
  9. }
  10. return false;
  11. }

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

  1. /**
  2. * Constructs a QueryClass representing the specified set of classes and ObjectStoreBag.
  3. *
  4. * @param types the Set of classes
  5. * @param osb the ObjectStoreBag
  6. */
  7. public QueryClassBag(Set<Class<?>> types, ObjectStoreBag osb) {
  8. Class<?> clazz;
  9. if (types.size() == 1) {
  10. clazz = types.iterator().next();
  11. } else {
  12. clazz = DynamicUtil.composeClass(types);
  13. }
  14. if (!InterMineObject.class.isAssignableFrom(clazz)) {
  15. throw new IllegalArgumentException("Cannot create a QueryClassBag with a class that"
  16. + " is not a subclass of InterMineObject: " + Util.getFriendlyName(
  17. clazz));
  18. }
  19. @SuppressWarnings("unchecked") Class<? extends InterMineObject> thisType = (Class) clazz;
  20. this.type = thisType;
  21. this.osb = osb;
  22. this.ids = null;
  23. this.bag = null;
  24. }

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

  1. private Set<String> getIgnorableFields(FastPathObject obj) {
  2. Set<String> ret = new HashSet<String>();
  3. for (Class<?> clazz: Util.decomposeClass(obj.getClass())) {
  4. if (ignoredFields.containsKey(clazz)) {
  5. ret.addAll(ignoredFields.get(clazz));
  6. }
  7. }
  8. return ret;
  9. }

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

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

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public int hashCode() {
  6. return 2 * queryString.hashCode()
  7. + 3 * Util.hashCode(packageName)
  8. + 5 * Util.hashCode(parameters);
  9. }

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

  1. private void setReverseReferences() {
  2. Map<String, Set<String>> partOfsCopy = new HashMap<String, Set<String>>(partOfs);
  3. for (Map.Entry<String, Set<String>> entry : partOfsCopy.entrySet()) {
  4. String oboTerm = entry.getKey();
  5. Set<String> parents = new HashSet<String>(entry.getValue());
  6. for (String parent : parents) {
  7. if (parent.equals(CHROMOSOME)) {
  8. continue;
  9. }
  10. if (!StringUtils.isEmpty(oboTerm) && !StringUtils.isEmpty(parent)) {
  11. Util.addToSetMap(reversePartOfs, parent, oboTerm);
  12. }
  13. }
  14. }
  15. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public boolean equals(Object o) {
  6. return (o instanceof Node)
  7. && Util.equals(type, ((Node) o).type)
  8. && Util.equals(parent, ((Node) o).parent)
  9. && Util.equals(fieldName, ((Node) o).fieldName);
  10. }

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

  1. /**
  2. * Constructs a QueryClass representing the specified set of classes and ObjectStoreBag.
  3. *
  4. * @param types the Set of classes
  5. * @param osb the ObjectStoreBag
  6. */
  7. public QueryClassBag(Set<Class<?>> types, ObjectStoreBag osb) {
  8. Class<?> clazz;
  9. if (types.size() == 1) {
  10. clazz = types.iterator().next();
  11. } else {
  12. clazz = DynamicUtil.composeClass(types);
  13. }
  14. if (!InterMineObject.class.isAssignableFrom(clazz)) {
  15. throw new IllegalArgumentException("Cannot create a QueryClassBag with a class that"
  16. + " is not a subclass of InterMineObject: " + Util.getFriendlyName(
  17. clazz));
  18. }
  19. @SuppressWarnings("unchecked") Class<? extends InterMineObject> thisType = (Class) clazz;
  20. this.type = thisType;
  21. this.osb = osb;
  22. this.ids = null;
  23. this.bag = null;
  24. }

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

  1. private Set<String> getIgnorableFields(FastPathObject obj) {
  2. Set<String> ret = new HashSet<String>();
  3. for (Class<?> clazz: Util.decomposeClass(obj.getClass())) {
  4. if (ignoredFields.containsKey(clazz)) {
  5. ret.addAll(ignoredFields.get(clazz));
  6. }
  7. }
  8. return ret;
  9. }

相关文章