Package org.ldaptive
Class AbstractOperationConnectionValidator<Q extends Request,S extends Result>
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.AbstractConnectionValidator
-
- org.ldaptive.AbstractOperationConnectionValidator<Q,S>
-
- Type Parameters:
Q
- type of requestS
- type of result
- All Implemented Interfaces:
Function<Connection,Boolean>
,ConnectionValidator
,Freezable
- Direct Known Subclasses:
CompareConnectionValidator
,SearchConnectionValidator
public abstract class AbstractOperationConnectionValidator<Q extends Request,S extends Result> extends AbstractConnectionValidator
Base class for validators that use an operation to perform validation. By default, validation is considered successful if the operation result contains any result code. Stricter validation can be configured by settingvalidResultCodes
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractOperationConnectionValidator.AbstractBuilder<Q extends Request,S extends Result,B,T extends AbstractOperationConnectionValidator<Q,S>>
Base class for operation validator builders.
-
Field Summary
Fields Modifier and Type Field Description private Q
request
Operation request.private ResultCode[]
validResultCodes
Valid result codes.-
Fields inherited from class org.ldaptive.AbstractConnectionValidator
DEFAULT_VALIDATE_PERIOD, DEFAULT_VALIDATE_TIMEOUT, logger
-
-
Constructor Summary
Constructors Constructor Description AbstractOperationConnectionValidator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
applyAsync(Connection conn, Consumer<Boolean> function)
Provides an asynchronous implementation ofFunction.apply(Object)
.Q
getRequest()
Returns the operation request.ResultCode[]
getValidResultCodes()
Returns the valid result codes.protected abstract OperationHandle<Q,S>
performOperation(Connection conn)
Perform the operation for this validator.void
setRequest(Q req)
Sets the operation request.void
setValidResultCodes(ResultCode... codes)
Sets the valid result codes.String
toString()
-
Methods inherited from class org.ldaptive.AbstractConnectionValidator
apply, applyAsync, getOnFailure, getOnSuccess, getTimeoutIsFailure, getValidatePeriod, getValidateTimeout, setOnFailure, setOnSuccess, setTimeoutIsFailure, setValidatePeriod, setValidateTimeout
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
validResultCodes
private ResultCode[] validResultCodes
Valid result codes.
-
-
Method Detail
-
getRequest
public Q getRequest()
Returns the operation request.- Returns:
- operation request
-
setRequest
public void setRequest(Q req)
Sets the operation request.- Parameters:
req
- operation request
-
getValidResultCodes
public ResultCode[] getValidResultCodes()
Returns the valid result codes.- Returns:
- valid result codes
-
setValidResultCodes
public void setValidResultCodes(ResultCode... codes)
Sets the valid result codes.- Parameters:
codes
- that represent a valid connection
-
performOperation
protected abstract OperationHandle<Q,S> performOperation(Connection conn)
Perform the operation for this validator.- Parameters:
conn
- to validate- Returns:
- operation handle
-
applyAsync
public void applyAsync(Connection conn, Consumer<Boolean> function)
Description copied from interface:ConnectionValidator
Provides an asynchronous implementation ofFunction.apply(Object)
. The supplied consumer will be invoked with the validation result.ConnectionValidator.getValidateTimeout()
must be enforced by the caller.- Parameters:
conn
- to validatefunction
- to consume the validation result
-
toString
public String toString()
- Overrides:
toString
in classAbstractConnectionValidator
-
-