public interface Into<T> {
	
	Class<T> getClazz();
	
	<E> E to(IntoConverter<E> converter);
	
	<R> Value<Into<T>, R> value(Function<T, R> property);

}
 public interface Value<E, R> {
	
	E set(R value);

}
 public class SimpleConvention implements Convention {
	
	@Override
	public String getNameFromMethod(List<Method> methods) {
		StringBuilder sb = new StringBuilder();
		
		for(Method m : methods) {
			String name = getNameFromMethod(m);
			if(sb.length() > 0) {
				sb.append("_");
			}
			sb.append(name);
		}
		
		return sb.toString();
	}

	@Override
	public String getNameFromMethod(Method m) {
		return getPropertyNameFromMethod(m);
	}

	@Override
	public <T> String getNameFromClass(Class<T> clazz) {
		return clazz.getSimpleName();
	}
	
	public static String getPropertyNameFromMethod(Method m) {
		String result = m.getName();
		
		String name = m.getName();
		if((name.startsWith("get") || name.startsWith("set"))
				&& name.length() > 3) {
			
			result = name.substring(3, 4).toLowerCase();
			if(name.length() > 4) {
				result += name.substring(4);
			}
		}
		
		return result;
	}
	
}
 public interface Convention {
	
	String getNameFromMethod(List<Method> methods);

	String getNameFromMethod(Method m);

	<T> String getNameFromClass(Class<T> clazz);
	
}
 public class HolderInt {
	public int value;
	
	@Override
	public String toString() {
		return String.valueOf(value);
	}
}
 public interface MethodRecordProxy<T> {
	
	Method getCalledMethod();
	
	T getProxy();

	void clear();

	List<Method> getMethods();

	void setExecute(boolean b);
	
} public class Tuple<T1, T2> {
	
	private T1 t1;
	private T2 t2;
	
	public Tuple(T1 t1, T2 t2) {
		this.t1 = t1;
		this.t2 = t2;
	}

	public T1 getT1() {
		return t1;
	}

	public T2 getT2() {
		return t2;
	}	

}
 public class TypeUtils {
	
	private static MethodRecordProxyFactory recordFactory;
	
	static {
		recordFactory = new MethodRecordProxyFactory() {
			public <T> MethodRecordProxy<T> create(Class<T> clazz) {
				return new MethodRecordProxyCGLib<T>(clazz);
			}
		};
	}
	
	public static void setMethodRecordProxyFactory(MethodRecordProxyFactory f) {
		recordFactory = f;
	}
	
	public static <E> E createInstance(Class<E> clazz) {
		try {
			return clazz.newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	public static <T> MethodRecordProxy<T> createProxy(Class<T> clazz) {
		return recordFactory.create(clazz);
	}
	
	private TypeUtils () {
	}

	private static final Set<Class<?>> VALUE_TYPE = getValuesTypes();

	public static boolean isValueType(Class<?> clazz) {
		return VALUE_TYPE.contains(clazz);
	}

	private static Set<Class<?>> getValuesTypes() {
		Set<Class<?>> types = new HashSet<Class<?>>();
		
		types.add(Character.class);
		types.add(String.class);
		types.add(Boolean.class);
		types.add(Byte.class);
		types.add(Short.class);
		types.add(Integer.class);
		types.add(Long.class);
		types.add(Float.class);
		types.add(Double.class);
		types.add(Void.class);
		
		return types;
	}

}
 public interface UpdateConverter<E> {

	<T> E convert(UpdateImpl<T> updateImpl);

} public class UpdateImpl<T>
	extends WhereImpl<T, Update<T>, UpdateImpl<T>> 
	implements Update<T>, PredicateProvider<T, UpdateImpl<T>> {
	
	private Class<T> clazz;
	private List<Tuple<Function<T, ?>, Value<Into<T>, ?>>> values;

	public UpdateImpl(Class<T> clazz) {
		super(clazz);
		this.clazz = clazz;
		this.values = new ArrayList<Tuple<Function<T, ?>, Value<Into<T>, ?>>>();
	}
	
	public Class<T> getClazz() {
		return clazz;
	}
	
	public List<Tuple<Function<T, ?>, Value<Into<T>, ?>>> getValues() {
		return values;
	}
	
	@Override
	public <E> E to(UpdateConverter<E> converter) {
		return converter.convert(this);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public <R> Value<Update<T>, R> value(Function<T, R> property) {
		ValueImpl<Update<T>, R> v = new ValueImpl<Update<T>, R>(this);
		Tuple<Function<T, R>, Value<Update<T>, R>> t = new Tuple<Function<T, R>, Value<Update<T>, R>>(property, v);
		// TODO: analisar porque
		this.values.add((Tuple<Function<T, ?>, Value<Into<T>, ?>>)(Object)t);
		return v;
	}

}
 public class UpdateParts {
	
	private StringBuilder table;
	private StringBuilder set;
	private StringBuilder where;
	
	public UpdateParts() {
		this.table = new StringBuilder("");
		this.set = new StringBuilder("");
		this.where = new StringBuilder("");
	}
	
	public StringBuilder getTable() {
		return table;
	}

	public StringBuilder getSet() {
		return set;
	}

	public StringBuilder getWhere() {
		return where;
	}
	
	public boolean hasWhere() {
		return where.length() > 0;
	}

}
 public class ValueImpl<T, R> implements Value<T, R> {
	
	private T t;
	private R value;
	
	public ValueImpl(T t) {
		this.t = t;
	}

	public R get() {
		return value;
	}
	
	@Override
	public T set(R value) {
		this.value = value;
		return t;
	}
	
}

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.naskar.fluentquery.Into;
import com.naskar.fluentquery.Value;
import com.naskar.fluentquery.conventions.SimpleConvention;
import com.naskar.fluentquery.impl.Convention;
import com.naskar.fluentquery.impl.HolderInt;
import com.naskar.fluentquery.impl.MethodRecordProxy;
import com.naskar.fluentquery.impl.Tuple;
import com.naskar.fluentquery.impl.TypeUtils;
import com.naskar.fluentquery.impl.UpdateConverter;
import com.naskar.fluentquery.impl.UpdateImpl;
import com.naskar.fluentquery.impl.UpdateParts;
import com.naskar.fluentquery.impl.ValueImpl;

package com.naskar.fluentquery.converters;



public class NativeSQLUpdate implements UpdateConverter<NativeSQLResult> {
	
	private Convention convention;
	private NativeSQL nativeSQL;
	private NativeSQLWhereImpl nativeWhereImpl;
	
	private boolean withoutAlias;
	private boolean withoutTableName;
	
	public NativeSQLUpdate(Convention convention) {
		this.convention = convention;
		this.nativeSQL = new NativeSQL();
		this.nativeSQL.setConvention(convention);
		this.nativeWhereImpl = new NativeSQLWhereImpl(this.nativeSQL);
		this.nativeWhereImpl.setConvention(convention);
		this.withoutAlias = true;
		this.withoutTableName = false;
	}
	
	public NativeSQLUpdate setWithoutAlias(boolean withoutAlias) {
		this.withoutAlias = withoutAlias;
		return this;
	}
	
	public NativeSQLUpdate setWithoutTableName(boolean withoutTableName) {
		this.withoutTableName = withoutTableName;
		return this;
	}
	
	public NativeSQLUpdate() {
		this(new SimpleConvention());
	}
	
	public NativeSQLUpdate setConvention(Convention convention) {
		this.convention = convention;
		this.nativeSQL.setConvention(convention);
		this.nativeWhereImpl.setConvention(convention);
		return this;
	}
		
	@Override

	public <T> NativeSQLResult convert(UpdateImpl<T> updateImpl) {
