All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.objectquery.generic.GenericUpdateQuery Maven / Gradle / Ivy

The newest version!
package org.objectquery.generic;

import java.util.IdentityHashMap;

import javassist.util.proxy.ProxyObject;

import org.objectquery.UpdateQuery;

public class GenericUpdateQuery extends GenericBaseQuery implements UpdateQuery {

	public GenericUpdateQuery(Class targetClass) {
		this(new GenericInternalQueryBuilder(GroupType.AND), targetClass);
	}

	public GenericUpdateQuery(InternalQueryBuilder builder, Class targetClass) {
		super(builder, targetClass, new IdentityHashMap(), QueryType.UPDATE);
	}

	public  void set(S target, V value) {
		PathItem item = extractItem(target);
		if (item.getParent() == null)
			throw new ObjectQueryException(" Cannot set the value of the root element");
		Object curValue = null;
		if (value instanceof ProxyObject && ((ProxyObject) value).getHandler() instanceof ObjectQueryHandler)
			curValue = ((ObjectQueryHandler) ((ProxyObject) value).getHandler()).getPath();
		else if ((curValue = unproxable.get(value)) == null)
			curValue = value;
		builder.set(item, curValue);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy