public class Helper<T extends Helper> { protected T child; public Helper() { child = (T) this; } public T setText(@IdRes int viewId,String textStr) { ... checkChild(); return child; } protected void checkChild() { if (child == null) throw new IllegalStateException("child must be set in child's Constructor!" + "not method:initDefaultValueAnimator"); } }