RegistryCodeSqlBuilder new interface
This commit is contained in:
parent
18a74ee7b8
commit
2c00b9194b
1 changed files with 26 additions and 12 deletions
|
|
@ -1,20 +1,34 @@
|
|||
package ru.spcex.platform.imdg.api.predicate.specific;
|
||||
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
public class RegistryCodeSqlBuilder {
|
||||
|
||||
private List<RegistryTradingParams> registryTradingParams;
|
||||
private String prefix = null;
|
||||
private String registryDesignation = "registryDesignation";
|
||||
private String registryInstrumentType = "registryInstrumentType";
|
||||
private String registryCapacity = "registryCapacity";
|
||||
private String registryUnit = "registryUnit";
|
||||
|
||||
public static RegistryCodeSqlBuilder getInstance(RegistryTradingParams... tradingParams) {
|
||||
return getInstance(false, tradingParams);
|
||||
}
|
||||
|
||||
public static RegistryCodeSqlBuilder getInstance(boolean directDB, RegistryTradingParams... tradingParams) {
|
||||
RegistryCodeSqlBuilder builder = new RegistryCodeSqlBuilder(Arrays.asList(tradingParams));
|
||||
if (directDB) {
|
||||
builder.registryDesignation = "registry_designation";
|
||||
builder.registryInstrumentType = "registry_instrument_type";
|
||||
builder.registryCapacity = "registry_capacity";
|
||||
builder.registryUnit = "registry_unit";
|
||||
}
|
||||
return new RegistryCodeSqlBuilder(Arrays.asList(tradingParams));
|
||||
}
|
||||
|
||||
|
|
@ -24,10 +38,10 @@ public class RegistryCodeSqlBuilder {
|
|||
|
||||
public String build() {
|
||||
List<StringBuilder> conditions = new ArrayList<>();
|
||||
String REGISTRY_DESIGNATION_FORMAT = "registryDesignation = '%s'";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FORMAT = "registryInstrumentType = '%s'";
|
||||
String REGISTRY_CAPACITY_FORMAT = "registryCapacity = '%s'";
|
||||
String REGISTRY_UNIT_FORMAT = "registryUnit = '%s'";
|
||||
String REGISTRY_DESIGNATION_FORMAT = registryDesignation + " = '%s'";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FORMAT = registryInstrumentType + " = '%s'";
|
||||
String REGISTRY_CAPACITY_FORMAT = registryCapacity + " = '%s'";
|
||||
String REGISTRY_UNIT_FORMAT = registryUnit + " = '%s'";
|
||||
if (prefix != null) {
|
||||
REGISTRY_DESIGNATION_FORMAT = "%s.%s".formatted(prefix, REGISTRY_DESIGNATION_FORMAT);
|
||||
REGISTRY_INSTRUMENT_TYPE_FORMAT = "%s.%s".formatted(prefix, REGISTRY_INSTRUMENT_TYPE_FORMAT);
|
||||
|
|
@ -75,10 +89,10 @@ public class RegistryCodeSqlBuilder {
|
|||
|
||||
public ImdgPredicate buildPredicate(ImdgPredicateBuilder pb) {
|
||||
List<ImdgPredicate> conditionsOr = new ArrayList<>();
|
||||
String REGISTRY_DESIGNATION_FIELD = "registryDesignation";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FIELD = "registryInstrumentType";
|
||||
String REGISTRY_CAPACITY_FIELD = "registryCapacity";
|
||||
String REGISTRY_UNIT_FIELD = "registryUnit";
|
||||
String REGISTRY_DESIGNATION_FIELD = registryDesignation;
|
||||
String REGISTRY_INSTRUMENT_TYPE_FIELD = registryInstrumentType;
|
||||
String REGISTRY_CAPACITY_FIELD = registryCapacity;
|
||||
String REGISTRY_UNIT_FIELD = registryUnit;
|
||||
if (prefix != null) {
|
||||
REGISTRY_DESIGNATION_FIELD = "%s.%s".formatted(prefix, REGISTRY_DESIGNATION_FIELD);
|
||||
REGISTRY_INSTRUMENT_TYPE_FIELD = "%s.%s".formatted(prefix, REGISTRY_INSTRUMENT_TYPE_FIELD);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue