Exemplo n.º 1
0
    public static CursorFactory fromProto(Common.CursorFactory proto) {
      // Reconstruct CursorFactory
      Class<?> clz = null;

      FieldDescriptor clzFieldDesc =
          proto
              .getDescriptorForType()
              .findFieldByNumber(Common.CursorFactory.CLASS_NAME_FIELD_NUMBER);

      if (proto.hasField(clzFieldDesc)) {
        try {
          clz = Class.forName(proto.getClassName());
        } catch (ClassNotFoundException e) {
          throw new RuntimeException(e);
        }
      }

      return CursorFactory.create(
          Style.fromProto(proto.getStyle()), clz, proto.getFieldNamesList());
    }