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

de.intarsys.tools.reflect.CollectionRelationHandler Maven / Gradle / Ivy

There is a newer version: 4.11
Show newest version
/**
 * 
 */
package de.intarsys.tools.reflect;

import java.util.Collection;

/**
 * The relation is implemented in a plain java collection.
 * 
 */
public class CollectionRelationHandler extends RelationHandlerAdapter {

	@Override
	public Object[] get(Object owner) {
		if (owner == null) {
			return new Object[0];
		}
		return ((Collection) owner).toArray();
	}

	@Override
	public Object insert(Object owner, Object value) {
		if (owner == null) {
			return null;
		}
		if (((Collection) owner).add(value)) {
			return value;
		}
		return null;
	}

	@Override
	public Object remove(Object owner, Object value) {
		if (owner == null) {
			return null;
		}
		if (((Collection) owner).remove(value)) {
			return value;
		}
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy