Skip to content

Commit

Permalink
Honor biblatex mode at default constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Nov 23, 2015
1 parent a1430d7 commit 1776bb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
13 changes: 2 additions & 11 deletions src/main/java/net/sf/jabref/bibtex/EntryTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,15 @@ private static void initBibtexEntryTypes() {
* or null if it does not exist.
*/
public static EntryType getType(String name) {
EntryType entryType = ALL_TYPES.get(name.toLowerCase());
if (entryType == null) {
return null;
}
return entryType;
return ALL_TYPES.get(name.toLowerCase());
}

/**
* This method returns the standard BibtexEntryType for the
* name of a type, or null if it does not exist.
*/
public static EntryType getStandardType(String name) {
EntryType entryType = STANDARD_TYPES.get(name.toLowerCase());
if (entryType == null) {
return null;
} else {
return entryType;
}
return STANDARD_TYPES.get(name.toLowerCase());
}

public static void addOrModifyCustomEntryType(CustomEntryType type) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/model/entry/BibtexEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import com.google.common.base.Strings;

import net.sf.jabref.bibtex.EntryTypes;
import net.sf.jabref.model.database.BibtexDatabase;

public class BibtexEntry {
Expand Down Expand Up @@ -65,7 +66,7 @@ public BibtexEntry() {
}

public BibtexEntry(String id) {
this(id, BibtexEntryTypes.MISC);
this(id, EntryTypes.getBibtexEntryType("misc"));
}

public BibtexEntry(String id, EntryType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.bibtex.EntryTypes;
import net.sf.jabref.importer.fileformat.BibtexParser;

import java.util.ArrayList;
Expand All @@ -20,8 +21,11 @@ public void setup() {

@Test
public void testDefaultConstructor() {
@SuppressWarnings("unused")
BibtexEntry entry = new BibtexEntry();
// we have to use `getType("misc")` in the case of biblatex mode
Assert.assertEquals(EntryTypes.getType("misc"), entry.getType());
Assert.assertNotNull(entry.getId());
Assert.assertNull(entry.getField("author"));
}

@Test
Expand Down

0 comments on commit 1776bb6

Please sign in to comment.