com.buschmais.xo.impl.proxy.entity.property.EntityCollectionPropertySetMethod Maven / Gradle / Ivy
The newest version!
package com.buschmais.xo.impl.proxy.entity.property;
import java.util.Collection;
import com.buschmais.xo.api.metadata.method.EntityCollectionPropertyMethodMetadata;
import com.buschmais.xo.impl.EntityPropertyManager;
import com.buschmais.xo.impl.proxy.common.property.AbstractPropertyMethod;
public class EntityCollectionPropertySetMethod
extends AbstractPropertyMethod, EntityCollectionPropertyMethodMetadata> {
public EntityCollectionPropertySetMethod(EntityPropertyManager propertyManager, EntityCollectionPropertyMethodMetadata metadata) {
super(propertyManager, metadata);
}
public Object invoke(Entity entity, Object instance, Object[] args) {
EntityPropertyManager propertyManager = getPropertyManager();
propertyManager.removeEntityReferences(entity, getMetadata());
Collection> collection = (Collection>) args[0];
for (Object o : collection) {
propertyManager.createEntityReference(entity, getMetadata(), o);
}
return null;
}
}