List of usage examples for java.util Objects isNull
public static boolean isNull(Object obj)
From source file:org.kitodo.production.metadata.MetadataProcessor.java
private List<LegacyDocStructHelperInterface> getStructureElements(LegacyDocStructHelperInterface docStruct) { List<LegacyDocStructHelperInterface> docStructElements = new LinkedList<>(); if (Objects.nonNull(docStruct)) { docStructElements.add(docStruct); if (Objects.nonNull(docStruct.getAllChildren())) { for (LegacyDocStructHelperInterface element : docStruct.getAllChildren()) { if (Objects.nonNull(element)) { if (Objects.isNull(element.getAllChildren()) || element.getAllChildren().isEmpty()) { docStructElements.add(element); } else { docStructElements.addAll(getStructureElements(element)); }/* ww w . ja va 2 s . c o m*/ } } } } return docStructElements; }
From source file:org.kitodo.production.metadata.MetadataProcessor.java
private List<SelectItem> getAllowedItems(String itemType) { List<Locale.LanguageRange> priorityList = Locale.LanguageRange .parse(ServiceManager.getUserService().getAuthenticatedUser().getMetadataLanguage()); if (Objects.isNull(this.selectedTreeNode) || !(this.selectedTreeNode.getData() instanceof IncludedStructuralElement)) { Helper.setErrorMessage("TreeNode data does not contain structure element!"); return Collections.emptyList(); }// w w w. j a v a2s .c o m IncludedStructuralElement includedStructuralElement = (IncludedStructuralElement) this.selectedTreeNode .getData(); StructuralElementViewInterface structuralElementView = rulesetManagement .getStructuralElementView(includedStructuralElement.getType(), "", priorityList); if (itemType.equals(METADATA)) { Map<Metadata, String> metadataEntriesMappedToKeyNames = includedStructuralElement.getMetadata() .parallelStream().collect(Collectors.toMap(Function.identity(), Metadata::getKey)); return structuralElementView .getAddableMetadata(metadataEntriesMappedToKeyNames, Collections.emptyList()).stream() .map(e -> new SelectItem(e.getId(), e.getLabel())).collect(Collectors.toList()); } else if (itemType.equals(STRUCTURE_ELEMENT)) { Map<String, String> structureElements = structuralElementView.getAllowedSubstructuralElements(); return structureElements.entrySet().stream().map(e -> new SelectItem(e.getKey(), e.getValue())) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }