Skip to content

Commit

Permalink
Added class ValidityDeterminatorRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Dec 5, 2024
1 parent 188c109 commit 58d99e3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ Please ensure that your stack size is at least 1MB (for Saxon). Using the Oracle

* v10.0.4 - work in progress
* Added new interface `IValidationExecutorSetMutable`
* Added new class `ValidationExecutorSetAlias`
* Added new class `ValidationExecutorSetAlias` to be able to proxy existing VES with different coordinates
* Added new class `ValidityDeterminatorRegistry` to support validity determination processes
* v10.0.3 - 2024-12-01
* Added default XML serialization of validation results
* Added new `EValidationBaseType` entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public interface IValidityDeterminator <SOURCETYPE extends IValidationSource>
/**
* @return A validity determinator that marks entries with at least one error
* as INVALID and others as VALID. It contains no uncertainty.
* @see ValidityDeterminatorRegistry#getValidityOneErrorInvalid(IErrorList)
*/
static <ST extends IValidationSource> IValidityDeterminator <ST> createCertainOneErrorInvalid ()
{
return (ex, errList) -> errList.containsAtLeastOneError () ? EExtendedValidity.INVALID : EExtendedValidity.VALID;
return (vex, errList) -> ValidityDeterminatorRegistry.getValidityOneErrorInvalid (errList);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2014-2024 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.phive.api.validity;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.error.list.IErrorList;

/**
* Helper class for validity determination implementations
*
* @author Philip Helger
* @since 10.0.4
*/
@Immutable
public final class ValidityDeterminatorRegistry
{
private ValidityDeterminatorRegistry ()
{}

/**
* Calculate the validity of an error list like this: if at least one entry of
* error level "error" or more severe is contained, the overall validity is
* invalid.
*
* @param aErrorList
* The error list to scan. May not be <code>null</code>.
* @return Never <code>null</code>.
*/
@Nonnull
public static EExtendedValidity getValidityOneErrorInvalid (@Nonnull final IErrorList aErrorList)
{
ValueEnforcer.notNull (aErrorList, "ErrorList");
return aErrorList.containsAtLeastOneError () ? EExtendedValidity.INVALID : EExtendedValidity.VALID;
}
}

0 comments on commit 58d99e3

Please sign in to comment.