Пример #1
0
 @Override
 public boolean isSuperTypeOf(Type type) {
   Type t = type;
   do {
     if (this == t) {
       return true;
     }
     t = t.getSuperType();
   } while (t != null);
   return false;
 }
Пример #2
0
 @Override
 public Type[] getTypeHierarchy() {
   Type type = getSuperType();
   if (type == null) {
     return EMPTY_SUPERTYPES;
   }
   List<Type> types = new ArrayList<Type>();
   while (type != null) {
     types.add(type);
     type = type.getSuperType();
   }
   return types.toArray(new Type[types.size()]);
 }
Пример #3
0
  public void testAnyType() throws TypeException {
    Type type = AnyType.INSTANCE;

    assertEquals(AnyType.ID, type.getName());
    assertTrue(type.isAnyType());
    assertFalse(type.isSimpleType());
    // assertFalse(type.isPrimitive());
    assertFalse(type.isComplexType());

    assertNull(type.getSuperType());
    assertEquals(0, type.getTypeHierarchy().length);

    // ANY validates anything
    assertTrue(type.validate(0));
    assertTrue(type.validate(""));
    assertTrue(type.validate(true));
  }
Пример #4
0
 private static Type getCommonInternal2(Type t1, Type t2) {
   if (t1 == t2) return t1;
   Type sup = t1.getSuperType();
   if (sup == t1) return t1;
   return getCommonInternal2(sup, t2.getSuperType());
 }