Skip to content

Commit

Permalink
[Add] Add method initialize to the PaginationSettings.
Browse files Browse the repository at this point in the history
  • Loading branch information
yihleego committed Aug 24, 2020
1 parent 08803a3 commit e47338a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,9 @@ public class PaginationInterceptor implements Interceptor {
private final ConcurrentMap<String, PaginationUnrefinedParam> unrefinedParamMap = new ConcurrentHashMap<>(64);

public PaginationInterceptor(PaginationSettings settings) {
if (settings == null || (settings.getDialect() == null && settings.getSqlDialect() == null)) {
throw new IllegalArgumentException("Dialect is not configured.");
}
// Whether to obtain values from parameter.
settings.setObtainValuesFromFields(
(settings.getPageFieldName() != null && settings.getSizeFieldName() != null)
|| (settings.getOffsetFieldName() != null && settings.getRowsFieldName() != null));
settings.initialize();
this.settings = settings;
this.dialect = settings.getDialect() != null
? settings.getDialect()
: settings.getSqlDialect().newDialect();
this.dialect = settings.getDialect();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ public void setMaxSize(int maxSize) {
this.maxSize = maxSize;
}

public void initialize() {
if (this.dialect == null && this.sqlDialect == null) {
throw new NullPointerException("Dialect is not configured.");
}
this.obtainValuesFromFields = (this.pageFieldName != null && this.sizeFieldName != null)
|| (this.offsetFieldName != null && this.rowsFieldName != null);
if (this.dialect == null) {
this.dialect = this.sqlDialect.newDialect();
}
}

public static Builder builder() {
return new Builder();
}
Expand Down

0 comments on commit e47338a

Please sign in to comment.