io.axway.iron.ReadWriteTransaction Maven / Gradle / Ivy
The newest version!
package io.axway.iron;
import java.util.*;
import javax.annotation.*;
import io.axway.iron.functional.Accessor;
/**
* A read write transaction can be use by a {@link Command#execute(ReadWriteTransaction)} method to modify the model.
*/
public interface ReadWriteTransaction extends ReadonlyTransaction {
/**
* Insert a new instance in the model.
*
* @param entityClass the entity class of the instance to be inserted
* @param the type corresponding to the entity class (automatically inferred)
* @return a fluent interface to continue the call
*/
ObjectUpdater insert(Class entityClass);
/**
* Update an existing instance in the model.
*
* @param object the object to be update. This has been retrieved by using the methods in {@link ReadonlyTransaction}
* @param the type corresponding to the entity class (automatically inferred)
* @return a fluent interface to continue the call
*/
ObjectUpdater update(E object);
/**
* Delete an existing instance in the model.
*
* @param object the object to be deleted. This has been retrieved by using the methods in {@link ReadonlyTransaction}
*/
void delete(Object object);
interface ObjectUpdaterBase {
/**
* Begin the update of an instance member.
*
* @param accessor the member accessor method reference
* @param the type of instance member
* @return a fluent interface to continue the call
*/
To set(Accessor accessor);
/**
* Begin the update of an instance relation collection.
*
* @param accessor the member accessor method reference
* @param the type of instance member collection
* @param the type of instance member collection item
* @return a fluent interface to continue the call
*/
> CollectionUpdater onCollection(Accessor accessor);
}
interface To {
/**
* Specify the value to be set for the updated member.
*
* @param value the new member value
* @return a fluent interface to continue the call
*/
ObjectUpdater to(@Nullable V value);
}
interface ObjectUpdater extends ObjectUpdaterBase {
/**
* Must be called to validate any changes.
*
* @return the object instance, it is useful for {@link #insert(Class)} operations
*/
E done();
}
interface CollectionUpdater extends ObjectUpdater {
/**
* Add one element in the relation collection.
*
* @param object the head entity instance to be added
* @return the same object to continue the collection update
*/
CollectionUpdater add(H object);
/**
* Add many elements in the relation collection.
*
* @param objects the head entity instances to be added
* @return the same object to continue the collection update
*/
CollectionUpdater addAll(Collection objects);
/**
* Remove one element in the relation collection.
*
* @param object the head entity instance to be removed
* @return the same object to continue the collection update
*/
CollectionUpdater remove(H object);
/**
* Remove many elements in the relation collection.
*
* @param objects the head entity instances to be removed
* @return the same object to continue the collection update
*/
CollectionUpdater removeAll(Collection objects);
/**
* Remove all elements in the relation collection.
*
* @return the same object to continue the collection update
*/
CollectionUpdater clear();
}
}