why functional interface 'selectDSLCompleter' does not contain any abstract method?

37 Views Asked by At

As far as I know, a functional interface in Java must have one (and only one) abstract method. However, the interface named selectDSLCompleter in org.mybatis.dynamic.sql.select does not have any abstract method, but still works normally.

The interface is defined as below:

package org.mybatis.dynamic.sql.select;

import java.util.function.Function;
import org.mybatis.dynamic.sql.SortSpecification;
import org.mybatis.dynamic.sql.util.Buildable;

@FunctionalInterface
public interface SelectDSLCompleter extends Function<QueryExpressionDSL<SelectModel>, Buildable<SelectModel>> {
    static SelectDSLCompleter allRows(){
        return (c) -> {
            return c;
        };
    }

    static SelectDSLCompleter allRowsOrderedBy(SortSpecification... columns) {
        return (c) -> {
            return c.orderBy(columns);
        };
    }
}

And is used as this example:

Method defined in mapper:

default List<Person> select(SelectDSLCompleter completer) {
    return MyBatis3Utils.selectList(this::selectMany, selectList, person, completer);
}

Method called in service:

List<Person> allRecords = mapper.select(c -> c);

Is there anything I missed?

I searched the question, but found nothing. I'm just wondering how it works.

1

There are 1 best solutions below

0
Sören On BEST ANSWER

It does contain one abstract method. The one it inherits from Function<QueryExpressionDSL<SelectModel>, Buildable<SelectModel>>