Class AttributeClassHelper


  • public class AttributeClassHelper
    extends java.lang.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
    • Constructor Summary

      Constructors 
      Constructor Description
      AttributeClassHelper()  
      AttributeClassHelper​(java.util.Map<java.lang.String,​pl.edu.icm.unity.types.basic.AttributesClass> knownClasses, java.util.Collection<java.lang.String> assignedClasses)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkAttribtues​(java.util.Collection<java.lang.String> attributes, java.util.Map<java.lang.String,​pl.edu.icm.unity.types.basic.AttributeType> allTypes)
      Verifies if the given attribute set is consistent with the effective AC
      static void cleanupClass​(pl.edu.icm.unity.types.basic.AttributesClass toCleanup, java.util.Map<java.lang.String,​pl.edu.icm.unity.types.basic.AttributesClass> knownClasses)
      All parents which are also parents of other existing parents are removed.
      java.util.Set<java.lang.String> getEffectiveAllowed()  
      java.util.Set<java.lang.String> getEffectiveMandatory()  
      boolean isAllowed​(java.lang.String attribute)  
      boolean isEffectiveAllowArbitrary()  
      boolean isMandatory​(java.lang.String attribute)  
      boolean isRestricting​(AttributeClassHelper original)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • AttributeClassHelper

        public AttributeClassHelper()
      • AttributeClassHelper

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

      • cleanupClass

        public static void cleanupClass​(pl.edu.icm.unity.types.basic.AttributesClass toCleanup,
                                        java.util.Map<java.lang.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​(java.util.Collection<java.lang.String> attributes,
                                    java.util.Map<java.lang.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​(java.lang.String attribute)
      • isMandatory

        public boolean isMandatory​(java.lang.String attribute)
      • getEffectiveAllowed

        public java.util.Set<java.lang.String> getEffectiveAllowed()
      • getEffectiveMandatory

        public java.util.Set<java.lang.String> getEffectiveMandatory()
      • isEffectiveAllowArbitrary

        public boolean isEffectiveAllowArbitrary()