Skip to content

Commit

Permalink
Merge pull request #3416 from ebean-orm/feature/querybean-gen-suppres…
Browse files Browse the repository at this point in the history
…swarnings

Change QueryBean to use protected constructors, suppress warning on generated query beans
  • Loading branch information
rbygrave committed Jun 10, 2024
2 parents 7b2128b + 1823ef2 commit fa92e7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ public abstract class QueryBean<T, R> implements IQueryBean<T, R> {
/**
* Construct using the type of bean to query on and the default database.
*/
public QueryBean(Class<T> beanType) {
protected QueryBean(Class<T> beanType) {
this(beanType, DB.getDefault());
}

/**
* Construct using the type of bean to query on and a given database.
*/
public QueryBean(Class<T> beanType, Database database) {
protected QueryBean(Class<T> beanType, Database database) {
this(database.find(beanType));
}

Expand All @@ -119,7 +119,7 @@ protected QueryBean(Class<T> beanType, Database database, Transaction transactio
* Construct using a query.
*/
@SuppressWarnings("unchecked")
public QueryBean(Query<T> query) {
protected QueryBean(Query<T> query) {
this.query = query;
this.root = (R) this;
}
Expand All @@ -129,7 +129,7 @@ public QueryBean(Query<T> query) {
* values for select() and fetch().
*/
@SuppressWarnings("unchecked")
public QueryBean(boolean aliasDummy) {
protected QueryBean(boolean aliasDummy) {
this.query = null;
this.root = (R) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ private void writeFields() {
private void writeClass() {
writer.append("/**").eol();
writer.append(" * Query bean for %s.", shortName).eol();
writer.append(" * ").eol();
writer.append(" * <p>").eol();
writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol();
writer.append(" */").eol();
writer.append("@SuppressWarnings(\"unused\")").eol();
writer.append(Constants.AT_GENERATED).eol();
if (embeddable) {
writer.append("public final class Q%s {", shortName).eol();
Expand Down Expand Up @@ -285,7 +286,7 @@ private void writeAssocClass() {
private void writeAssocFilterMany() {
writer.eol();
writer.append(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})").eol();
writer.append(" public final R filterMany(java.util.function.Consumer<Q%s> apply) {", shortName).eol();
writer.append(" public R filterMany(java.util.function.Consumer<Q%s> apply) {", shortName).eol();
writer.append(" final io.ebean.ExpressionList list = io.ebean.Expr.factory().expressionList();", shortName).eol();
writer.append(" final var qb = new Q%s(list);", shortName).eol();
writer.append(" apply.accept(qb);").eol();
Expand Down

0 comments on commit fa92e7a

Please sign in to comment.