Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.elder.sourcerer.Operations Maven / Gradle / Ivy
package org.elder.sourcerer;
import org.elder.sourcerer.functions.AppendHandler;
import org.elder.sourcerer.functions.AppendHandlerSingle;
import org.elder.sourcerer.functions.ConstructorHandler;
import org.elder.sourcerer.functions.ConstructorHandlerSingle;
import org.elder.sourcerer.functions.ParameterizedAppendHandler;
import org.elder.sourcerer.functions.ParameterizedAppendHandlerSingle;
import org.elder.sourcerer.functions.ParameterizedConstructorHandler;
import org.elder.sourcerer.functions.ParameterizedConstructorHandlerSingle;
import org.elder.sourcerer.functions.ParameterizedPojoUpdateHandler;
import org.elder.sourcerer.functions.ParameterizedPojoUpdateHandlerSingle;
import org.elder.sourcerer.functions.ParameterizedUpdateHandler;
import org.elder.sourcerer.functions.ParameterizedUpdateHandlerSingle;
import org.elder.sourcerer.functions.ParameterizedUpdateHandlerAggregate;
import org.elder.sourcerer.functions.PojoUpdateHandler;
import org.elder.sourcerer.functions.PojoUpdateHandlerSingle;
import org.elder.sourcerer.functions.UpdateHandler;
import org.elder.sourcerer.functions.UpdateHandlerSingle;
import org.elder.sourcerer.functions.UpdateHandlerAggregate;
/**
* Utility functions for building functions from various method types.
*/
public final class Operations {
private Operations() {
}
public static Operation constructorOf(
final ConstructorHandler handler) {
return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated());
}
public static Operation constructorOf(
final ConstructorHandlerSingle handler) {
return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated());
}
public static Operation constructorOf(
final ParameterizedConstructorHandler handler) {
return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated());
}
public static Operation constructorOf(
final ParameterizedConstructorHandlerSingle handler) {
return new OperationHandlerOperation<>(handler, false, false, ExpectedVersion.notCreated());
}
public static Operation appendOf(
final AppendHandler handler) {
return new OperationHandlerOperation<>(handler, false, false);
}
public static Operation appendOf(
final AppendHandlerSingle handler) {
return new OperationHandlerOperation<>(handler, false, false);
}
public static Operation appendOf(
final ParameterizedAppendHandler handler) {
return new OperationHandlerOperation<>(handler, false, true);
}
public static Operation appendOf(
final ParameterizedAppendHandlerSingle handler) {
return new OperationHandlerOperation<>(handler, false, true);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandler handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandlerSingle handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandlerAggregate handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandler handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandlerSingle handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandlerAggregate handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandler handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
false,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandlerSingle handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
false,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final UpdateHandlerAggregate handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
false,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandler handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
true,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandlerSingle handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
true,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedUpdateHandlerAggregate handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
true,
expectedVersion,
true);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final PojoUpdateHandler handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final PojoUpdateHandlerSingle handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedPojoUpdateHandler handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedPojoUpdateHandlerSingle handler) {
return updateOf(handler, false);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final PojoUpdateHandler handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
false,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final PojoUpdateHandlerSingle handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
false,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedPojoUpdateHandler handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
true,
expectedVersion,
true);
}
/**
* Creates an update operation, optionally requiring an existing aggregate.
*
* @param handler The handler to invoke with the current state to apply updates.
* @param autoCreate If true, the handler will be invoked with a null state in the case where no
* current aggregate exists. If false, the command will fail without the
* handler being invoked if the aggregate is not already present.
* @return An operation representing the supplied logic, with metadata.
*/
public static Operation updateOf(
final ParameterizedPojoUpdateHandlerSingle handler,
final boolean autoCreate) {
ExpectedVersion expectedVersion = autoCreate
? ExpectedVersion.any()
: ExpectedVersion.anyExisting();
return new OperationHandlerOperation<>(
handler,
true,
true,
expectedVersion,
true);
}
}