class OrderedItemMetadataFilter extends MetadataFilterImpl {

  @Override
  public MetadataCollection filter(MetadataCollection originalCollection) {
    MetadataCollection results = new MetadataCollection();
    Map<String, String> original;
    if(ignoreCase()) {
      original = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
      original.putAll(MetadataCollection.asMap(originalCollection));
    } else {
      original = MetadataCollection.asMap(originalCollection);
    }
    for (String key : getMetadataKeys()) {
      String value = original.get(key);
      if (value != null) {
        results.add(new MetadataElement(key, value));
      } else {
        results.add(new MetadataElement(key, ""));
      }
    }
    return results;
  }

}