name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
querydsl_QueryBase_restrict_rdh
|
/**
* Defines both limit and offset of the query results,
* use {@link QueryModifiers#EMPTY} to apply no paging.
*
* @param modifiers
* query modifiers
* @return the current object
*/
public Q restrict(QueryModifiers modifiers) {
return queryMixin.restrict(modifiers);
}
| 3.26 |
querydsl_QueryBase_where_rdh
|
/**
* Add the given filter condition
*
* <p>Skips null arguments</p>
*
* @param o
* filter conditions to be added
* @return the current object
*/ public
Q where(Predicate o) {
return queryMixin.where(o);
}
| 3.26 |
querydsl_LiteralExpression_castToNum_rdh
|
/**
* Create a cast expression to the given numeric type
*
* @param <A>
* numeric type
* @param type
* numeric type
* @return cast expression
*/
public <A extends Number & Comparable<? super A>> NumberExpression<A> castToNum(Class<A> type) {
return Expressions.numberOperation(type, Ops.NUMCAST, mixin, ConstantImpl.create(type));
}
| 3.26 |
querydsl_JTSPolygonExpression_interiorRingN_rdh
|
/**
* Returns the N th interior ring for this Polygon as a LineString.
*
* @param idx
* one based index
* @return interior ring at index
*/
public JTSLineStringExpression<LineString> interiorRingN(int idx) {
return JTSGeometryExpressions.lineStringOperation(SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
}
| 3.26 |
querydsl_JTSPolygonExpression_numInteriorRing_rdh
|
/**
* Returns the number of interior rings in this Polygon.
*
* @return number of interior rings
*/
public NumberExpression<Integer> numInteriorRing() {
if (numInteriorRing == null) {
numInteriorRing = Expressions.numberOperation(Integer.class, SpatialOps.NUM_INTERIOR_RING, mixin);
}
return numInteriorRing;
}
| 3.26 |
querydsl_JTSLineStringExpression_pointN_rdh
|
/**
* Returns the specified Point N in this LineString.
*
* @param idx
* one based index
* @return point at index
*/
public JTSPointExpression<Point> pointN(int idx) {
return JTSGeometryExpressions.pointOperation(SpatialOps.POINTN, mixin, ConstantImpl.create(idx));
}
| 3.26 |
querydsl_JTSLineStringExpression_numPoints_rdh
|
/**
* The number of Points in this LineString.
*
* @return number of points
*/public NumberExpression<Integer> numPoints() {
if (numPoints == null) {
numPoints = Expressions.numberOperation(Integer.class, SpatialOps.NUM_POINTS, mixin);
}
return numPoints;
}
| 3.26 |
querydsl_MetaDataExporter_setNameSuffix_rdh
|
/**
* Override the name suffix for the classes (default: "")
*
* @param nameSuffix
* name suffix for querydsl-types (default: "")
*/
public void setNameSuffix(String nameSuffix) {
module.bind(CodegenModule.SUFFIX, nameSuffix);
}
| 3.26 |
querydsl_MetaDataExporter_m1_rdh
|
/**
* Set the source encoding
*
* @param sourceEncoding
*/
public void m1(String sourceEncoding) {
this.sourceEncoding = sourceEncoding;
}
/**
* Set whether schema names should be appended to the package name.
*
* <p><b>!!! Important !!!</b><i> {@link NamingStrategy#getPackage(String, SchemaAndTable)}
* will be invoked only if <code>schemaToPackage</code> is set to <code>true</code>.</i></p>
*
* @deprecated This flag will not be necessary in the future because the generated package name
can be controlled in method {@link NamingStrategy#getPackage(String, SchemaAndTable)}
| 3.26 |
querydsl_MetaDataExporter_setExportViews_rdh
|
/**
* Set whether views should be exported
*
* @param exportViews
*/
public void setExportViews(boolean exportViews) {
this.f2 = exportViews;
}
| 3.26 |
querydsl_MetaDataExporter_setPackageName_rdh
|
/**
* Set the package name
*
* @param packageName
* package name for sources
*/
public void setPackageName(String packageName) {
module.bind(SQLCodegenModule.PACKAGE_NAME, packageName);
}
| 3.26 |
querydsl_MetaDataExporter_setBeanPackageName_rdh
|
/**
* Override the bean package name (default: packageName)
*
* @param beanPackageName
* package name for bean sources
*/
public void setBeanPackageName(@Nullable
String beanPackageName) {
this.beanPackageName = beanPackageName;
}
| 3.26 |
querydsl_MetaDataExporter_setBeanSerializerClass_rdh
|
/**
* Set the Bean serializer class to create bean types as well
*
* @param beanSerializerClass
* serializer for JavaBeans (default: null)
*/
public void setBeanSerializerClass(Class<? extends Serializer> beanSerializerClass) {
module.bind(SQLCodegenModule.BEAN_SERIALIZER, beanSerializerClass);
}
| 3.26 |
querydsl_MetaDataExporter_setColumnAnnotations_rdh
|
/**
* Set whether column annotations should be created
*
* @param columnAnnotations
*/
public void setColumnAnnotations(boolean columnAnnotations) {
this.columnAnnotations = columnAnnotations;
}
| 3.26 |
querydsl_MetaDataExporter_setCreateScalaSources_rdh
|
/**
* Set true to create Scala sources instead of Java sources
*
* @param createScalaSources
* whether to create Scala sources (default: false)
*/
public void setCreateScalaSources(boolean createScalaSources) {
this.createScalaSources = createScalaSources;
}
| 3.26 |
querydsl_MetaDataExporter_setTypeMappings_rdh
|
/**
* Set the type mappings to use
*
* @param typeMappings
*/
public void setTypeMappings(TypeMappings typeMappings) {
module.bind(TypeMappings.class, typeMappings);
}
| 3.26 |
querydsl_MetaDataExporter_setNamingStrategy_rdh
|
/**
* Override the NamingStrategy (default: new DefaultNamingStrategy())
*
* @param namingStrategy
* naming strategy to override (default: new DefaultNamingStrategy())
*/ public void setNamingStrategy(NamingStrategy namingStrategy) {
module.bind(NamingStrategy.class, namingStrategy);
}
| 3.26 |
querydsl_MetaDataExporter_export_rdh
|
/**
* Export the tables based on the given database metadata
*
* @param md
* database metadata
* @throws SQLException
*/
public void export(DatabaseMetaData md) throws SQLException {if (beanPackageName == null) {
beanPackageName = module.getPackageName();
}
if (beansTargetFolder == null) {
beansTargetFolder = targetFolder;
}
module.bind(SQLCodegenModule.BEAN_PACKAGE_NAME, beanPackageName);
module.loadExtensions();
classes.clear();
typeMappings = module.get(TypeMappings.class);
queryTypeFactory = module.get(QueryTypeFactory.class);
serializer = module.get(Serializer.class);
beanSerializer = module.get(Serializer.class, SQLCodegenModule.BEAN_SERIALIZER);
namingStrategy = module.get(NamingStrategy.class);configuration = module.get(Configuration.class);
SQLTemplates templates = sqlTemplatesRegistry.getTemplates(md);
if (templates != null) {
configuration.setTemplates(templates);
} else {
f0.info("Found no specific dialect for " + md.getDatabaseProductName());
}
if (beanSerializer == null) {
keyDataFactory = new KeyDataFactory(namingStrategy, module.getPackageName(), module.getPrefix(), module.getSuffix(),
f1);
} else {
keyDataFactory = new KeyDataFactory(namingStrategy, beanPackageName, module.getBeanPrefix(), module.getBeanSuffix(), f1);
}
String[] typesArray = null;
if ((tableTypesToExport != null) && (!tableTypesToExport.isEmpty())) {
List<String> types = new ArrayList<String>();
for (String tableType : tableTypesToExport.split(",")) {
types.add(tableType.trim());
}
typesArray = types.toArray(new String[0]);
} else if (!exportAll) {
List<String> types = new ArrayList<String>(2);
if (exportTables) {
types.add("TABLE");
}
if (f2) {
types.add("VIEW");
}typesArray = types.toArray(new String[0]); }
List<String> catalogs
= patternAsList(catalogPattern);
List<String> schemas = patternAsList(schemaPattern);
List<String> tables = patternAsList(tableNamePattern);
for (String v17 : catalogs) {
v17 = trimIfNonNull(v17);
for (String schema : schemas)
{
schema = trimIfNonNull(schema);
for (String table : tables)
{
table = trimIfNonNull(table);
handleTables(md, v17, schema, table, typesArray);
}
}
}
}
| 3.26 |
querydsl_MetaDataExporter_setSchemaPattern_rdh
|
/**
* Set the schema pattern filter to be used
*
* @param schemaPattern
* a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a schema;
* {@code null} means that the schema name should not be used to narrow
* the search (default: null)
*/
public void setSchemaPattern(@Nullable String schemaPattern) {
this.schemaPattern = schemaPattern;
}
| 3.26 |
querydsl_MetaDataExporter_setExportDirectForeignKeys_rdh
|
/**
* Set whether direct foreign keys should be exported
*
* @param exportDirectForeignKeys
*/public void setExportDirectForeignKeys(boolean exportDirectForeignKeys) {
this.exportDirectForeignKeys = exportDirectForeignKeys;
}
| 3.26 |
querydsl_MetaDataExporter_setBeanSuffix_rdh
|
/**
* Override the bean suffix for the classes (default: "")
*
* @param beanSuffix
* bean suffix for bean-types (default: "")
*/
public void setBeanSuffix(String beanSuffix) {
module.bind(SQLCodegenModule.BEAN_SUFFIX, beanSuffix);
}
| 3.26 |
querydsl_MetaDataExporter_setExportAll_rdh
|
/**
* Set whether all table types should be exported
*
* @param exportAll
*/
public void setExportAll(boolean exportAll) {
this.exportAll = exportAll;
}
| 3.26 |
querydsl_MetaDataExporter_patternAsList_rdh
|
/**
* Splits the input on ',' if non-null and a ',' is present.
* Returns a singletonList of null if null
*/
private List<String> patternAsList(@Nullable
String input) {
if ((input != null) && input.contains(",")) {
return Arrays.asList(input.split(","));
} else {
return Collections.singletonList(input);
}
}
| 3.26 |
querydsl_MetaDataExporter_setNamePrefix_rdh
|
/**
* Override the name prefix for the classes (default: Q)
*
* @param namePrefix
* name prefix for querydsl-types (default: Q)
*/
public void setNamePrefix(String namePrefix) {
module.bind(CodegenModule.PREFIX, namePrefix);
}
| 3.26 |
querydsl_MetaDataExporter_setGeneratedAnnotationClass_rdh
|
/**
* Set the fully qualified class name of the "generated" annotation added ot the generated sources
*
* @param generatedAnnotationClass
* the fully qualified class name of the <em>Single-Element Annotation</em> (with {@code String} element) to be used on
* the generated sources, or {@code null} (defaulting to {@code javax.annotation.Generated} or
* {@code javax.annotation.processing.Generated} depending on the java version).
* @see <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.7.3">Single-Element Annotation</a>
*/
public void setGeneratedAnnotationClass(@Nullable
String generatedAnnotationClass) {
module.bindInstance(CodegenModule.GENERATED_ANNOTATION_CLASS, GeneratedAnnotationResolver.resolve(generatedAnnotationClass));
}
| 3.26 |
querydsl_MetaDataExporter_m2_rdh
|
/**
* Set the java imports
*
* @param imports
* java imports array
*/
public void m2(String[] imports) {
module.bind(CodegenModule.IMPORTS, new HashSet<String>(Arrays.asList(imports)));
}
| 3.26 |
querydsl_MetaDataExporter_setColumnComparatorClass_rdh
|
/**
* Set the column comparator class
*
* @param columnComparatorClass
*/
public void setColumnComparatorClass(Class<? extends Comparator<Property>> columnComparatorClass) {
module.bind(SQLCodegenModule.COLUMN_COMPARATOR, columnComparatorClass);
}
| 3.26 |
querydsl_MetaDataExporter_setBeansTargetFolder_rdh
|
/**
* Set the target folder for beans
*
* <p>defaults to the targetFolder value</p>
*
* @param targetFolder
* target source folder to create the bean sources into
*/
public void setBeansTargetFolder(File targetFolder) {
this.beansTargetFolder = targetFolder;
}
| 3.26 |
querydsl_MetaDataExporter_setExportTables_rdh
|
/**
* Set whether tables should be exported
*
* @param exportTables
*/
public void setExportTables(boolean exportTables) {
this.exportTables = exportTables;
}
| 3.26 |
querydsl_MetaDataExporter_setExportInverseForeignKeys_rdh
|
/**
* Set whether inverse foreign keys should be exported
*
* @param exportInverseForeignKeys
*/public void setExportInverseForeignKeys(boolean exportInverseForeignKeys) {
this.exportInverseForeignKeys = exportInverseForeignKeys;
}
| 3.26 |
querydsl_MetaDataExporter_setTableNamePattern_rdh
|
/**
* Set the table name pattern filter to be used
*
* @param tableNamePattern
* a table name pattern; must match the
* table name as it is stored in the database (default: null)
*/
public void setTableNamePattern(@Nullable
String tableNamePattern) {
this.tableNamePattern = tableNamePattern;
}
| 3.26 |
querydsl_MetaDataExporter_setExportForeignKeys_rdh
|
/**
* Set whether foreign keys should be exported
*
* @param exportForeignKeys
*/
public void setExportForeignKeys(boolean exportForeignKeys) {
this.exportForeignKeys = exportForeignKeys;}
| 3.26 |
querydsl_MetaDataExporter_setConfiguration_rdh
|
/**
* Override the configuration
*
* @param configuration
* override configuration for custom type mappings etc
*/
public void setConfiguration(Configuration configuration) {
module.bind(Configuration.class, configuration);
}
| 3.26 |
querydsl_MetaDataExporter_setBeanSerializer_rdh
|
/**
* Set the Bean serializer to create bean types as well
*
* @param beanSerializer
* serializer for JavaBeans (default: null)
*/
public void setBeanSerializer(@Nullable
Serializer beanSerializer) {
module.bind(SQLCodegenModule.BEAN_SERIALIZER, beanSerializer);
}
| 3.26 |
querydsl_MetaDataExporter_setInnerClassesForKeys_rdh
|
/**
* Set whether inner classes should be created for keys
*
* @param innerClassesForKeys
*/public void setInnerClassesForKeys(boolean innerClassesForKeys) {
module.bind(SQLCodegenModule.INNER_CLASSES_FOR_KEYS, innerClassesForKeys);
}
| 3.26 |
querydsl_MetaDataExporter_setBeanPrefix_rdh
|
/**
* Override the bean prefix for the classes (default: "")
*
* @param beanPrefix
* bean prefix for bean-types (default: "")
*/
public void setBeanPrefix(String beanPrefix) {
module.bind(SQLCodegenModule.BEAN_PREFIX, beanPrefix);
}
| 3.26 |
querydsl_Fetchable_stream_rdh
|
/**
* Get the projection as a typed closeable Stream.
*
* @return closeable stream
*/
default Stream<T> stream() {
final CloseableIterator<T> iterator = iterate();
final Spliterator<T> spliterator =
Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED);
return StreamSupport.stream(spliterator, false).onClose(iterator::close);
}
| 3.26 |
querydsl_SerializerBase_serializeConstant_rdh
|
/**
* Serialize the constant as parameter to the query. The default implementation writes the
* label name for the constants. Some dialects may replace this by indexed based or
* positional parameterization.
* Dialects may also use this to prefix the parameter with for example ":" or "?".
*
* @param parameterIndex
* index at which this constant occurs in {@link #getConstants()}
* @param constantLabel
* label under which this constant occurs in {@link #getConstantToLabel()}
*/
protected void serializeConstant(int parameterIndex, String constantLabel) {
append(constantLabel);
}
| 3.26 |
querydsl_SerializerBase_getConstantLabel_rdh
|
/**
* Generate a constant value under which to register a new constant in {@link #getConstantToLabel()}.
*
* @param value
* the constant value or parameter to create a constant for
* @return the generated label
*/
@NotNull
protected String getConstantLabel(Object value) {
return constantPrefix + (getConstantToLabel().size() + 1);
}
| 3.26 |
querydsl_LuceneSerializer_m3_rdh
|
/**
* template method
*
* @param leftHandSide
* left hand side
* @param rightHandSide
* right hand side
* @return results
*/
protected String[] m3(Path<?> leftHandSide, Object rightHandSide) {
String str = rightHandSide.toString();
if (lowerCase) {
str = str.toLowerCase();
}if (splitTerms) {
if (str.equals("")) {
return new String[]{ str };
} else {
return str.split("\\s+");
}
} else {
return new String[]{ str };
}
}
| 3.26 |
querydsl_LuceneSerializer_convert_rdh
|
/**
* template method
*
* @param leftHandSide
* left hand side
* @param rightHandSide
* right hand side
* @return results
*/
protected String[] convert(Path<?> leftHandSide, Expression<?> rightHandSide, QueryMetadata metadata) {
if (rightHandSide instanceof Operation) {
Operation<?> operation = ((Operation<?>) (rightHandSide));
if (operation.getOperator() == LuceneOps.PHRASE) {
return operation.getArg(0).toString().split("\\s+");
} else if (operation.getOperator() == LuceneOps.TERM) {
return new String[]{ operation.getArg(0).toString() };
} else {
throw new IllegalArgumentException(rightHandSide.toString());
}
} else if (rightHandSide instanceof ParamExpression<?>) {
Object
value = metadata.getParams().get(rightHandSide);if (value == null) {
throw
new ParamNotSetException(((ParamExpression<?>) (rightHandSide)));}
return convert(leftHandSide, value);
} else if (rightHandSide instanceof Constant<?>)
{
return convert(leftHandSide, ((Constant<?>) (rightHandSide)).getConstant());
} else {
throw new IllegalArgumentException(rightHandSide.toString());
}
}
| 3.26 |
querydsl_SQLSerializer_getIdentifierColumns_rdh
|
/**
* Return a list of expressions that can be used to uniquely define the query sources
*
* @param joins
* @return identifier columns
*/
@SuppressWarnings("unchecked")
protected List<Expression<?>> getIdentifierColumns(List<JoinExpression> joins, boolean alias) {
if (joins.size() == 1) { JoinExpression v2 = joins.get(0);
if (v2.getTarget() instanceof RelationalPath) {
return ((RelationalPath) (v2.getTarget())).getColumns();
} else {
return Collections.emptyList();}
} else {
List<Expression<?>> rv = new ArrayList<>();
int counter = 0;
for (JoinExpression join : joins) {
if
(join.getTarget() instanceof RelationalPath) {
RelationalPath path = ((RelationalPath) (join.getTarget()));
List<Expression<?>> columns;
if (path.getPrimaryKey() != null) {
columns = path.getPrimaryKey().getLocalColumns();
} else {
columns = path.getColumns();
}
if (alias) {
for (Expression<?> column : columns) {
rv.add(ExpressionUtils.as(column, "col" + (++counter)));
}
} else {
rv.addAll(columns);
}
} else {
// not able to provide a distinct list of columns
return Collections.emptyList();
}
}
return rv;
}
}
| 3.26 |
querydsl_CaseBuilder_then_rdh
|
// Time
public <T extends Comparable> Cases<T, TimeExpression<T>> then(TimeExpression<T> expr) {
return thenTime(expr);
}
| 3.26 |
querydsl_Coalesce_as_rdh
|
/**
* Create an alias for the expression
*
* @return this as alias
*/
public DslExpression<T> as(String alias) {
return as(ExpressionUtils.path(getType(), alias));
}
| 3.26 |
querydsl_AbstractJDOQuery_m1_rdh
|
/**
* Set the maximum fetch depth when fetching.
* A value of 0 has no meaning and will throw a {@link JDOUserException}.
* A value of -1 means that no limit is placed on fetching.
* A positive integer will result in that number of references from the
* initial object to be fetched.
*
* @param depth
* fetch depth
* @return the current object
*/@Override
public Q m1(int depth) {
maxFetchDepth =
depth;
return queryMixin.getSelf();
}
| 3.26 |
querydsl_AbstractJDOQuery_close_rdh
|
/**
* Close the query and related resources
*/
@Override
public void close()
{
for (Query query : queries) {
query.closeAll();
}
}
| 3.26 |
querydsl_AbstractJDOQuery_addFetchGroup_rdh
|
/**
* Add the fetch group to the set of active fetch groups.
*
* @param fetchGroupName
* fetch group name
* @return the current object
*/
@Override
public Q
addFetchGroup(String fetchGroupName) {
fetchGroups.add(fetchGroupName);
return queryMixin.getSelf();
}
| 3.26 |
querydsl_CollQuery_clone_rdh
|
/**
* Clone the state of this query to a new CollQuery instance
*/
@Override
public CollQuery<T> clone() {
return new
CollQuery<T>(queryMixin.getMetadata().clone(), getQueryEngine());
}
| 3.26 |
querydsl_AliasFactory_createProxy_rdh
|
/**
* Create a proxy instance for the given class and path
*
* @param <A>
* @param cl
* type of the proxy
* @param path
* underlying expression
* @return proxy instance
*/
@SuppressWarnings("unchecked")protected <A> A createProxy(Class<A> cl, Expression<?> path) {
Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(AliasFactory.class.getClassLoader());
if (cl.isInterface()) {
enhancer.setInterfaces(new Class<?>[]{ cl, ManagedObject.class });
} else {
enhancer.setSuperclass(cl);
enhancer.setInterfaces(new Class<?>[]{ ManagedObject.class });
}
// creates one handler per proxy
MethodInterceptor handler = new PropertyAccessInvocationHandler(path, this, pathFactory,
typeSystem);
enhancer.setCallback(handler);return ((A) (enhancer.create()));
}
| 3.26 |
querydsl_AliasFactory_createAliasForExpr_rdh
|
/**
* Create an alias instance for the given class and Expression
*
* @param <A>
* @param cl
* type for alias
* @param expr
* underlying expression
* @return alias instance
*/
@SuppressWarnings("unchecked")
public <A> A createAliasForExpr(Class<A> cl, Expression<?
extends A> expr) {
try {
final Map<Expression<?>, ManagedObject> expressionCache = proxyCache.computeIfAbsent(cl, a -> Collections.synchronizedMap(new WeakHashMap<>()));
return ((A) (expressionCache.computeIfAbsent(expr, e -> ((ManagedObject) (createProxy(cl, expr))))));
} catch (ClassCastException e) {
throw new QueryException(e);
}
}
| 3.26 |
querydsl_AliasFactory_getCurrent_rdh
|
/**
* Get the current thread bound expression without resetting it
*
* @param <A>
* @return expression
*/
@SuppressWarnings("unchecked")
@Nullable
public <A extends Expression<?>> A getCurrent() {
return ((A) (current.get()));
}
| 3.26 |
querydsl_AliasFactory_getCurrentAndReset_rdh
|
/**
* Get the current thread bound expression and reset it
*
* @param <A>
* @return expression
*/
@Nullable
public <A extends Expression<?>> A getCurrentAndReset() {
A rv = this.getCurrent();
reset();return rv;
}
| 3.26 |
querydsl_AliasFactory_createAliasForProperty_rdh
|
/**
* Create an alias instance for the given class, parent and path
*
* @param <A>
* @param cl
* type for alias
* @param path
* underlying expression
* @return alias instance
*/
public <A> A createAliasForProperty(Class<A> cl, Expression<?> path) {
return createProxy(cl, path);
}
| 3.26 |
querydsl_AliasFactory_setCurrent_rdh
|
/**
* Set the thread bound expression to the given value
*
* @param expr
* expression to be set to current
*/
public void setCurrent(Expression<?> expr) {
current.set(expr);
}
| 3.26 |
querydsl_AliasFactory_createAliasForVariable_rdh
|
/**
* Create an alias instance for the given class and variable name
*
* @param <A>
* @param cl
* type for alias
* @param var
* variable name for the underlying expression
* @return alias instance
*/
public <A> A createAliasForVariable(Class<A> cl, String var) {
final Path<A> expr = pathFactory.createEntityPath(cl, PathMetadataFactory.forVariable(var));
return createAliasForExpr(cl, expr);
}
| 3.26 |
querydsl_PropertyAccessInvocationHandler_intercept_rdh
|
// CHECKSTYLE:OFF
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
// CHECKSTYLE:ON
Object rv = null;
MethodType methodType = MethodType.get(method);if (methodType == MethodType.GETTER) {
String ptyName = propertyNameForGetter(method);
Class<?> ptyClass =
method.getReturnType();
Type genericType = method.getGenericReturnType();
if (propToObj.containsKey(ptyName)) {
rv
= propToObj.get(ptyName);
} else {
PathMetadata
pm = createPropertyPath(((Path<?>) (hostExpression)), ptyName);
rv = newInstance(ptyClass, genericType, proxy, ptyName, pm);
}
aliasFactory.setCurrent(propToExpr.get(ptyName));
} else if (methodType == MethodType.SCALA_GETTER) {
String ptyName = method.getName();Class<?> ptyClass = method.getReturnType();
Type genericType = method.getGenericReturnType();
if (propToObj.containsKey(ptyName)) {
rv = propToObj.get(ptyName);
} else {
PathMetadata pm = createPropertyPath(((Path<?>) (hostExpression)), ptyName);
rv = newInstance(ptyClass, genericType, proxy, ptyName, pm);
}
aliasFactory.setCurrent(propToExpr.get(ptyName));
} else if
((methodType == MethodType.LIST_ACCESS) || (methodType == MethodType.SCALA_LIST_ACCESS))
{
// TODO : manage cases where the argument is based on a property invocation
Object propKey = Arrays.asList(MethodType.LIST_ACCESS, args[0]);
if
(propToObj.containsKey(propKey)) {
rv = propToObj.get(propKey);
} else {
PathMetadata pm = createListAccessPath(((Path<?>) (hostExpression)), ((Integer) (args[0])));
Class<?> elementType = ((ParameterizedExpression<?>) (hostExpression)).getParameter(0);
rv = newInstance(elementType, elementType, proxy, propKey, pm);
}
aliasFactory.setCurrent(propToExpr.get(propKey));
} else if ((methodType == MethodType.MAP_ACCESS) || (methodType == MethodType.SCALA_MAP_ACCESS)) {
Object propKey = Arrays.asList(MethodType.MAP_ACCESS, args[0]);
if (propToObj.containsKey(propKey)) {
rv = propToObj.get(propKey);
} else {
PathMetadata pm = createMapAccessPath(((Path<?>) (hostExpression)), args[0]);
Class<?> valueType = ((ParameterizedExpression<?>) (hostExpression)).getParameter(1);
rv = newInstance(valueType, valueType, proxy,
propKey, pm);
}
aliasFactory.setCurrent(propToExpr.get(propKey));
} else if (methodType == MethodType.TO_STRING)
{rv
= hostExpression.toString();
} else if (methodType == MethodType.HASH_CODE) {
rv = hostExpression.hashCode();
} else if (methodType == MethodType.GET_MAPPED_PATH) {
rv =
hostExpression;} else {
throw new IllegalArgumentException(((("Invocation of " + method.getName()) + " with types ") + Arrays.asList(method.getParameterTypes())) + " not supported");
}
return rv;
}
@SuppressWarnings({ "unchecked"
}
| 3.26 |
querydsl_BeanMap_reinitialise_rdh
|
// Implementation methods
// -------------------------------------------------------------------------
/**
* Reinitializes this bean. Called during {@link #setBean(Object)}.
* Does introspection to find properties.
*/
protected void reinitialise() {
readMethods.clear();
writeMethods.clear();types.clear();
initialise();
}
| 3.26 |
querydsl_BeanMap_get_rdh
|
/**
* Returns the value of the bean's property with the given name.
* <p>
* The given name must be a {@code String} and must not be
* null; otherwise, this method returns {@code null}.
* If the bean defines a property with the given name, the value of
* that property is returned. Otherwise, {@code null} is
* returned.
* <p>
* Write-only properties will not be matched as the test operates against
* property read methods.
*
* @param name
* the name of the property whose value to return
* @return the value of the property with that name
*/
public Object get(String name) {
if (bean != null) {
Method method = getReadMethod(name);
if (method != null) {
try {
return method.invoke(bean, NULL_ARGUMENTS);
} catch (IllegalAccessException | NullPointerException | InvocationTargetException | IllegalArgumentException e) {
}
}
}
return null;
}
| 3.26 |
querydsl_BeanMap_firePropertyChange_rdh
|
/**
* Called during a successful {@link #put(Object,Object)} operation.
* Default implementation does nothing. Override to be notified of
* property changes in the bean caused by this map.
*
* @param key
* the name of the property that changed
* @param oldValue
* the old value for that property
* @param newValue
* the new value for that property
*/
protected void firePropertyChange(String key, Object oldValue, Object newValue) {
}
| 3.26 |
querydsl_BeanMap_convertType_rdh
|
/**
* Converts the given value to the given type. First, reflection is
* is used to find a public constructor declared by the given class
* that takes one argument, which must be the precise type of the
* given value. If such a constructor is found, a new object is
* created by passing the given value to that constructor, and the
* newly constructed object is returned.<P>
* <p>
* If no such constructor exists, and the given type is a primitive
* type, then the given value is converted to a string using its
* {@link Object#toString() toString()} method, and that string is
* parsed into the correct primitive type using, for instance,
* {@link Integer#valueOf(String)} to convert the string into an
* {@code int}.<P>
* <p>
* If no special constructor exists and the given type is not a
* primitive type, this method returns the original value.
*
* @param newType
* the type to convert the value to
* @param value
* the value to convert
* @return the converted value
* @throws NumberFormatException
* if newType is a primitive type, and
* the string representation of the given value cannot be converted
* to that type
* @throws InstantiationException
* if the constructor found with
* reflection raises it
* @throws InvocationTargetException
* if the constructor found with
* reflection raises it
* @throws IllegalAccessException
* never
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Object convertType(Class<?> newType, Object value) throws InstantiationException, IllegalAccessException, InvocationTargetException {
// try call constructor
Class<?>[] types
= new Class<?>[]{ value.getClass() };
try {
Constructor<?> v33 = newType.getConstructor(types);
Object[] arguments
= new Object[]{ value };
return v33.newInstance(arguments);} catch (NoSuchMethodException e) {
// try using the transformers
Function function = getTypeFunction(newType);
if (function != null) {
return function.apply(value);
}
return value;
}
}
| 3.26 |
querydsl_BeanMap_entryIterator_rdh
|
/**
* Convenience method for getting an iterator over the entries.
*
* @return an iterator over the entries
*/
public Iterator<Entry<String,
Object>> entryIterator() {
final Iterator<String> iter = keyIterator();
return new Iterator<Entry<String, Object>>() {
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public Entry<String, Object> next() {
String key = iter.next();
Object value = get(key);
return new MyMapEntry(BeanMap.this, key, value);
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove() not supported for BeanMap");
}
};
}
| 3.26 |
querydsl_BeanMap_entrySet_rdh
|
/**
* Gets a Set of MapEntry objects that are the mappings for this BeanMap.
* <p>
* Each MapEntry can be set but not removed.
*
* @return the unmodifiable set of mappings
*/
@Overridepublic Set<Entry<String, Object>> entrySet() {
return new AbstractSet<Entry<String, Object>>() {
@Override
public Iterator<Entry<String, Object>> iterator() {
return entryIterator();
}
@Override
public int size() {
return
BeanMap.this.readMethods.size();
}
};
}
| 3.26 |
querydsl_BeanMap_valueIterator_rdh
|
/**
* Convenience method for getting an iterator over the values.
*
* @return an iterator over the values
*/
public Iterator<Object> valueIterator() {
final Iterator<String> iter = keyIterator();
return new Iterator<Object>() {
@Override
public boolean hasNext()
{
return iter.hasNext();
}
@Override
public Object next() {
Object key = iter.next();
return get(key);
}
@Override
public void remove() {
throw new
UnsupportedOperationException("remove() not supported for BeanMap");
}
};
}
| 3.26 |
querydsl_BeanMap_clone_rdh
|
/**
* Clone this bean map using the following process:
* <p>
* <ul>
* <li>If there is no underlying bean, return a cloned BeanMap without a
* bean.
* <p>
* <li>Since there is an underlying bean, try to instantiate a new bean of
* the same type using Class.newInstance().
* <p>
* <li>If the instantiation fails, throw a CloneNotSupportedException
* <p>
* <li>Clone the bean map and set the newly instantiated bean as the
* underlying bean for the bean map.
* <p>
* <li>Copy each property that is both readable and writable from the
* existing object to a cloned bean map.
* <p>
* <li>If anything fails along the way, throw a
* CloneNotSupportedException.
* <p>
* </ul>
*/
@Override
public Object clone() throws CloneNotSupportedException {
BeanMap
newMap = ((BeanMap) (super.clone()));
if (bean == null) {
// no bean, just an empty bean map at the moment. return a newly
// cloned and empty bean map.
return newMap;
}
Object newBean = null;
Class<?> beanClass
= null;
try {
beanClass = bean.getClass();
newBean = beanClass.newInstance();
} catch (Exception e) {
// unable to instantiate
throw new CloneNotSupportedException((("Unable to instantiate the underlying bean \"" + beanClass.getName()) + "\": ") + e);
}
try {
newMap.setBean(newBean);
} catch (Exception exception) {
throw new CloneNotSupportedException("Unable to set bean in the cloned bean map: " + exception);
}
try {
// copy only properties that are readable and writable. If its
// not readable, we can't get the value from the old map. If
// its not writable, we can't write a value into the new map.
for (String key : readMethods.keySet()) {
if (getWriteMethod(key) != null) {
newMap.put(key, get(key));
}
}
}
catch (Exception exception) {
throw new CloneNotSupportedException("Unable to copy bean values to cloned bean map: " + exception);
}
return newMap;
}
| 3.26 |
querydsl_BeanMap_setValue_rdh
|
/**
* Sets the value.
*
* @param value
* the new value for the entry
* @return the old value for the entry
*/
@Override
public Object setValue(Object value) {
String key = getKey();
Object oldValue = owner.get(key);
owner.put(key, value);
Object newValue = owner.get(key);
this.value = newValue;
return oldValue;
}
| 3.26 |
querydsl_BeanMap_setBean_rdh
|
/**
* Sets the bean to be operated on by this map. The given value may
* be null, in which case this map will be empty.
*
* @param newBean
* the new bean to operate on
*/
public void setBean(Object newBean) {
bean = newBean;
reinitialise();
}
| 3.26 |
querydsl_BeanMap_put_rdh
|
/**
* Sets the bean property with the given name to the given value.
*
* @param name
* the name of the property to set
* @param value
* the value to set that property to
* @return the previous value of that property
*/
@Override
public Object put(String name, Object value) {
if (bean != null) {
Object oldValue = get(name);
Method method = getWriteMethod(name);
if (method == null)
{
throw new IllegalArgumentException((("The bean of type: " + bean.getClass().getName()) + " has no property called: ") + name); }
try {
Object[] arguments = createWriteMethodArguments(method, value);
method.invoke(bean, arguments);
Object newValue = get(name);
firePropertyChange(name, oldValue, newValue);
} catch (InvocationTargetException | IllegalAccessException e) {
throw new IllegalArgumentException(e.getMessage());
}
return oldValue;
}
return null;
}
| 3.26 |
querydsl_BeanMap_getBean_rdh
|
// Properties
// -------------------------------------------------------------------------
/**
* Returns the bean currently being operated on. The return value may
* be null if this map is empty.
*
* @return the bean being operated on by this map
*/
public Object getBean() {
return bean;
}
| 3.26 |
querydsl_BeanMap_getWriteMethod_rdh
|
/**
* Returns the mutator for the property with the given name.
*
* @param name
* the name of the property
* @return the mutator method for the property, or null
*/
public Method getWriteMethod(String name) {
return writeMethods.get(name);
}
| 3.26 |
querydsl_BeanMap_getReadMethod_rdh
|
/**
* Returns the accessor for the property with the given name.
*
* @param name
* the name of the property
* @return the accessor method for the property, or null
*/
public Method getReadMethod(String name) {
return readMethods.get(name);
}
| 3.26 |
querydsl_BeanMap_putAllWriteable_rdh
|
/**
* Puts all of the writable properties from the given BeanMap into this
* BeanMap. Read-only and Write-only properties will be ignored.
*
* @param map
* the BeanMap whose properties to put
*/
public void putAllWriteable(BeanMap
map) {
for (String key : map.readMethods.keySet()) { if (getWriteMethod(key) != null) {
this.put(key, map.get(key));
}
}
}
/**
* This method reinitializes the bean map to have default values for the
* bean's properties. This is accomplished by constructing a new instance
* of the bean which the map uses as its underlying data source. This
* behavior for {@code Map#clear()}
| 3.26 |
querydsl_BeanMap_toString_rdh
|
// Map interface
// -------------------------------------------------------------------------
@Override
public String toString() {
return ("BeanMap<" + bean) + ">";
}
| 3.26 |
querydsl_MongodbExpressions_geoIntersects_rdh
|
/**
* Finds documents whose geospatial data intersects
*
* @param expr
* location
* @param latVal
* latitude
* @param longVal
* longitude
* @return predicate
*/
public static BooleanExpression geoIntersects(Expression<Double[]> expr, double latVal, double longVal) { return Expressions.booleanOperation(MongodbOps.GEO_INTERSECTS, expr, ConstantImpl.create(new Double[]{ latVal, longVal }));
}
| 3.26 |
querydsl_MongodbExpressions_near_rdh
|
/**
* Finds the closest points relative to the given location and orders the results with decreasing proximity
*
* @param expr
* location
* @param latVal
* latitude
* @param longVal
* longitude
* @return predicate
*/
public static BooleanExpression near(Expression<Double[]> expr, double latVal, double longVal) {
return Expressions.booleanOperation(MongodbOps.NEAR, expr, ConstantImpl.create(new Double[]{ latVal, longVal }));
}
| 3.26 |
querydsl_MongodbExpressions_nearSphere_rdh
|
/**
* Finds the closest points relative to the given location on a sphere and orders the results with decreasing proximity
*
* @param expr
* location
* @param latVal
* latitude
* @param longVal
* longitude
* @return predicate
*/
public static BooleanExpression nearSphere(Expression<Double[]> expr, double latVal, double longVal) {
return Expressions.booleanOperation(MongodbOps.NEAR_SPHERE, expr, ConstantImpl.create(new Double[]{ latVal, longVal }));
}
| 3.26 |
querydsl_MongodbExpressions_withinBox_rdh
|
/**
* Finds points within bounds of the rectangle
*
* @param blLatVal
* bottom left latitude
* @param blLongVal
* bottom left longitude
* @param urLatVal
* upper right latitude
* @param urLongVal
* upper right longitude
* @return predicate
*/
public static BooleanExpression withinBox(Expression<Double[]> expr, double blLongVal, double blLatVal, double urLongVal, double urLatVal) {
return Expressions.booleanOperation(MongodbOps.GEO_WITHIN_BOX, expr, ConstantImpl.create(new Double[]{ blLongVal, blLatVal }), ConstantImpl.create(new Double[]{ urLongVal, urLatVal }));
}
| 3.26 |
querydsl_AbstractJPAQuery_m0_rdh
|
/**
* Transforms results using FactoryExpression if ResultTransformer can't be used
*
* @param query
* query
* @return single result
*/
@Nullable
private Object m0(Query query) {
if (projection != null) {
Object result = query.getSingleResult();
if (result != null) {if (!result.getClass().isArray()) {
result = new Object[]{ result };
}
return projection.newInstance(((Object[]) (result)));
} else {
return null;
}
} else {
return query.getSingleResult();
}
}
| 3.26 |
querydsl_AbstractJPAQuery_getResultList_rdh
|
/**
* Transforms results using FactoryExpression if ResultTransformer can't be used
*
* @param query
* query
* @return results
*/
private List<?> getResultList(Query
query) {
// TODO : use lazy fetch here?
if (projection != null) {List<?> results = query.getResultList();
List<Object> rv = new ArrayList<Object>(results.size());
for (Object o : results) {
if (o != null) {
if (!o.getClass().isArray()) {
o = new Object[]{ o };
}
rv.add(projection.newInstance(((Object[]) (o))));
} else {
rv.add(projection.newInstance(new Object[]{ null }));
}
}
return rv;
} else {
return query.getResultList();
}
}
| 3.26 |
querydsl_QueryResults_getTotal_rdh
|
/**
* Get the total number of results
*
* @return total rows
*/
public long getTotal() {
return total;}
| 3.26 |
querydsl_QueryResults_isEmpty_rdh
|
/**
* Return whether there are results in the current query window
*
* @return true, if no results where found
*/
public boolean isEmpty() {
return f1.isEmpty();}
| 3.26 |
querydsl_QueryResults_getOffset_rdh
|
/**
* Get the offset value used for the query
*
* @return applied offset
*/public long getOffset() {
return offset;
}
| 3.26 |
querydsl_QueryResults_getResults_rdh
|
/**
* Get the results in List form
*
* An empty list is returned for no results.
*
* @return results
*/
public List<T> getResults() {
return f1;
}
| 3.26 |
querydsl_MapExpressionBase_isEmpty_rdh
|
/**
* Create a {@code this.isEmpty()} expression
*
* @return this.isEmpty()
*/ public final BooleanExpression isEmpty() {
if
(empty == null) {
empty = Expressions.booleanOperation(Ops.MAP_IS_EMPTY, mixin);
}
return empty;
}
| 3.26 |
querydsl_MapExpressionBase_containsKey_rdh
|
/**
* Create a {@code key in keys(this)} expression
*
* @param key
* key
* @return expression
*/
public final BooleanExpression containsKey(K key) {
return Expressions.booleanOperation(Ops.CONTAINS_KEY, mixin, ConstantImpl.create(key));
}
| 3.26 |
querydsl_MapExpressionBase_contains_rdh
|
/**
* Create a {@code (key, value) in this} expression
*
* @param key
* key of entry
* @param value
* value of entry
* @return expression
*/
@SuppressWarnings("unchecked")
public final BooleanExpression contains(Expression<K> key, Expression<V>
value) {
return
get(key).eq(((Expression) (value)));
}
| 3.26 |
querydsl_MapExpressionBase_containsValue_rdh
|
/**
* Create a {@code value in values(this)} expression
*
* @param value
* value
* @return expression
*/
public final BooleanExpression containsValue(V value) {
return Expressions.booleanOperation(Ops.CONTAINS_VALUE, mixin, ConstantImpl.create(value));
}
| 3.26 |
querydsl_MapExpressionBase_isNotEmpty_rdh
|
/**
* Create a {@code !this,isEmpty()} expression
*
* @return !this.isEmpty()
*/
public final BooleanExpression isNotEmpty() {
return isEmpty().not();
}
/**
* Create a {@code this.size()}
| 3.26 |
querydsl_AbstractSQLServerQuery_tableHints_rdh
|
/**
* Set the table hints
*
* @param tableHints
* table hints
* @return the current object
*/
public C tableHints(SQLServerTableHints... tableHints) {
if (tableHints.length > 0) {
String hints = SQLServerGrammar.tableHints(tableHints);
addJoinFlag(hints, Position.BEFORE_CONDITION);
}
return ((C) (this));
}
| 3.26 |
querydsl_AbstractGroupExpression_as_rdh
|
/**
* Create an alias for the expression
*
* @return alias expression
*/
public DslExpression<R> as(Path<R> alias)
{
return Expressions.dslOperation(getType(), Ops.ALIAS, this, alias);
}
| 3.26 |
querydsl_CollectionExpressionBase_contains_rdh
|
/**
* Create a {@code this.contains(child)} expression
*
* <p>Evaluates to true, if child is contained in this</p>
*
* @param child
* element to check
* @return this.contains(child)
*/
public final BooleanExpression contains(Expression<E> child) {
return Expressions.booleanOperation(Ops.IN, child, mixin);
}
| 3.26 |
querydsl_CollectionExpressionBase_isEmpty_rdh
|
/**
* Create a {@code this.isEmpty()} expression
*
* <p>Evaluates to true, if this has no elements.</p>
*
* @return this.isEmpty()
*/
public final BooleanExpression isEmpty() {
if (empty == null)
{
empty = Expressions.booleanOperation(Ops.COL_IS_EMPTY, mixin);
}
return empty;
}
| 3.26 |
querydsl_CollectionExpressionBase_size_rdh
|
/**
* Create a {@code this.size()} expression
*
* <p>Gets the number of elements in this collection</p>
*
* @return this.size()
*/
public final NumberExpression<Integer> size() {
if (size == null) {
size = Expressions.numberOperation(Integer.class, Ops.COL_SIZE, mixin);
}
return size;
}
| 3.26 |
querydsl_SurfaceExpression_centroid_rdh
|
/**
* The mathematical centroid for this Surface as a Point. The result is not guaranteed to
* be on this Surface.
*
* @return centroid
*/
public PointExpression<Point> centroid() {
if (centroid == null) {
centroid = GeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
| 3.26 |
querydsl_SurfaceExpression_pointOnSurface_rdh
|
/**
* A Point guaranteed to be on this Surface.
*
* @return point on surface
*/
public PointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = GeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}return pointOnSurface;
}
| 3.26 |
querydsl_WindowRows_unboundedPreceding_rdh
|
/**
* Intermediate step
*/public class Between {
public BetweenAnd unboundedPreceding() {
str.append(UNBOUNDED);
str.append(PRECEDING);
return new BetweenAnd();
}
| 3.26 |
querydsl_AbstractDomainExporter_execute_rdh
|
/**
* Export the contents
*
* @throws IOException
*/
public void execute() throws IOException {
// collect types
try {
collectTypes();
} catch (Exception e) {
throw new QueryException(e);
}
// go through supertypes
Set<Supertype> additions = new HashSet<>();
for (Map.Entry<Class<?>, EntityType> entry : allTypes.entrySet()) {
EntityType entityType = entry.getValue();
if ((entityType.getSuperType() != null) && (!allTypes.containsKey(entityType.getSuperType().getType().getJavaClass()))) {
additions.add(entityType.getSuperType());
}
}
for (Supertype type : additions) {
type.setEntityType(createEntityType(type.getType(), this.superTypes));
}
// merge supertype fields into subtypes
Set<EntityType> handled = new HashSet<EntityType>();
for (EntityType type : superTypes.values()) {
addSupertypeFields(type, allTypes, handled);
}
for (EntityType type : entityTypes.values()) {
addSupertypeFields(type, allTypes, handled);
}
for (EntityType type : embeddableTypes.values()) {addSupertypeFields(type, allTypes, handled);
}
// serialize them
serialize(superTypes, supertypeSerializer);
serialize(embeddableTypes, embeddableSerializer);
serialize(entityTypes, entitySerializer);
}
| 3.26 |
querydsl_AbstractCollQuery_from_rdh
|
/**
* Add a query source
*
* @param <A>
* type of expression
* @param entity
* Path for the source
* @param col
* content of the source
* @return current object
*/
public <A> Q from(Path<A> entity, Iterable<? extends A> col) {
iterables.put(entity, col);
m1().addJoin(JoinType.DEFAULT, entity);
return queryMixin.getSelf();
}
| 3.26 |
querydsl_AbstractCollQuery_m2_rdh
|
/**
* Define a left join from the Collection typed path to the alias
*
* @param <P>
* type of expression
* @param target
* target of the join
* @param alias
* alias for the join target
* @return current object
*/
public <P> Q m2(Path<? extends Collection<P>> target, Path<P> alias) {
m1().addJoin(JoinType.LEFTJOIN, createAlias(target, alias));
return queryMixin.getSelf();
}
| 3.26 |
querydsl_AbstractCollQuery_innerJoin_rdh
|
/**
* Define an inner join from the Map typed path to the alias
*
* @param <P>
* type of expression
* @param target
* target of the join
* @param alias
* alias for the join target
* @return current object
*/
public <P> Q innerJoin(MapExpression<?, P> target, Path<P> alias) {
m1().addJoin(JoinType.INNERJOIN, createAlias(target, alias));
return queryMixin.getSelf();
}
| 3.26 |
querydsl_AbstractCollQuery_bind_rdh
|
/**
* Bind the given collection to an already existing query source
*
* @param <A>
* type of expression
* @param entity
* Path for the source
* @param col
* content of the source
* @return current object
*/
public <A> Q bind(Path<A> entity, Iterable<? extends A> col) {iterables.put(entity, col);
return queryMixin.getSelf();
}
| 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.