private static void getInterfaces(Class clazz, Set<Class> interfaces) {
   final Class[] classes = clazz.getInterfaces();
   if (classes.length > 0) {
     Collections.addAll(interfaces, classes);
     for (Class cl : classes) {
       getInterfaces(cl, interfaces);
     }
   }
 }
 public SerializerAdapter serializerFor(final Class type) {
   if (DataSerializable.class.isAssignableFrom(type)) {
     return dataSerializerAdapter;
   } else if (Portable.class.isAssignableFrom(type)) {
     return portableSerializerAdapter;
   } else {
     final SerializerAdapter serializer;
     if ((serializer = constantTypesMap.get(type)) != null) {
       return serializer;
     }
   }
   SerializerAdapter serializer = typeMap.get(type);
   if (serializer == null) {
     // look for super classes
     Class typeSuperclass = type.getSuperclass();
     final Set<Class> interfaces = new LinkedHashSet<Class>(5);
     getInterfaces(type, interfaces);
     while (typeSuperclass != null) {
       if ((serializer = registerFromSuperType(type, typeSuperclass)) != null) {
         break;
       }
       getInterfaces(typeSuperclass, interfaces);
       typeSuperclass = typeSuperclass.getSuperclass();
     }
     if (serializer == null) {
       // look for interfaces
       for (Class typeInterface : interfaces) {
         if ((serializer = registerFromSuperType(type, typeInterface)) != null) {
           break;
         }
       }
     }
     if (serializer == null && (serializer = global.get()) != null) {
       safeRegister(type, serializer);
     }
   }
   return serializer;
 }