package org.jabref.logic;

import java.util.Objects;
import java.util.Optional;

import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.BibEntryTypesManager;

/**
 * Wrapper around a {@link BibEntry} offering methods for {@link BibDatabaseMode} dependend results
 */
public class TypedBibEntry {

    private final BibEntry entry;
    private final Optional<BibDatabase> database;
    private final BibDatabaseMode mode;

    public TypedBibEntry(BibEntry entry, BibDatabaseMode mode) {
        this(entry, Optional.empty(), mode);
    }

    private TypedBibEntry(BibEntry entry, Optional<BibDatabase> database, BibDatabaseMode mode) {
        this.entry = Objects.requireNonNull(entry);
        this.database = Objects.requireNonNull(database);
        this.mode = mode;
    }

    public TypedBibEntry(BibEntry entry, BibDatabaseContext databaseContext) {
        this(entry, Optional.of(databaseContext.getDatabase()), databaseContext.getMode());
    }

    /**
     * Returns true if this entry contains the fields it needs to be complete.
     *
     * @param entryTypesManager
     */
    public boolean hasAllRequiredFields(BibEntryTypesManager entryTypesManager) {
        Optional<BibEntryType> type = entryTypesManager.enrich(entry.getType(), this.mode);
        if (type.isPresent()) {
            return entry.allFieldsPresent(type.get().getRequiredFields(), database.orElse(null));
        } else {
            return true;
        }
    }

    /**
     * Gets the display name for the type of the entry.
     */
    public String getTypeForDisplay() {
        return entry.getType().getDisplayName();
    }
}

@@ -449,17 +449,17 @@
 ode%7D
- 
+-
 dependen
 d re
@@ -454,17 +454,17 @@
 dependen
-d
+t
  results
@@ -692,158 +692,8 @@
 ) %7B%0A
-        this(entry, Optional.empty(), mode);%0A    %7D%0A%0A    private TypedBibEntry(BibEntry entry, Optional%3CBibDatabase%3E database, BibDatabaseMode mode) %7B%0A
     
@@ -769,65 +769,73 @@
  = O
-bjects.requireNonNull(database);%0A        this.mode = 
+ptional.empty();%0A        this.mode = Objects.requireNonNull(
 mode
+)
 ;%0A  
@@ -934,60 +934,159 @@
 this
-(entry, Optional.of(databaseContext.getDatabase()), 
+.entry = Objects.requireNonNull(entry);%0A        this.database = Optional.of(databaseContext.getDatabase());%0A        this.mode = Objects.requireNonNull(
 data
@@ -1092,24 +1092,25 @@
 abaseContext
+)
 .getMode());
@@ -1107,17 +1107,16 @@
 etMode()
-)
 ;%0A    %7D%0A
@@ -1135,23 +1135,120 @@
   * 
-Returns true if
+Checks the fields of the entry whether all required fields are set.%0A     * In other words: It is checked whether
  thi
@@ -1264,19 +1264,19 @@
 ontains 
-the
+all
  fields 
@@ -1319,31 +1319,67 @@
  * @
-param entryTypesManager
+return true if all required fields are set, false otherwise
 %0A   

Fix code style (#6792)