Class TLcyGenericComposite<T>

java.lang.Object
com.luciad.lucy.util.TLcyGenericComposite<T>
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
TLcyCompositeAsynchronousPaintHintProvider, TLcyCompositeBalloonContentProvider, TLcyCompositeCameraLinkerFactory, TLcyCompositeCustomizerPanelFactory, TLcyCompositeGXYLayerDecoder, TLcyCompositeGXYLayerEncoder, TLcyCompositeGXYLayerFactory, TLcyCompositeGXYLayerTypeProvider, TLcyCompositeHyperlinkListener, TLcyCompositeInputStreamFactory, TLcyCompositeLayerHeightProviderFactory, TLcyCompositeLayerMeasureProviderFactory, TLcyCompositeLayerStyleCodec, TLcyCompositeLayerStyleProvider, TLcyCompositeModelContentTypeProvider, TLcyCompositeModelDecoder, TLcyCompositeModelEncoder, TLcyCompositeModelFactory, TLcyCompositeModelHeightProviderFactory, TLcyCompositeModelMeasureProviderFactory, TLcyCompositeModelReferenceDecoder, TLcyCompositeModelReferenceParser, TLcyCompositeOutputStreamFactory, TLcyCompositeOWSTransport, TLcyCompositeSimulatorModelFactory, TLcyGXYCompositeLabelPlacementHintProvider, TLcyLspCompositeLayerFactory

public class TLcyGenericComposite<T> extends Object implements Iterable<T>

A composite implementation of T according to the composite design pattern.

When creating a TLcyGenericComposite<T> using the default constructor (see TLcyGenericComposite(), the created instance will only work on/with the instances of T registered on this composite instance (see add(Object) and remove(Object)).

When creating a new TLcyGenericComposite<T> using the constructor specifying an ILcyLucyEnv instance (see TLcyGenericComposite(com.luciad.lucy.ILcyLucyEnv, Class), the created instance will work on the Lucy back-end services. It will use all registered instances of T of the Lucy back-end, adding and/or removing an instance of T will add/remove the instance as service from Lucy, ... .

Since:
10.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Constant defining the normal priority.
    static final int
    Constant defining the fallback priority.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    TLcyGenericComposite(ILcyLucyEnv aLucyEnv, Class<T> aServiceClass)
    Construct a TLcyGenericComposite working on the Lucy back-end.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T aService)
    Adds the given instance of T to the list of registered instances.
    void
    add(T aService, int aPriority)
    Adds the given instance of T to the list of registered instances with the given priority.
    Returns an unmodifiable List containing all registered instances of T.
    int
    getPriority(int aIndex)
    Returns the priority for the service at the specified index
    void
    remove(T aService)
    Removes the given instance of T to the list of registered instances.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • PRIORITY_DEFAULT

      public static final int PRIORITY_DEFAULT

      Constant defining the normal priority. Services added with this priority constant have a higher priority than services added with the PRIORITY_FALLBACK constant. Its value is the same as ILcyLucyEnv.PRIORITY_DEFAULT.

      See Also:
    • PRIORITY_FALLBACK

      public static final int PRIORITY_FALLBACK

      Constant defining the fallback priority. Services added with this priority constant have a lower priority than services added with the PRIORITY_NORMAL constant. Its value is the same as ILcyLucyEnv.PRIORITY_FALLBACK.

      See Also:
  • Constructor Details

    • TLcyGenericComposite

      public TLcyGenericComposite()

      Default constructor.

      The created instance will only work on the instances of T registered to it. If you want to use all registered instances of T of the Lucy back-end, use TLcyGenericComposite(com.luciad.lucy.ILcyLucyEnv, Class) instead.

      See Also:
    • TLcyGenericComposite

      public TLcyGenericComposite(ILcyLucyEnv aLucyEnv, Class<T> aServiceClass)

      Construct a TLcyGenericComposite working on the Lucy back-end.

      It will use all instances of T registered to the back-end, and adding an/or removing instances of T to/from this TLcyGenericComposite will respectively add/remove it as service from the back-end.

      If you want to create a TLcyGenericComposite which does not use the back-end, use TLcyGenericComposite() instead.

      Parameters:
      aLucyEnv - The Lucy back-end. When null, calling this constructor is equivalent to calling the default constructor TLcyGenericComposite().
      aServiceClass - The class of the service that this composite will manage. E.g. if you add an object implementing T and another interface, it will only be registered as a service of class T and not for the other interface.
  • Method Details

    • add

      public void add(T aService)

      Adds the given instance of T to the list of registered instances.

      Equivalent of calling add(Object, int) with PRIORITY_DEFAULT

      Parameters:
      aService - The instance to add.
      See Also:
    • add

      public void add(T aService, int aPriority)

      Adds the given instance of T to the list of registered instances with the given priority. A single instance can only have one priority at a time, so it cannot be added twice with two different priorities.

      If the constructor specifying an ILcyLucyEnv is used, the instance of T will be registered as a service on the Lucy back-end (see ILcyLucyEnv.addService(Object)). When calling ILcyLucyEnv.getServices(Class) afterwards, aService will only be included in the returned list when the requested class was the class specified in the constructor.
      Note: if you want to remove the registered instance of T afterwards, use remove(Object) and not ILcyLucyEnv.removeService(Object).

      Parameters:
      aService - The instance to add.
      aPriority - The priority for the instance. Lower values mean higher priorities. Services with higher priority appear earlier in the list of results. Common values are PRIORITY_DEFAULT and PRIORITY_FALLBACK
    • remove

      public void remove(T aService)

      Removes the given instance of T to the list of registered instances. Nothing will happen if the given instance was never added before.

      If the constructor specifying an ILcyLucyEnv is used, the instance of T will be removed as a service on the Lucy back-end (see ILcyLucyEnv.addService(Object)).
      Note: it is only possible to remove instances of T which were registered using the add(Object) method.

      Parameters:
      aService - The instance to add.
      See Also:
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      iterator over the elements in this composite.
    • getList

      public List<T> getList()

      Returns an unmodifiable List containing all registered instances of T.

      Returns:
      an unmodifiable List containing all registered instances of T.
    • getPriority

      public int getPriority(int aIndex)
      Returns the priority for the service at the specified index
      Parameters:
      aIndex - The index of the service for which the priority should be returned.
      Returns:
      The priority for the service at the specified index