Class CookieSet


  • @OpenApi
    public final class CookieSet
    extends java.lang.Object
    Support class for storing cookies and retrieving them by representation class.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  com.nomagic.magicdraw.cookies.CookieSet.CookieEntry
      Entry for one Cookie
      static interface  com.nomagic.magicdraw.cookies.CookieSet.Factory
      Factory for creating cookies of given Class
      private static class  com.nomagic.magicdraw.cookies.CookieSet.R
      Implementation of the result.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.event.EventListenerList listeners
      set of listeners
      private java.util.HashMap<java.lang.Class,​com.nomagic.magicdraw.cookies.CookieSet.R> map
      list of cookies (Class, Node.Cookie)
    • Constructor Summary

      Constructors 
      Constructor Description
      CookieSet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Cookie cookie)
      Add a new cookie to the set.
      void add​(java.lang.Class[] cookieClasses, com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
      Registers a Factory for given cookie classes
      void add​(java.lang.Class cookieClass, com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
      Registers a Factory for given cookie class
      void addChangeListener​(javax.swing.event.ChangeListener l)
      Add a listener to changes in the cookie set.
      private com.nomagic.magicdraw.cookies.CookieSet.R findR​(java.lang.Class c)
      Finds a result in a map.
      private void fireChangeEvent()
      Fires change event
      Cookie getCookie​(java.lang.Class clazz)
      Get a cookie.
      private void registerCookie​(java.lang.Class c, Cookie cookie)
      Attaches cookie to given class and all its superclasses and superinterfaces.
      void remove​(Cookie cookie)
      Remove a cookie from the set.
      void remove​(java.lang.Class[] cookieClasses, com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
      Unregisters a Factory for given cookie classes
      void remove​(java.lang.Class cookieClass, com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
      Unregisters a Factory for given cookie class
      void removeChangeListener​(javax.swing.event.ChangeListener l)
      Remove a listener to changes in the cookie set.
      private void unregisterCookie​(java.lang.Class c, Cookie cookie)
      Removes cookie from the class and all its superclasses and superinterfaces.
      • Methods inherited from class java.lang.Object

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

      • map

        private final java.util.HashMap<java.lang.Class,​com.nomagic.magicdraw.cookies.CookieSet.R> map
        list of cookies (Class, Node.Cookie)
      • listeners

        private final javax.swing.event.EventListenerList listeners
        set of listeners
    • Constructor Detail

      • CookieSet

        public CookieSet()
    • Method Detail

      • add

        @OpenApi
        public void add​(Cookie cookie)
        Add a new cookie to the set. If a cookie of the same actual (not representation!) class is already there, it is replaced.

        Cookies inserted earlier are given preference during lookup, in case a supplied representation class matches more than one cookie in the set.

        Parameters:
        cookie - cookie to add
      • remove

        @OpenApi
        public void remove​(Cookie cookie)
        Remove a cookie from the set.
        Parameters:
        cookie - the cookie to remove
      • getCookie

        @CheckForNull
        @OpenApi
        public Cookie getCookie​(java.lang.Class clazz)
        Get a cookie.
        Parameters:
        clazz - the representation class
        Returns:
        a cookie assignable to the representation class, or null if there is none
      • addChangeListener

        public void addChangeListener​(javax.swing.event.ChangeListener l)
        Add a listener to changes in the cookie set.
        Parameters:
        l - the listener to add
      • removeChangeListener

        public void removeChangeListener​(javax.swing.event.ChangeListener l)
        Remove a listener to changes in the cookie set.
        Parameters:
        l - the listener to remove
      • fireChangeEvent

        private void fireChangeEvent()
        Fires change event
      • registerCookie

        private void registerCookie​(java.lang.Class c,
                                    Cookie cookie)
        Attaches cookie to given class and all its superclasses and superinterfaces.
        Parameters:
        c - class or null
        cookie - cookie to attach
      • unregisterCookie

        private void unregisterCookie​(java.lang.Class c,
                                      Cookie cookie)
        Removes cookie from the class and all its superclasses and superinterfaces.
        Parameters:
        c - class or null
        cookie - cookie to attach
      • add

        public void add​(java.lang.Class cookieClass,
                        com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
        Registers a Factory for given cookie class
      • add

        public void add​(java.lang.Class[] cookieClasses,
                        com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
        Registers a Factory for given cookie classes
      • remove

        public void remove​(java.lang.Class cookieClass,
                           com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
        Unregisters a Factory for given cookie class
        Since:
        2.6
      • remove

        public void remove​(java.lang.Class[] cookieClasses,
                           com.nomagic.magicdraw.cookies.CookieSet.Factory factory)
        Unregisters a Factory for given cookie classes
        Since:
        2.6
      • findR

        private com.nomagic.magicdraw.cookies.CookieSet.R findR​(java.lang.Class c)
        Finds a result in a map.