'How to wrap the return of @FindBy into another class

The usage of the annotation @FindBy of selenium is:

    @FindBy(xpath='//xpath/selector')
    private WebElement element;
    
    public void setText(String text) {
      element.clear();
      element.sendKeys(text);
    }

But I would like to wrap the WebElement result from the FindBy into another class TextBox for example

public class TextBox {
    private final WebElement element;

    public TextBox(WebElement element){
        this.element = element;
    }

    public void setText(String text) {
        element.clear();
        element.sendKeys(text);
    }
}

And being able to use it as follows

@FindBy(xpath='//xpath/selector')
private TextBox element;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source