public PropertyBuilder property(String name, @Nullable String targetEntityName, int type) { return property(name, targetEntityName, null, type); }
public PropertyBuilder property(String name, @Nullable String targetEntityName, @Nullable String virtualTarget, int type) { checkNotFinished(); checkFinishProperty(); propertyBuilder = new PropertyBuilder(name, targetEntityName, virtualTarget, type); return propertyBuilder; }
public ModelBuilder entityDone() { checkNotFinished(); checkFinishProperty(); finished = true; int testEntityNameOffset = fbb.createString(name); int propertiesOffset = createVector(propertyOffsets); int relationsOffset = relationOffsets.isEmpty() ? 0 : createVector(relationOffsets); ModelEntity.startModelEntity(fbb); ModelEntity.addName(fbb, testEntityNameOffset); ModelEntity.addProperties(fbb, propertiesOffset); if (relationsOffset != 0) ModelEntity.addRelations(fbb, relationsOffset); if (id != null && uid != null) { int idOffset = IdUid.createIdUid(fbb, id, uid); ModelEntity.addId(fbb, idOffset); } if (lastPropertyId != null) { int idOffset = IdUid.createIdUid(fbb, lastPropertyId, lastPropertyUid); ModelEntity.addLastPropertyId(fbb, idOffset); } if (flags != null) { ModelEntity.addFlags(fbb, flags); } entityOffsets.add(ModelEntity.endModelEntity(fbb)); return ModelBuilder.this; } }
private void addTestEntity(ModelBuilder modelBuilder, boolean withIndex) { lastEntityUid = ++lastUid; EntityBuilder entityBuilder = modelBuilder.entity("TestEntity").id(++lastEntityId, lastEntityUid); entityBuilder.property("id", PropertyType.Long).id(TestEntity_.id.id, ++lastUid) .flags(PropertyFlags.ID | (areIdsAssignable() ? PropertyFlags.ID_SELF_ASSIGNABLE : 0)); entityBuilder.property("simpleBoolean", PropertyType.Bool).id(TestEntity_.simpleBoolean.id, ++lastUid); entityBuilder.property("simpleByte", PropertyType.Byte).id(TestEntity_.simpleByte.id, ++lastUid); entityBuilder.property("simpleShort", PropertyType.Short).id(TestEntity_.simpleShort.id, ++lastUid); entityBuilder.property("simpleInt", PropertyType.Int).id(TestEntity_.simpleInt.id, ++lastUid); entityBuilder.property("simpleLong", PropertyType.Long).id(TestEntity_.simpleLong.id, ++lastUid); entityBuilder.property("simpleFloat", PropertyType.Float).id(TestEntity_.simpleFloat.id, ++lastUid); entityBuilder.property("simpleDouble", PropertyType.Double).id(TestEntity_.simpleDouble.id, ++lastUid); PropertyBuilder pb = entityBuilder.property("simpleString", PropertyType.String).id(TestEntity_.simpleString.id, ++lastUid); if (withIndex) { lastIndexUid = ++lastUid; pb.flags(PropertyFlags.INDEXED).indexId(++lastIndexId, lastIndexUid); } entityBuilder.property("simpleByteArray", PropertyType.ByteVector).id(TestEntity_.simpleByteArray.id, ++lastUid); int lastId = TestEntity_.simpleByteArray.id; entityBuilder.lastPropertyId(lastId, lastUid); addOptionalFlagsToTestEntity(entityBuilder); entityBuilder.entityDone(); }
public EntityBuilder relation(String name, int relationId, long relationUid, int targetEntityId, long targetEntityUid) { checkNotFinished(); checkFinishProperty(); int propertyNameOffset = fbb.createString(name); ModelRelation.startModelRelation(fbb); ModelRelation.addName(fbb, propertyNameOffset); int relationIdOffset = IdUid.createIdUid(fbb, relationId, relationUid); ModelRelation.addId(fbb, relationIdOffset); int targetEntityIdOffset = IdUid.createIdUid(fbb, targetEntityId, targetEntityUid); ModelRelation.addTargetEntityId(fbb, targetEntityIdOffset); relationOffsets.add(ModelRelation.endModelRelation(fbb)); return this; }
@Override protected void addOptionalFlagsToTestEntity(EntityBuilder entityBuilder) { entityBuilder.flags(EntityFlags.USE_NO_ARG_CONSTRUCTOR); }
public EntityBuilder entity(String name) { return new EntityBuilder(name); }
public PropertyBuilder property(String name, int type) { return property(name, null, type); }
private void addTestEntityMinimal(ModelBuilder modelBuilder, boolean withIndex) { lastEntityUid = ++lastUid; EntityBuilder entityBuilder = modelBuilder.entity("TestEntityMinimal").id(++lastEntityId, lastEntityUid); int pId = 0; entityBuilder.property("id", PropertyType.Long).id(++pId, ++lastUid).flags(PropertyFlags.ID); long lastPropertyUid = ++lastUid; PropertyBuilder pb = entityBuilder.property("text", PropertyType.String).id(++pId, lastPropertyUid); if (withIndex) { lastIndexUid = ++lastUid; pb.flags(PropertyFlags.INDEXED).indexId(++lastIndexId, lastIndexUid); } entityBuilder.lastPropertyId(pId, lastPropertyUid); entityBuilder.entityDone(); }
private static byte[] getModel() { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.lastEntityId(1, 1001L); modelBuilder.lastIndexId(0, 0L); EntityBuilder entityBuilder; entityBuilder = modelBuilder.entity("ObfuscatedEntity"); entityBuilder.id(1, 1001L).lastPropertyId(3, 1004L); entityBuilder.property("id", PropertyType.Long).id(1, 1002L) .flags(PropertyFlags.ID); entityBuilder.property("myInt", PropertyType.Int).id(2, 1003L); entityBuilder.property("myString", PropertyType.String).id(3, 1004L); entityBuilder.entityDone(); return modelBuilder.build(); }
public EntityBuilder lastPropertyId(int lastPropertyId, long lastPropertyUid) { checkNotFinished(); this.lastPropertyId = lastPropertyId; this.lastPropertyUid = lastPropertyUid; return this; }
public EntityBuilder id(int id, long uid) { checkNotFinished(); this.id = id; this.uid = uid; return this; }