EntityClass extends ModelClass<E> { public E create(Object constructionArgument) { checkNotNull(constructionArgument); E result = factory().create(constructionArgument); return result; } protected  EntityClass(Class<E> cls); static EntityClass<E> asEntityClass(Class<E> cls); E create(Object constructionArgument); final EntityFactory<E> factory(); final EntityState defaultState(); final Columns columns(); final Constructor<E> constructor(); final Class<?> idClass(); final Class<? extends EntityState> stateClass(); final MessageType stateType(); final EntityVisibility visibility(); final EntityTypeName typeName(); @SuppressWarnings("unchecked") // The cast is protected by the generic param of this class. @Override Class<E> value(); final TypeUrl stateTypeUrl(); @Override boolean equals(Object o); @Override int hashCode(); static Class<I> idClass(Class<? extends Entity> cls); static Class<S> stateClassOf(Class<? extends Entity> entityClass);  }
@Test @DisplayName("create and initialize entity instance") void createEntityInstance() { TaskId id = TaskId.generate(); Timestamp before = TimeTests.Past.secondsAgo(1); EntityClass<TaskEntity> entityClass = new EntityClass<>(TaskEntity.class); AbstractEntity<TaskId, Task> entity = entityClass.create(id); Timestamp after = Time.currentTime(); Range<Instant> whileWeCreate = Range.closed(toInstant(before), toInstant(after)); assertEquals(id, entity.id()); assertEquals(0, entity.version() .getNumber()); assertTrue(whileWeCreate.contains(toInstant(entity.whenModified()))); assertEquals(Task.getDefaultInstance(), entity.state()); assertFalse(entity.isArchived()); assertFalse(entity.isDeleted()); }