本文整理汇总了Java中io.requery.util.function.Supplier类的典型用法代码示例。如果您正苦于以下问题:Java Supplier类的具体用法?Java Supplier怎么用?Java Supplier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Supplier类属于io.requery.util.function包,在下文中一共展示了Supplier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public <U> V initialize(EntityProxy<E> proxy,
Attribute<E, V> attribute,
Supplier<? extends Result<U>> query) {
Class<?> type = attribute.getClassType();
CollectionChanges<E, U> changes = new CollectionChanges<>(proxy, attribute);
Result<U> result = query == null ? null : query.get();
Collection<U> collection;
if (type == Set.class) {
Set<U> set = attribute.getOrderByAttribute() == null ?
new HashSet<U>() : new LinkedHashSet<U>();
if (result != null) {
result.collect(set);
}
collection = new ObservableSet<>(set, changes);
} else if (type == List.class) {
ArrayList<U> list = new ArrayList<>();
if (result != null) {
result.collect(list);
}
collection = new ObservableList<>(list, changes);
} else {
throw new IllegalStateException("Unsupported collection type " + type);
}
return attribute.getClassType().cast(collection);
}
示例2: write
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public void write(Output output, WhereElement query) {
QueryBuilder qb = output.builder();
ExistsElement<?> whereExists = query.getWhereExistsElement();
if (whereExists != null) {
qb.keyword(WHERE);
if (whereExists.isNotExists()) {
qb.keyword(NOT);
}
qb.keyword(EXISTS);
qb.openParenthesis();
Supplier<?> wrapper = whereExists.getQuery();
output.appendQuery((QueryWrapper) wrapper);
qb.closeParenthesis().space();
} else if (query.getWhereElements() != null && query.getWhereElements().size() > 0) {
qb.keyword(WHERE);
for (WhereConditionElement<?> w : query.getWhereElements()) {
output.appendConditional(w);
}
}
}
示例3: refreshAssociation
import io.requery.util.function.Supplier; //导入依赖的package包/类
private <V> void refreshAssociation(EntityProxy<E> proxy, Attribute<E, V> attribute) {
Supplier<? extends Result<S>> query = associativeQuery(proxy, attribute);
switch (attribute.getCardinality()) {
case ONE_TO_ONE:
case MANY_TO_ONE:
S value = query == null ? null : query.get().firstOrNull();
proxy.set(attribute, attribute.getClassType().cast(value), PropertyState.LOADED);
break;
case ONE_TO_MANY:
case MANY_TO_MANY:
Initializer<E, V> initializer = attribute.getInitializer();
if (initializer instanceof QueryInitializer) {
@SuppressWarnings("unchecked")
QueryInitializer<E, V> queryInitializer = (QueryInitializer<E, V>) initializer;
V result = queryInitializer.initialize(proxy, attribute, query);
proxy.set(attribute, result, PropertyState.LOADED);
}
break;
default:
throw new IllegalStateException();
}
}
示例4: order
import io.requery.util.function.Supplier; //导入依赖的package包/类
private <Q extends S> Supplier<? extends Result<Q>>
order(WhereAndOr<? extends Result<Q>> query, Supplier<Attribute> supplier) {
if (supplier != null) {
Attribute attribute = supplier.get();
if (attribute.getOrderByDirection() != null && attribute instanceof Functional) {
switch (attribute.getOrderByDirection()) {
case ASC:
query.orderBy(((Functional)attribute).asc());
break;
case DESC:
query.orderBy(((Functional)attribute).desc());
break;
}
} else {
query.orderBy((Expression)attribute);
}
}
return query;
}
示例5: createAnonymousSupplier
import io.requery.util.function.Supplier; //导入依赖的package包/类
static TypeSpec createAnonymousSupplier(TypeName type, CodeBlock block) {
return TypeSpec.anonymousClassBuilder("")
.addSuperinterface(ParameterizedTypeName.get(ClassName.get(Supplier.class), type))
.addMethod(overridePublicMethod("get")
.addCode(block)
.returns(type)
.build())
.build();
}
示例6: firstOr
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public E firstOr(Supplier<E> supplier) {
if (result != null) {
return result.firstOr(supplier);
}
return supplier.get();
}
示例7: from
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public QueryElement<E> from(Supplier<?>... subqueries) {
if (from == null) {
from = new LinkedHashSet<>();
}
for (Supplier supplier : subqueries) {
if (supplier instanceof Expression) {
from.add((Expression<?>) supplier);
} else {
throw new UnsupportedOperationException();
}
}
return this;
}
示例8: toCompletableFuture
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public CompletableFuture<E> toCompletableFuture(Executor executor) {
final java.util.function.Supplier<E> supplier =
new java.util.function.Supplier<E>() {
@Override
public E get() {
return BaseScalar.this.value();
}
};
return executor == null ?
CompletableFuture.supplyAsync(supplier) :
CompletableFuture.supplyAsync(supplier, executor);
}
示例9: toSupplier
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public Supplier<E> toSupplier() {
return new Supplier<E>() {
@Override
public E get() {
return value();
}
};
}
示例10: firstOr
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public E firstOr(Supplier<E> supplier) {
try (CloseableIterator<E> iterator = createIterator()) {
if (iterator.hasNext()) {
return iterator.next();
}
}
return supplier.get();
}
示例11: initialize
import io.requery.util.function.Supplier; //导入依赖的package包/类
@Override
public <U> V initialize(EntityProxy<E> proxy,
Attribute<E, V> attribute,
Supplier<? extends Result<U>> query) {
Class<?> type = attribute.getClassType();
CollectionChanges<E, U> changes = new CollectionChanges<>(proxy, attribute);
Result<U> result = query == null ? null : query.get();
Object collection;
if (Iterable.class.isAssignableFrom(type)) {
collection = new ModifiableResult<>(result, changes);
} else {
throw new IllegalStateException("Unsupported result type " + type);
}
return attribute.getClassType().cast(collection);
}
示例12: ImmutableConfiguration
import io.requery.util.function.Supplier; //导入依赖的package包/类
ImmutableConfiguration(ConnectionProvider connectionProvider,
Platform platform,
EntityModel model,
EntityCache cache,
Mapping mapping,
boolean useDefaultLogging,
int statementCacheSize,
int batchUpdateSize,
boolean quoteTableNames,
boolean quoteColumnNames,
Function<String, String> tableTransformer,
Function<String, String> columnTransformer,
Set<EntityStateListener> entityStateListeners,
Set<StatementListener> statementListeners,
TransactionMode transactionMode,
TransactionIsolation transactionIsolation,
Set<Supplier<TransactionListener>> transactionListenerFactories,
Executor writeExecutor) {
this.connectionProvider = connectionProvider;
this.platform = platform;
this.model = model;
this.cache = cache;
this.mapping = mapping;
this.useDefaultLogging = useDefaultLogging;
this.statementCacheSize = statementCacheSize;
this.batchUpdateSize = batchUpdateSize;
this.quoteTableNames = quoteTableNames;
this.quoteColumnNames = quoteColumnNames;
this.tableTransformer = tableTransformer;
this.columnTransformer = columnTransformer;
this.transactionMode = transactionMode;
this.entityStateListeners = Collections.unmodifiableSet(entityStateListeners);
this.statementListeners = Collections.unmodifiableSet(statementListeners);
this.transactionIsolation = transactionIsolation;
this.transactionListenerFactories = transactionListenerFactories;
this.writeExecutor = writeExecutor;
}
示例13: CompositeTransactionListener
import io.requery.util.function.Supplier; //导入依赖的package包/类
CompositeTransactionListener(Set<Supplier<TransactionListener>> listenerFactories) {
for (Supplier<TransactionListener> supplier : listenerFactories) {
TransactionListener listener = supplier.get();
if (listener != null) {
add(listener);
}
}
}
示例14: appendConditionValue
import io.requery.util.function.Supplier; //导入依赖的package包/类
private void appendConditionValue(Expression expression, Object value, boolean parameterize) {
if (value instanceof QueryAttribute) {
appendColumn((Expression<?>) value);
} else if (value instanceof Supplier && ((Supplier)value).get() instanceof QueryAttribute) {
appendColumn((Expression<?>) ((Supplier)value).get());
} else if (value instanceof NamedExpression) {
NamedExpression namedExpression = (NamedExpression) value;
qb.append(namedExpression.getName());
} else if (value instanceof Function) {
appendFunction((Function) value);
} else if (value instanceof Collection &&
expression.getExpressionType() == ExpressionType.ROW) {
qb.openParenthesis();
qb.commaSeparated((Collection) value);
qb.closeParenthesis();
} else {
if (parameterize) {
if (parameters != null) {
parameters.add(expression, value);
}
qb.append("?").space();
} else {
if (value instanceof CharSequence) {
qb.appendQuoted(value.toString()).space();
} else {
qb.append(value).space();
}
}
}
}
示例15: TransactionScope
import io.requery.util.function.Supplier; //导入依赖的package包/类
TransactionScope(Supplier<? extends EntityTransaction> supplier, Set<Type<?>> types) {
this.transaction = supplier.get();
if (!transaction.active()) {
transaction.begin();
enteredTransaction = true;
} else {
enteredTransaction = false;
}
if (types != null) {
transaction.addToTransaction(types);
}
}