Class IdentifiedObjectSet<T extends IdentifiedObject>

    • Field Detail

      • factory

        protected final AuthorityFactory factory
        The factory to use for creating Identified­Objects when first needed. This is the authority factory given at construction time.
    • Constructor Detail

      • IdentifiedObjectSet

        public IdentifiedObjectSet​(AuthorityFactory factory,
                                   Class<T> type)
        Creates an initially empty set. The set can be populated after construction by calls to add­Authority­Code(String) for deferred Identified­Object creation, or to add(Identified­Object) for already instantiated objects.
        factory - the factory to use for deferred Identified­Object instances creation.
        type - the type of objects included in this set.
    • Method Detail

      • getLocale

        public Locale getLocale()
        Returns the locale to use for error messages and warnings. The default implementation inherits the factory locale, if any.
        Specified by:
        get­Locale in interface Localized
        the locale, or null if not explicitly defined.
      • getAuthorityCodes

        public String[] getAuthorityCodes()
        Returns the authority codes of all Identified­Objects contained in this collection, in insertion order. This method does not trig the creation of any object.
        the authority codes in iteration order.
      • setAuthorityCodes

        public void setAuthorityCodes​(String... codes)
        Sets the content of this collection to the object identified by the given codes. For any code in the given sequence, this method will preserve the corresponding Identified­Object instance if it was already created. Otherwise objects will be created only when first needed.
        Purpose: this method is typically used together with get­Authority­Codes() for altering the iteration order on the basis of authority codes. If the specified codes sequence contains the same elements than the ones in the array returned by get­Authority­Codes() but in a different order, then this method just sets the new ordering.
        codes - the authority codes of identified objects to store in this set.
        See Also:
      • addAuthorityCode

        public void addAuthorityCode​(String code)
        Ensures that this collection contains an object for the specified authority code. If this collection does not contain any element for the given code, then this method will instantiate an Identified­Object for the given code only when first needed. Otherwise this collection is unchanged.
        code - the code authority code of the Identified­Object to include in this set.
      • resolve

        public void resolve​(int n)
                     throws FactoryException
        Ensures that the n first objects in this set are created. This method can be invoked for making sure that the underlying factory is really capable to create at least one object. Factory­Exception (except the ones accepted as recoverable failures) are thrown as if they were never wrapped into Backing­Store­Exception.
        n - the number of object to resolve. If this number is equals or greater than size(), then this method ensures that all Identified­Object instances in this collection are created.
        Factory­Exception - if an object creation failed.
      • getAuthorityCode

        protected String getAuthorityCode​(T object)
        Returns the identifier for the specified object. The default implementation takes the first of the following identifier which is found:
        1. An identifier allocated by the authority given by factory.get­Authority().
        2. The first object identifier, regardless its authority.
        3. The first object name, regardless its authority.
        Subclasses may override this method if they want to use a different identifiers.
        object - the object for which to get the authority code.
        the authority code of the given identified object.
      • createObject

        protected T createObject​(String code)
                          throws FactoryException
        Creates an object for the specified authority code. This method is invoked during the iteration process if an object was not already created.
        code - the code for which to create the identified object.
        the identified object created from the given code.
        Factory­Exception - if the object creation failed.
      • isRecoverableFailure

        protected boolean isRecoverableFailure​(FactoryException exception)
        Returns true if the specified exception should be handled as a recoverable failure. This method is invoked during the iteration process if the factory failed to create some objects. If this method returns true for the given exception, then the exception will be logged at Level​.WARNING. If this method returns false, then the exception will be re-thrown as a Backing­Store­Exception.

        The default implementation applies the following rules:

        exception - the exception that occurred while creating an object.
        true if the given exception should be considered recoverable, or false if it should be considered fatal.