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

org.ioc.commons.impl.android.integration.service.AndroidServiceObjectManager Maven / Gradle / Ivy

package org.ioc.commons.impl.android.integration.service;

import org.ioc.commons.integration.common.ObjectState;
import org.ioc.commons.integration.service.Service;
import org.ioc.commons.integration.service.ServiceObjectManager;

public class AndroidServiceObjectManager implements ServiceObjectManager {

	private final Service service;

	public AndroidServiceObjectManager(Service service) {
		this.service = service;
	}
	
	@Override
	public  T create(Class class1) {
		try {
			return class1.newInstance();
		} catch (InstantiationException e) {
			throw new RuntimeException("Error creating instance of " + class1, e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException("Error creating instance of " + class1, e);
		}
	}

	@Override
	public  T edit(T entity) {
		/**
		 * On Android the edition is always enabled.
		 */
		return entity;
	}

	@Override
	public Service getService() {
		return this.service;
	}

	@Override
	public ObjectState getObjectState(Object object) {
		/**
		 * Unable to know the object state by using RequestFactory. 
		 */
		return ObjectState.UNKNOWN;
	}

	@Override
	public  T detach(T object, boolean detachAttributesRecursively) {
		/**
		 * Unable to know the object state by using RequestFactory. 
		 */
		return object;
	}
	
	@Override
	public  T detach(T object) {
		return detach(object, true);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy