...

Text file src/github.com/google/flatbuffers/tests/MyGame/Example/Referrable.java

Documentation: github.com/google/flatbuffers/tests/MyGame/Example

     1// automatically generated by the FlatBuffers compiler, do not modify
     2
     3package MyGame.Example;
     4
     5import com.google.flatbuffers.BaseVector;
     6import com.google.flatbuffers.BooleanVector;
     7import com.google.flatbuffers.ByteVector;
     8import com.google.flatbuffers.Constants;
     9import com.google.flatbuffers.DoubleVector;
    10import com.google.flatbuffers.FlatBufferBuilder;
    11import com.google.flatbuffers.FloatVector;
    12import com.google.flatbuffers.IntVector;
    13import com.google.flatbuffers.LongVector;
    14import com.google.flatbuffers.ShortVector;
    15import com.google.flatbuffers.StringVector;
    16import com.google.flatbuffers.Struct;
    17import com.google.flatbuffers.Table;
    18import com.google.flatbuffers.UnionVector;
    19import java.nio.ByteBuffer;
    20import java.nio.ByteOrder;
    21
    22@SuppressWarnings("unused")
    23public final class Referrable extends Table {
    24  public static void ValidateVersion() { Constants.FLATBUFFERS_23_5_26(); }
    25  public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
    26  public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
    27  public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
    28  public Referrable __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
    29
    30  public long id() { int o = __offset(4); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
    31  public boolean mutateId(long id) { int o = __offset(4); if (o != 0) { bb.putLong(o + bb_pos, id); return true; } else { return false; } }
    32
    33  public static int createReferrable(FlatBufferBuilder builder,
    34      long id) {
    35    builder.startTable(1);
    36    Referrable.addId(builder, id);
    37    return Referrable.endReferrable(builder);
    38  }
    39
    40  public static void startReferrable(FlatBufferBuilder builder) { builder.startTable(1); }
    41  public static void addId(FlatBufferBuilder builder, long id) { builder.addLong(id); builder.slot(0); }
    42  public static int endReferrable(FlatBufferBuilder builder) {
    43    int o = builder.endTable();
    44    return o;
    45  }
    46
    47  @Override
    48  protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
    49    long val_1 = _bb.getLong(__offset(4, o1, _bb));
    50    long val_2 = _bb.getLong(__offset(4, o2, _bb));
    51    return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
    52  }
    53
    54  public static Referrable __lookup_by_key(Referrable obj, int vectorLocation, long key, ByteBuffer bb) {
    55    int span = bb.getInt(vectorLocation - 4);
    56    int start = 0;
    57    while (span != 0) {
    58      int middle = span / 2;
    59      int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
    60      long val = bb.getLong(__offset(4, bb.capacity() - tableOffset, bb));
    61      int comp = val > key ? 1 : val < key ? -1 : 0;
    62      if (comp > 0) {
    63        span = middle;
    64      } else if (comp < 0) {
    65        middle++;
    66        start += middle;
    67        span -= middle;
    68      } else {
    69        return (obj == null ? new Referrable() : obj).__assign(tableOffset, bb);
    70      }
    71    }
    72    return null;
    73  }
    74
    75  public static final class Vector extends BaseVector {
    76    public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
    77
    78    public Referrable get(int j) { return get(new Referrable(), j); }
    79    public Referrable get(Referrable obj, int j) {  return obj.__assign(__indirect(__element(j), bb), bb); }
    80    public Referrable getByKey(long key) {  return __lookup_by_key(null, __vector(), key, bb); }
    81    public Referrable getByKey(Referrable obj, long key) {  return __lookup_by_key(obj, __vector(), key, bb); }
    82  }
    83  public ReferrableT unpack() {
    84    ReferrableT _o = new ReferrableT();
    85    unpackTo(_o);
    86    return _o;
    87  }
    88  public void unpackTo(ReferrableT _o) {
    89    long _oId = id();
    90    _o.setId(_oId);
    91  }
    92  public static int pack(FlatBufferBuilder builder, ReferrableT _o) {
    93    if (_o == null) return 0;
    94    return createReferrable(
    95      builder,
    96      _o.getId());
    97  }
    98}
    99

View as plain text