/** * Initializes {@link org.lightmare.criteria.query.LambdaStream} implementation implementation for * JOIN expression * * @param parent * @param alias * @param joinType * @return L {@link org.lightmare.criteria.query.LambdaStream} implementation */ protected static <P, E, S extends LambdaStream<E, ? super S>> S initJoinQuery( AbstractQueryStream<P, ?, ?> parent, String alias, Class<E> joinType) { S joinQuery; if (alias == null) { joinQuery = ObjectUtils.applyAndCast(joinType, c -> new JdbcJoinProcessor<E, P>(parent, c)); } else { joinQuery = ObjectUtils.applyAndCast(joinType, c -> new JdbcJoinProcessor<E, P>(parent, alias, c)); } return joinQuery; }
/** * Gets appropriated {@link org.lightmare.criteria.tuples.QueryTuple} from serialized lambda cache * or analyzes appropriated lambda expression from compiled class * * @param method * @return {@link org.lightmare.criteria.tuples.QueryTuple} from cache */ private static QueryTuple getByLambda(Serializable method) { QueryTuple tuple; LambdaInfo lambda = LambdaReplacements.getReplacement(method); tuple = ObjectUtils.callOrInit(lambda, QueryCache::getQuery, LambdaUtils::resolvefromLambda); return tuple; }
/** * Initializes {@link org.lightmare.criteria.query.LambdaStream} implementation implementation for * sub query expressions * * @param parent * @param subType * @return L {@link org.lightmare.criteria.query.LambdaStream} implementation */ protected static <P, E, S extends QueryStream<E, ? super S>> S initSubQuery( AbstractQueryStream<P, ?, ?> parent, Class<E> subType) { S query = ObjectUtils.applyAndCast(subType, c -> new JdbcSubQueryStream<E, P>(parent, c)); return query; }
/** * Clones passed {@link org.lightmare.criteria.tuples.QueryTuple} without throwing an exception * * @param instance * @return {@link org.lightmare.criteria.tuples.QueryTuple} clone */ private static QueryTuple cloneTuple(QueryTuple instance) { return ObjectUtils.applyAndCast(instance, c -> ObjectUtils.applyQuietly(c, QueryTuple::clone)); }
/** * Gets appropriated {@link org.lightmare.criteria.tuples.QueryTuple} from cache or initializes * and caches new instance * * @param method * @return {@link org.lightmare.criteria.tuples.QueryTuple} from cache */ public static QueryTuple getOrInit(Serializable method) { return ObjectUtils.applyNonNull( method, LambdaUtils::getOrInitOriginal, LambdaUtils::cloneTuple); }
/** * Sets generic parameters to passed {@link org.lightmare.criteria.tuples.QueryTuple} by entity * {@link Class} instance if it is not <code>null</code> * * @param type * @param tuple */ public static void setGenericIfValid(Class<?> type, QueryTuple tuple) { ObjectUtils.nonNull(tuple, c -> setGenericType(type, c)); }
/** * Gets appropriated {@link org.lightmare.criteria.tuples.QueryTuple} from cache or initializes * and caches new instance * * @param method * @return {@link org.lightmare.criteria.tuples.QueryTuple} from cache */ private static QueryTuple getOrInitOriginal(Serializable method) { return ObjectUtils.callOrInit(method, LambdaCache::getByInstance, LambdaUtils::initAndCache); }