001package org.hl7.fhir.utilities.validation; 002 003 004public class ValidationOptions { 005 public enum ValueSetMode { 006 ALL_CHECKS, CHECK_MEMERSHIP_ONLY, NO_MEMBERSHIP_CHECK 007 } 008 009 private String language; 010 private boolean useServer = true; 011 private boolean useClient = true; 012 private boolean guessSystem = false; 013 private ValueSetMode valueSetMode = ValueSetMode.ALL_CHECKS; 014 private boolean vsAsUrl; 015 private boolean versionFlexible = true; 016 017 public ValidationOptions() { 018 super(); 019 } 020 021 public ValidationOptions(String language) { 022 super(); 023 this.language = language; 024 } 025 026 public String getLanguage() { 027 return language; 028 } 029 030 031 public boolean isUseServer() { 032 return useServer; 033 } 034 035 public boolean isUseClient() { 036 return useClient; 037 } 038 039 public boolean isGuessSystem() { 040 return guessSystem; 041 } 042 043 private ValidationOptions copy() { 044 ValidationOptions n = new ValidationOptions(language); 045 n.useServer = useServer; 046 n.useClient = useClient; 047 n.guessSystem = guessSystem; 048 n.vsAsUrl = vsAsUrl; 049 n.versionFlexible = versionFlexible; 050 return n; 051 } 052 053 public ValidationOptions setLanguage(String language) { 054 ValidationOptions n = this.copy(); 055 n.language = language; 056 return n; 057 } 058 059 060 public ValidationOptions noServer() { 061 ValidationOptions n = this.copy(); 062 n.useServer = false; 063 return n; 064 } 065 066 public ValidationOptions noClient() { 067 ValidationOptions n = this.copy(); 068 n.useClient = false; 069 return n; 070 } 071 072 public ValidationOptions guessSystem() { 073 ValidationOptions n = this.copy(); 074 n.guessSystem = true; 075 return n; 076 } 077 078 079 public String toJson() { 080 return "\"lang\":\""+language+"\", \"useServer\":\""+Boolean.toString(useServer)+"\", \"useClient\":\""+Boolean.toString(useClient)+"\", "+ 081 "\"guessSystem\":\""+Boolean.toString(guessSystem)+"\", \"valueSetMode\":\""+valueSetMode.toString()+"\", \"versionFlexible\":\""+Boolean.toString(versionFlexible)+"\""; 082 } 083 084 public static ValidationOptions defaults() { 085 return new ValidationOptions("en-US"); 086 } 087 088 public ValidationOptions checkValueSetOnly() { 089 ValidationOptions n = this.copy(); 090 n.valueSetMode = ValueSetMode.CHECK_MEMERSHIP_ONLY; 091 return n; 092 } 093 094 public ValidationOptions noCheckValueSetMembership() { 095 ValidationOptions n = this.copy(); 096 n.valueSetMode = ValueSetMode.NO_MEMBERSHIP_CHECK; 097 return n; 098 } 099 100 public ValueSetMode getValueSetMode() { 101 return valueSetMode; 102 } 103 104 public ValidationOptions setVsAsUrl() { 105 vsAsUrl = true; 106 return this; 107 } 108 109 public boolean getVsAsUrl() { 110 return vsAsUrl; 111 } 112 113 public boolean versionFlexible() { 114 return versionFlexible; 115 } 116 117 public ValidationOptions setVersionFlexible(boolean value) { 118 ValidationOptions n = this.copy(); 119 n.versionFlexible = value; 120 return n; 121 } 122 123 124}