} throw new IllegalArgumentException("DataObject not supported.");
} else throw new IllegalArgumentException("Child and parent are not" + " compatible.");
    public static IObject createIObject(DataObject child, DataObject parent)    {        if (child instanceof ProjectData) {            ProjectData data = (ProjectData) child;            Project model = new Project();            model.setName(data.getName());            model.setDescription(data.getDescription());            return model;        } else if (child instanceof CategoryGroupData) {            CategoryGroupData data = (CategoryGroupData) child;            CategoryGroup model = new CategoryGroup();            model.setName(data.getName());            model.setDescription(data.getDescription());            return model;        } else if (child instanceof DatasetData) {            if (!(parent instanceof ProjectData))                 throw new IllegalArgumentException("Parent not valid.");            DatasetData data = (DatasetData) child;            Dataset model = new Dataset();            model.setName(data.getName());            model.setDescription(data.getDescription());            model.linkProject(new Project(new Long(parent.getId()), false));            return model;        } else if (child instanceof CategoryData) {            if (!(parent instanceof CategoryGroupData))                 throw new IllegalArgumentException("Parent not valid.");            CategoryData data = (CategoryData) child;            Category model = new Category();            model.setName(data.getName());            model.setDescription(data.getDescription());            model.linkCategoryGroup(new CategoryGroup(new Long(parent.getId()),                                                     false));            return model;        } else if (child instanceof ImageData) {            if (!(parent instanceof CategoryData) &&                 !(parent instanceof DatasetData))                throw new IllegalArgumentException("Parent not valid.");            ImageData data = (ImageData) child;            Image model = new Image();            model.setName(data.getName());            model.setDescription(data.getDescription());            if (parent instanceof CategoryData)                 model.linkCategory(new Category(new Long(parent.getId()),                                                 false));            else if (parent instanceof DatasetData)                 model.linkDataset(new Dataset(new Long(parent.getId()),                                             false));            return model;         }        throw new IllegalArgumentException("DataObject not supported.");    }