de.intarsys.tools.reflect.CollectionRelationHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isrt Show documentation
Show all versions of isrt Show documentation
The basic runtime tools and interfaces for intarsys components.
/**
*
*/
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