001package org.xbib.elasticsearch.index.analysis.standardnumber;
002
003import org.xbib.standardnumber.ARK;
004import org.xbib.standardnumber.DOI;
005import org.xbib.standardnumber.EAN;
006import org.xbib.standardnumber.GTIN;
007import org.xbib.standardnumber.IBAN;
008import org.xbib.standardnumber.ISAN;
009import org.xbib.standardnumber.ISBN;
010import org.xbib.standardnumber.ISMN;
011import org.xbib.standardnumber.ISNI;
012import org.xbib.standardnumber.ISSN;
013import org.xbib.standardnumber.ISTC;
014import org.xbib.standardnumber.ISWC;
015import org.xbib.standardnumber.ORCID;
016import org.xbib.standardnumber.PPN;
017import org.xbib.standardnumber.SICI;
018import org.xbib.standardnumber.StandardNumber;
019import org.xbib.standardnumber.UPC;
020import org.xbib.standardnumber.ZDB;
021
022import java.util.Arrays;
023import java.util.Collection;
024import java.util.List;
025
026import static org.elasticsearch.common.collect.Lists.newLinkedList;
027
028public class StandardNumberService {
029
030    public static StandardNumber create(String type) {
031        if  ("ark".equals(type)) {
032            return new ARK();
033        }
034        if  ("doi".equals(type)) {
035            return new DOI();
036        }
037        if  ("ean".equals(type)) {
038            return new EAN();
039        }
040        if  ("gtin".equals(type)) {
041            return new GTIN();
042        }
043        if  ("iban".equals(type)) {
044            return new IBAN();
045        }
046        if  ("isan".equals(type)) {
047            return new ISAN();
048        }
049        if  ("isbn".equals(type)) {
050            return new ISBN();
051        }
052        if  ("ismn".equals(type)) {
053            return new ISMN();
054        }
055        if  ("isni".equals(type)) {
056            return new ISNI();
057        }
058        if  ("issn".equals(type)) {
059            return new ISSN();
060        }
061        if  ("istc".equals(type)) {
062            return new ISTC();
063        }
064        if  ("iswc".equals(type)) {
065            return new ISWC();
066        }
067        if  ("orcid".equals(type)) {
068            return new ORCID();
069        }
070        if  ("ppn".equals(type)) {
071            return new PPN();
072        }
073        if  ("sici".equals(type)) {
074            return new SICI();
075        }
076        if  ("upc".equals(type)) {
077            return new UPC();
078        }
079        if  ("zdb".equals(type)) {
080            return new ZDB();
081        }
082        return null;
083    }
084
085    public static Collection<StandardNumber> create(Collection<String> types) {
086        List<StandardNumber> stdnums = newLinkedList();
087        for (String type : types) {
088            stdnums.add(create(type));
089        }
090        return stdnums;
091    }
092
093    public static Collection<StandardNumber> create() {
094        StandardNumber[] array = new StandardNumber[] {
095                new ARK(),
096                new DOI(),
097                new EAN(),
098                new GTIN(),
099                new IBAN(),
100                new ISAN(),
101                new ISBN(),
102                new ISMN(),
103                new ISNI(),
104                new ISSN(),
105                new ISTC(),
106                new ISWC(),
107                new ORCID(),
108                new PPN(),
109                new SICI(),
110                new UPC(),
111                new ZDB()
112        };
113        return Arrays.asList(array);
114    }
115
116}