/** * Binds the given {@link ViewBinding} to the specified {@link View}. * * @param viewId A view id in a layout XML specifying the target {@link View}. * @param binding An {@link ViewBinding}. * @return The found and bound {@link View}. */ @SuppressWarnings("unchecked") public <T extends View> T bind(final int viewId, final ViewBinding<T> binding) { final T view = getView(viewId); if (binding.canBind(view)) { binding.setView(view); mBindingsCache.put(viewId, binding); } else { throw new IllegalStateException( "No View with id: " + Integer.toString(viewId) + " compatible with the given ViewBinding was found"); } return view; }