class JpaItemWriterBuilder<T> {

	private EntityManagerFactory entityManagerFactory;

	private boolean usePersist = false;

	private boolean clearPersistenceContext = true;

	/**
	 * The JPA {@link EntityManagerFactory} to obtain an entity manager from. Required.
	 * @param entityManagerFactory the {@link EntityManagerFactory}
	 * @return this instance for method chaining
	 * @see JpaItemWriter#setEntityManagerFactory(EntityManagerFactory)
	 */
	public JpaItemWriterBuilder<T> entityManagerFactory(EntityManagerFactory entityManagerFactory) {
		this.entityManagerFactory = entityManagerFactory;

		return this;
	}

	/**
	 * Set whether the entity manager should perform a persist instead of a merge.
	 * @param usePersist defaults to false
	 * @return this instance for method chaining
	 * @see JpaItemWriter#setUsePersist(boolean)
	 */
	public JpaItemWriterBuilder<T> usePersist(boolean usePersist) {
		this.usePersist = usePersist;

		return this;
	}

	/**
	 * If set to false, the {@link jakarta.persistence.EntityManager} will not be cleared
	 * at the end of the chunk. defaults to true
	 * @param clearPersistenceContext true if the persistence context should be cleared
	 * after writing items, false otherwise
	 * @return this instance for method chaining
	 * @see org.springframework.batch.item.database.JpaItemWriter#setClearPersistenceContext(boolean)
	 * @since 5.1
	 */
	public JpaItemWriterBuilder<T> clearPersistenceContext(boolean clearPersistenceContext) {
		this.clearPersistenceContext = clearPersistenceContext;

		return this;
	}

	/**
	 * Returns a fully built {@link JpaItemWriter}.
	 * @return the writer
	 */
	public JpaItemWriter<T> build() {<FILL_FUNCTION_BODY>}

}

		Assert.state(this.entityManagerFactory != null, "EntityManagerFactory must be provided");

		JpaItemWriter<T> writer = new JpaItemWriter<>();
		writer.setEntityManagerFactory(this.entityManagerFactory);
		writer.setUsePersist(this.usePersist);
		writer.setClearPersistenceContext(this.clearPersistenceContext);

		return writer;
	
<no_super_class>