package io.jasonsparc.chemistry;

import android.support.annotation.AnyRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.ViewGroup;

import io.jasonsparc.chemistry.util.InflateUtils;

/**
 * TODO Docs
 *
 * Created by jason on 07/07/2016.
 */
public abstract class Chemistry<Item> implements IdSelector<Item>, TypeSelector<Item> {

	public long getItemId(Item item) {
		return NO_ID;
	}

	@ViewType
	@AnyRes
	public abstract int getItemViewType(Item item);

	public abstract VhFactory<?> getVhFactory(Item item);

	public abstract ItemBinder<? super Item, ?> getItemBinder(Item item);


	// Utilities

	public static View inflate(@NonNull ViewGroup parent, @LayoutRes int layoutRes) {
		return InflateUtils.inflate(parent, layoutRes);
	}

	// Factories

	public static <Item> BasicChemistry.Preperator<Item> make() {
		return new BasicChemistry.Preperator<>();
	}

	public static <Item> BasicChemistry.Preperator<Item> make(@ViewType @AnyRes int viewType) {
		return new BasicChemistry.Preperator<Item>().useViewType(viewType);
	}

	public static <Item, VH extends ViewHolder> BasicChemistry.Boiler<Item, VH> make(@NonNull BasicChemistry<? super Item, VH> base) {
		return new BasicChemistry.Boiler<>(base);
	}

	public static <Item, VH extends ViewHolder> BasicChemistry.Boiler<Item, VH> make(@ViewType @AnyRes int viewType, @NonNull BasicChemistry<? super Item, VH> base) {
		return new BasicChemistry.Boiler<>(base).useViewType(viewType);
	}
}

@@ -1584,11 +1584,243 @@
 ype);%0A%09%7D
+%0A%0A%09public static %3CItem, VH extends ViewHolder%3E BasicChemistry.Boiler%3CItem, VH%3E make(@NonNull BasicChemistry.Transformer%3C? super Item, ? super VH%3E transformer) %7B%0A%09%09return new BasicChemistry.Boiler%3CItem, VH%3E().compose(transformer);%0A%09%7D
 %0A%7D%0A

Create Boiler's with a Transformer pre-applied