Class AttributeClassHelper


  • public class AttributeClassHelper
    extends Object
    Helper for handling AttributesClasses of an entity. A single virtual 'class' is created from the classes provided as arguments. With it checking of attributes is fast.

    Additionally static utility methods are provided allowing to clean up the duplicated entries in ACs.

    Author:
    K. Benedyczak
    • Field Detail

    • Constructor Detail

      • AttributeClassHelper

        public AttributeClassHelper()
      • AttributeClassHelper

        public AttributeClassHelper​(Map<String,​pl.edu.icm.unity.types.basic.AttributesClass> knownClasses,
                                    Collection<String> assignedClasses)
    • Method Detail

      • cleanupClass

        public static void cleanupClass​(pl.edu.icm.unity.types.basic.AttributesClass toCleanup,
                                        Map<String,​pl.edu.icm.unity.types.basic.AttributesClass> knownClasses)
                                 throws pl.edu.icm.unity.exceptions.IllegalTypeException
        All parents which are also parents of other existing parents are removed. All allowed/mandatory attributes which are allowed/required by parent classes are removed.
        Parameters:
        knownClasses -
        toCleanup -
        Throws:
        pl.edu.icm.unity.exceptions.IllegalTypeException
      • isRestricting

        public boolean isRestricting​(AttributeClassHelper original)
        Parameters:
        original -
        Returns:
        true only if the this effective class is more restrictive then the given argument, i.e. it has more mandatory attributes or less allowed.
      • checkAttribtues

        public void checkAttribtues​(Collection<String> attributes,
                                    Map<String,​pl.edu.icm.unity.types.basic.AttributeType> allTypes)
                             throws pl.edu.icm.unity.exceptions.SchemaConsistencyException
        Verifies if the given attribute set is consistent with the effective AC
        Parameters:
        attributes -
        allTypes - if not null, then it is used skip checking of attribute allowance in case of system attributes (i.e. those with instances immutable flag).
        Throws:
        pl.edu.icm.unity.exceptions.SchemaConsistencyException
      • isAllowed

        public boolean isAllowed​(String attribute)
      • isMandatory

        public boolean isMandatory​(String attribute)
      • getEffectiveAllowed

        public Set<String> getEffectiveAllowed()
      • getEffectiveMandatory

        public Set<String> getEffectiveMandatory()
      • isEffectiveAllowArbitrary

        public boolean isEffectiveAllowArbitrary()