/** * Find the ClassDescriptor for the type that any random element selected from a collection * of objects must be an instance of, where each object is an instance of one of the classes * represented by the class descriptors in the input collection. This method does not * consider any of the sub-types of the classes in question. * * eg: * <dl> * <dt>Given <code>[Employee, Manager, CEO]</code></dt> * <dd>returns <code>Employee</code></dd> * <dt>Given <code>[CEO, Company]</code></dt> * <dd>returns <code>HasAddress</code></dd> * <dt>Given <code>[HasAddress, Employable]</code></dt> * <dd>throws an exception</dd> * <dt>Given <code>[]</code></dt> * <dd>throws an exception</dd> * </dl> * @param classes The classes to consider. * @return The lowest common denominator. * @throws MetaDataException if no such type exists. */ public static ClassDescriptor findSumType(Collection<ClassDescriptor> classes) throws MetaDataException { return findCommonClasses(classes).get(0); }
/** * Find the ClassDescriptor for the type that any random element selected from a collection * of objects must be an instance of, where each object is an instance of one of the classes * represented by the class descriptors in the input collection. This method does not * consider any of the sub-types of the classes in question. * * eg: * <dl> * <dt>Given <code>[Employee, Manager, CEO]</code></dt> * <dd>returns <code>Employee</code></dd> * <dt>Given <code>[CEO, Company]</code></dt> * <dd>returns <code>HasAddress</code></dd> * <dt>Given <code>[HasAddress, Employable]</code></dt> * <dd>throws an exception</dd> * <dt>Given <code>[]</code></dt> * <dd>throws an exception</dd> * </dl> * @param classes The classes to consider. * @return The lowest common denominator. * @throws MetaDataException if no such type exists. */ public static ClassDescriptor findSumType(Collection<ClassDescriptor> classes) throws MetaDataException { return findCommonClasses(classes).get(0); }
List<ClassDescriptor> commonTypes = findCommonClasses(classes); ClassDescriptor commonSuperType = commonTypes.get(0);
List<ClassDescriptor> commonTypes = findCommonClasses(classes); ClassDescriptor commonSuperType = commonTypes.get(0);