code: private static boolean allowCustomClass(DataSchema schema)
    {
      boolean result = false;
      final DataSchema.Type type = schema.getType();
      if (type == DataSchema.Type.TYPEREF || type == DataSchema.Type.RECORD)
      {
        // allow custom class only if the dereferenced type is a record or a primitive types that are not enums
        final DataSchema dereferencedSchema = schema.getDereferencedDataSchema();
        if (dereferencedSchema.getType() == DataSchema.Type.RECORD || (CodeUtil.isDirectType(dereferencedSchema) && dereferencedSchema.getType() != DataSchema.Type.ENUM))
        {
          result = true;
        }
      }
      return result;
    }
docs: Allow custom class to to bound to record or typeref of primitive types that are not enums.