Class TypeFilterImpl

  • All Implemented Interfaces:
    TypeFilter, com.nomagic.magicdraw.ui.ElementFilter

    @OpenApiAll
    public class TypeFilterImpl
    extends java.lang.Object
    implements TypeFilter
    Default TypeFilter implementation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.nomagic.magicdraw.ui.RestrictedElementFilter filter  
      private java.util.Collection<?> types
      Acceptable types.
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeFilterImpl()
      Constructor.
      TypeFilterImpl​(java.util.Collection<?> types)
      Constructor.
      TypeFilterImpl​(java.util.Collection all, java.util.Collection restricted)
      An utility constructor for compatibility with old approach when all and restricted types were used.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(BaseElement obj)  
      boolean accept​(BaseElement baseElement, boolean checkType)
      Tests element to satisfy filter condition.
      protected boolean acceptByType​(java.util.Collection<?> types, BaseElement baseElement)
      Test for acceptable element type.
      java.util.Collection<?> getTypes()
      Get the acceptable element types.
      • Methods inherited from class java.lang.Object

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

      • types

        @CheckForNull
        private java.util.Collection<?> types
        Acceptable types.
      • filter

        private com.nomagic.magicdraw.ui.RestrictedElementFilter filter
    • Constructor Detail

      • TypeFilterImpl

        public TypeFilterImpl()
        Constructor. Any element will be accepted
      • TypeFilterImpl

        public TypeFilterImpl​(@CheckForNull
                              java.util.Collection<?> types)
        Constructor.
        Parameters:
        types - acceptable types. Can be null.
      • TypeFilterImpl

        public TypeFilterImpl​(@CheckForNull
                              java.util.Collection all,
                              @CheckForNull
                              java.util.Collection restricted)
        An utility constructor for compatibility with old approach when all and restricted types were used. It uses "restricted" types if they are not null, otherwise "all" types are used.
        Parameters:
        all - all types
        restricted - restricted types.
    • Method Detail

      • getTypes

        public java.util.Collection<?> getTypes()
        Description copied from interface: TypeFilter
        Get the acceptable element types.
        Specified by:
        getTypes in interface TypeFilter
        Returns:
        acceptable element types. If null - all element types are accepted.
      • accept

        public final boolean accept​(BaseElement obj)
        Specified by:
        accept in interface com.nomagic.magicdraw.ui.ElementFilter
      • accept

        public boolean accept​(BaseElement baseElement,
                              boolean checkType)
        Description copied from interface: TypeFilter
        Tests element to satisfy filter condition.
        Specified by:
        accept in interface TypeFilter
        Parameters:
        baseElement - element.
        checkType - check object type
        Returns:
        true if obj satisfies filter condition otherwise false.
      • acceptByType

        protected boolean acceptByType​(@CheckForNull
                                       java.util.Collection<?> types,
                                       @Nonnull
                                       BaseElement baseElement)
        Test for acceptable element type.
        Parameters:
        types - acceptable types. Null means ANY type
        baseElement - element to be tested. Can not be null.
        Returns:
        true if tested element is acceptable.