/** * {@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; }
/** * 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(); }
/** * 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(); } }
/** * 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; }
private void assignPartOf(String parent, String child) { if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) { Util.addToSetMap(partOfs, child, parent); } }
/** * 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; }
/** * 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(); } }
/** * 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; }
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); } } } }
/** * 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; }
/** * {@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; }
/** * 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; }
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; }
/** * 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(); }
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); } } } }
/** * 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; }
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; }