org.notima.camel.fortnox.InvoiceReferenceMap Maven / Gradle / Ivy
The newest version!
package org.notima.camel.fortnox;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.notima.api.fortnox.entities3.Invoice;
/**
* A reference map for a specified reference field
*
*/
public class InvoiceReferenceMap {
private String referenceField;
// Map of references to invoices.
private Map> invoiceReferenceMap = new TreeMap>();
// Map of document number to invoice
private Map invoiceMap = new TreeMap();
public InvoiceReferenceMap(String referenceField) {
this.referenceField = referenceField;
}
public String getReferenceField() {
return referenceField;
}
public void addInvoiceToMap(String reference, Invoice i) {
List il = invoiceReferenceMap.get(reference);
if (il==null) {
il = new ArrayList();
invoiceReferenceMap.put(reference, il);
}
il.add(i);
invoiceMap.put(i.getDocumentNumber(), i);
}
public List getInvoicesWithReference(String reference) {
if (invoiceReferenceMap==null) {
return new ArrayList();
}
List result = invoiceReferenceMap.get(reference);
if (result!=null)
return result;
else
return new ArrayList();
}
}