Lombok 的参数数量错误

Wrong number of Arguments with Lombok

我正在尝试使用 Lombok 的@SuperBuilder,但由于某种原因我在编译时遇到问题 Error:(14, 1) java: wrong number of type arguments; required 3

那是我的子class;

@SuperBuilder
public class FetchFollowersOperation extends Operation<List<InstagramUserSummary>> {

    private String userName;

    public List<InstagramUserSummary> operate() {

        InstagramSearchUsernameResult userResult = null;
        try {
            userResult = instagram4j.sendRequest(new InstagramSearchUsernameRequest(this.userName));
            InstagramGetUserFollowersResult followers = instagram4j.sendRequest(new InstagramGetUserFollowersRequest(userResult.getUser().getPk()));
            return followers.getUsers();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

父class在下方;

@SuperBuilder
public abstract class Operation<T> {
    protected Instagram4j instagram4j;

    public abstract T operate();
}

问题在第 public class FetchFollowersOperation extends Operation<List<InstagramUserSummary>> 行。您必须仅指定一种类型,即 T 而不是此处的内部通用类型,即用 public class FetchFollowersOperation extends Operation<List>.

替换它

这解决了你的问题。虽然我查看了 lombok 文档和其他有关导致此问题的详细信息,但没有获得任何相关信息。

希望对您有所帮助!

正如@Jan Rieke 提到的那样,这是一个错误。通过 https://github.com/rzwitserloot/lombok/issues/2262 报告;它已被修复并将在即将发布的 lombok 版本中。