001package org.hl7.fhir.dstu3.utils;
002
003import java.util.ArrayList;
004import java.util.HashSet;
005import java.util.List;
006import java.util.Set;
007
008import org.hl7.fhir.dstu3.model.StructureDefinition;
009
010public class ValidationProfileSet {
011
012  public static class ProfileRegistration {
013    private String profile; 
014    private boolean error;  
015    
016    public ProfileRegistration(String profile, boolean error) {
017      super();
018      this.profile = profile;
019      this.error = error;
020    }
021    public String getProfile() {
022      return profile;
023    }
024    public boolean isError() {
025      return error;
026    }
027    
028    
029  }
030  private List<ProfileRegistration> canonical = new ArrayList<ProfileRegistration>();
031  private List<StructureDefinition> definitions = new ArrayList<StructureDefinition>();
032  
033  public ValidationProfileSet(String profile, boolean isError) {
034    super();
035    canonical.add(new ProfileRegistration(profile, isError));
036  }
037
038  public ValidationProfileSet() {
039    super();
040  }
041
042  public ValidationProfileSet(StructureDefinition profile) {
043    super();
044    definitions.add(profile);
045  }
046
047  public ValidationProfileSet(List<String> profiles, boolean isError) {
048    super();
049    if (profiles != null)
050      for (String p : profiles)
051        canonical.add(new ProfileRegistration(p, isError));
052  }
053
054  public List<String> getCanonicalUrls() {
055    List<String> res = new ArrayList<String>();
056    for (ProfileRegistration c : canonical) {
057      res.add(c.getProfile());
058    }
059    return res;
060  }
061
062  public List<StructureDefinition> getDefinitions() {
063    return definitions;
064  }
065
066  public boolean empty() {
067    return canonical.isEmpty() && definitions.isEmpty();
068  }
069
070  public List<String> getCanonicalAll() {
071    Set<String> res = new HashSet<String>();
072    res.addAll(getCanonicalUrls());
073    for (StructureDefinition sd : definitions)
074      res.add(sd.getUrl());
075    return new ArrayList<String>(res);
076  }
077
078  public List<ProfileRegistration> getCanonical() {
079    return canonical;
080  }
081
082}