@Test public void preserveOrder() throws Exception { BibTeXDatabase db = loadUnixDatabase(); BibTeXConverter conv = new BibTeXConverter(); Map<String, CSLItemData> cids = conv.toItemData(db); Iterator<Key> ik1 = db.getEntries().keySet().iterator(); Iterator<String> ik2 = cids.keySet().iterator(); while (ik1.hasNext() && ik2.hasNext()) { assertEquals(ik1.next().getValue(), ik2.next()); } assertFalse(ik1.hasNext()); assertFalse(ik2.hasNext()); }
public Map<String, CSLItemData> toItemData(BibTeXDatabase db) { Map<String, CSLItemData> result = new LinkedHashMap<>(); for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) { result.put(e.getKey().getValue(), toItemData(e.getValue())); } return result; }
BibTeXConverter { public Map<String, CSLItemData> toItemData(BibTeXDatabase db) { Map<String, CSLItemData> result = new LinkedHashMap<>(); for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) { result.put(e.getKey().getValue(), toItemData(e.getValue())); } return result; } }
BibTeXConverter { public Map<String, CSLItemData> toItemData(BibTeXDatabase db) { Map<String, CSLItemData> result = new LinkedHashMap<>(); for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) { result.put(e.getKey().getValue(), toItemData(e.getValue())); } return result; } BibTeXConverter(); }
BibTeXConverter { public Map<String, CSLItemData> toItemData(BibTeXDatabase db) { Map<String, CSLItemData> result = new LinkedHashMap<>(); for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) { result.put(e.getKey().getValue(), toItemData(e.getValue())); } return result; } BibTeXConverter(); BibTeXDatabase loadDatabase(InputStream is); Map<String, CSLItemData> toItemData(BibTeXDatabase db); CSLItemData toItemData(BibTeXEntry e); CSLType toType(Key type); }
BibTeXConverter { public Map<String, CSLItemData> toItemData(BibTeXDatabase db) { Map<String, CSLItemData> result = new LinkedHashMap<>(); for (Map.Entry<Key, BibTeXEntry> e : db.getEntries().entrySet()) { result.put(e.getKey().getValue(), toItemData(e.getValue())); } return result; } BibTeXConverter(); BibTeXDatabase loadDatabase(InputStream is); Map<String, CSLItemData> toItemData(BibTeXDatabase db); CSLItemData toItemData(BibTeXEntry e); CSLType toType(Key type);  }