Response.java

  1. package com.surrealdb;

  2. import java.util.Objects;

  3. /**
  4.  * The Response class is a specialized wrapper for handling responses from SurrealDB.
  5.  */
  6. public class Response extends Native {

  7.     Response(long ptr) {
  8.         super(ptr);
  9.     }

  10.     private static native int size(long ptr);

  11.     @Override
  12.     final native boolean deleteInstance(long ptr);

  13.     private native long take(long ptr, int num);

  14.     public Value take(int num) {
  15.         return new Value(take(getPtr(), num));
  16.     }

  17.     public <T> T take(Class<T> type, int num) {
  18.         return take(num).get(type);
  19.     }

  20.     public int size() {
  21.         return size(getPtr());
  22.     }

  23.     @Override
  24.     final String toString(long ptr) {
  25.         return getClass().getName() + "[ptr=" + ptr + "]";
  26.     }

  27.     @Override
  28.     final int hashCode(long ptr) {
  29.         return Objects.hashCode(ptr);
  30.     }

  31.     @Override
  32.     final boolean equals(long ptr1, long ptr2) {
  33.         return ptr1 == ptr2;
  34.     }

  35. }