1 /** 2 * Copyright (C) 2014-2017 Philip Helger (www.helger.com) 3 * philip[at]helger[dot]com 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package com.helger.schematron.svrl; 18 19 import javax.annotation.Nonnull; 20 import javax.annotation.Nullable; 21 22 import org.oclc.purl.dsdl.svrl.FailedAssert; 23 import org.oclc.purl.dsdl.svrl.SuccessfulReport; 24 25 import com.helger.commons.ValueEnforcer; 26 import com.helger.commons.error.level.IErrorLevel; 27 28 /** 29 * Interface that helps in determining an error level from SVRL elements. 30 * 31 * @author Philip Helger 32 */ 33 @FunctionalInterface 34 public interface ISVRLErrorLevelDeterminator 35 { 36 /** 37 * Get the error level associated with a single failed assertion/successful 38 * report. 39 * 40 * @param sFlag 41 * The flag to be queried. May be <code>null</code>. 42 * @return The error level and never <code>null</code>. 43 */ 44 @Nonnull 45 IErrorLevel getErrorLevelFromFlag (@Nullable String sFlag); 46 47 /** 48 * Get the error level associated with a single failed assertion. 49 * 50 * @param aFailedAssert 51 * The failed assert to be queried. May not be <code>null</code>. 52 * @return The error level and never <code>null</code>. 53 */ 54 @Nonnull 55 default IErrorLevel getErrorLevelFromFailedAssert (@Nonnull final FailedAssert aFailedAssert) 56 { 57 ValueEnforcer.notNull (aFailedAssert, "FailedAssert"); 58 59 return getErrorLevelFromFlag (aFailedAssert.getFlag ()); 60 } 61 62 /** 63 * Get the error level associated with a single successful report. 64 * 65 * @param aSuccessfulReport 66 * The failed assert to be queried. May not be <code>null</code>. 67 * @return The error level and never <code>null</code>. 68 */ 69 @Nonnull 70 default IErrorLevel getErrorLevelFromSuccessfulReport (@Nonnull final SuccessfulReport aSuccessfulReport) 71 { 72 ValueEnforcer.notNull (aSuccessfulReport, "SuccessfulReport"); 73 74 return getErrorLevelFromFlag (aSuccessfulReport.getFlag ()); 75 } 76 }