public < T > void validateDuplicateKeyValueConfiguration ( String parentElementName , String keyElementName , String keyElementValue , String valueElementName , T newValue , ConfigItem < T > priorConfigItem ) { T priorValue = priorConfigItem . getValue ( ) ; if ( priorValue == null ) { if ( newValue == null ) { return ; // Same null value; ignore } else { // Different values: null vs non-null; check the source } } else if ( newValue == null ) { // Different values: non-null vs null; check the source } else if ( priorConfigItem . compareValue ( newValue ) ) { return ; // Same non-null value; ignore } ConfigSource priorSource = priorConfigItem . getSource ( ) ; ConfigSource newSource = getConfigSource ( ) ; if ( priorSource == ConfigSource . WEB_XML ) { if ( newSource == ConfigSource . WEB_FRAGMENT ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "{0} {1} == {2} {3} == {4} is configured in web.xml, the value {5} from web-fragment.xml in {6} is ignored" , parentElementName , keyElementName , keyElementValue , valueElementName , priorValue , newValue , getLibraryURI ( ) ) ; } } else { // web.xml vs web.xml: Should not be possible; ignore. } } else if ( priorSource == ConfigSource . WEB_FRAGMENT ) { // If the prior source is a web-fragment.xml, we have started // processing fragments, and any subsequent source must also // be a fragment. String priorLibraryURI = priorConfigItem . getLibraryURI ( ) ; String newLibraryURI = getLibraryURI ( ) ; if ( ! priorLibraryURI . equals ( newLibraryURI ) ) { errorMessages . add ( nls . getFormattedMessage ( "CONFLICT_KEY_VALUE_CONFIG_BETWEEN_WEB_FRAGMENT_XML" , new Object [ ] { valueElementName , parentElementName , keyElementName , keyElementValue , priorValue , priorLibraryURI , newValue , newLibraryURI } , "Conflict configurations are found in the web-fragment.xml files" ) ) ; } else { // Same library; should not be possible; ignore } } }
Validate configuration items which are elements of keyed collections in two configurations .