use of io.jmix.core.entity.HasInstanceMetaClass in project jmix by jmix-framework.
the class InstanceContainerImpl method setItem.
@Override
public void setItem(@Nullable E item) {
E prevItem = this.item;
if (this.item != null) {
detachListener(this.item);
}
if (item != null) {
MetaClass aClass = item instanceof HasInstanceMetaClass ? ((HasInstanceMetaClass) item).getInstanceMetaClass() : metadata.getClass(item);
if (!aClass.equals(entityMetaClass) && !entityMetaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item's metaClass '%s'", aClass), ParamsMap.of("container", toString(), "metaClass", aClass));
}
detachListener(item);
attachListener(item);
}
this.item = item;
fireItemChanged(prevItem);
}
Aggregations