Source:
public Integer createSampleListFolder(final String folderName, final Integer parentId, final User createdBy, final String programUUID) { Preconditions.checkNotNull(folderName); Preconditions.checkNotNull(parentId); Preconditions.checkNotNull(createdBy,"createdBy can not be empty"); Preconditions.checkNotNull(programUUID); Preconditions.checkArgument(!folderName.isEmpty(), "folderName can not be empty"); Preconditions.checkArgument(!programUUID.isEmpty(), "programUUID can not be empty"); final SampleList parentList; if (0 == parentId) { parentList = this.sampleListDao.getRootSampleList(); } else { parentList = this.sampleListDao.getById(parentId); } if (parentList == null) { Preconditions.checkArgument(false,"Parent Folder does not exist"); } if (!parentList.isFolder()) { Preconditions.checkArgument(false,"Specified parentID is not a folder"); } final SampleList uniqueSampleListName = this.sampleListDao.getSampleListByParentAndName(folderName, parentList.getId(), programUUID); if (uniqueSampleListName != null) { Preconditions.checkArgument(false, "Folder name should be unique within the same directory"); } try { final SampleList sampleFolder = new SampleList(); sampleFolder.setCreatedDate(new Date()); sampleFolder.setCreatedBy(createdBy); sampleFolder.setDescription(null); sampleFolder.setListName(folderName); sampleFolder.setNotes(null); sampleFolder.setHierarchy(parentList); sampleFolder.setType(SampleListType.FOLDER); sampleFolder.setProgramUUID(programUUID); return this.sampleListDao.save(sampleFolder).getId(); } catch (HibernateException e) { throw new MiddlewareQueryException("Error in createSampleListFolder in SampleListServiceImpl: " + e.getMessage(), e); } }

Target:
public Integer createSampleListFolder(final String folderName, final Integer parentId, final User createdBy, final String programUUID) { Preconditions.checkNotNull(folderName); Preconditions.checkNotNull(parentId); Preconditions.checkNotNull(createdBy, "createdBy can not be empty"); Preconditions.checkNotNull(programUUID); Preconditions.checkArgument(!folderName.isEmpty(), "folderName can not be empty"); Preconditions.checkArgument(!programUUID.isEmpty(), "programUUID can not be empty"); final SampleList parentList; if (0 == parentId) { parentList = this.sampleListDao.getRootSampleList(); } else { parentList = this.sampleListDao.getById(parentId); } Preconditions.checkArgument(parentList != null, "Parent Folder does not exist"); Preconditions.checkArgument(parentList.isFolder(), "Specified parentID is not a folder"); final SampleList uniqueSampleListName = this.sampleListDao.getSampleListByParentAndName(folderName, parentList.getId(), programUUID); Preconditions.checkArgument(uniqueSampleListName == null, "Folder name should be unique within the same directory"); try { final SampleList sampleFolder = new SampleList(); sampleFolder.setCreatedDate(new Date()); sampleFolder.setCreatedBy(createdBy); sampleFolder.setDescription(null); sampleFolder.setListName(folderName); sampleFolder.setNotes(null); sampleFolder.setHierarchy(parentList); sampleFolder.setType(SampleListType.FOLDER); sampleFolder.setProgramUUID(programUUID); return this.sampleListDao.save(sampleFolder).getId(); } catch (final HibernateException e) { throw new MiddlewareQueryException("Error in createSampleListFolder in SampleListServiceImpl: " + e.getMessage(), e); } }