Class ICUService.SimpleFactory

  • All Implemented Interfaces:
    ICUService.Factory
    Enclosing class:
    ICUService

    public static class ICUService.SimpleFactory
    extends java.lang.Object
    implements ICUService.Factory
    A default implementation of factory. This provides default implementations for subclasses, and implements a singleton factory that matches a single id and returns a single (possibly deferred-initialized) instance. This implements updateVisibleIDs to add a mapping from its ID to itself if visible is true, or to remove any existing mapping for its ID if visible is false.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String id  
      protected java.lang.Object instance  
      protected boolean visible  
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleFactory​(java.lang.Object instance, java.lang.String id)
      Convenience constructor that calls SimpleFactory(Object, String, boolean) with visible true.
      SimpleFactory​(java.lang.Object instance, java.lang.String id, boolean visible)
      Construct a simple factory that maps a single id to a single service instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object create​(ICUService.Key key, ICUService service)
      Return the service instance if the factory's id is equal to the key's currentID.
      java.lang.String getDisplayName​(java.lang.String identifier, ULocale locale)
      If this.id equals id, returns id regardless of locale, otherwise returns null.
      java.lang.String toString()
      For debugging.
      void updateVisibleIDs​(java.util.Map<java.lang.String,​ICUService.Factory> result)
      If visible, adds a mapping from id -> this to the result, otherwise removes id from result.
      • Methods inherited from class java.lang.Object

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

      • instance

        protected java.lang.Object instance
      • id

        protected java.lang.String id
      • visible

        protected boolean visible
    • Constructor Detail

      • SimpleFactory

        public SimpleFactory​(java.lang.Object instance,
                             java.lang.String id)
        Convenience constructor that calls SimpleFactory(Object, String, boolean) with visible true.
      • SimpleFactory

        public SimpleFactory​(java.lang.Object instance,
                             java.lang.String id,
                             boolean visible)
        Construct a simple factory that maps a single id to a single service instance. If visible is true, the id will be visible. Neither the instance nor the id can be null.
    • Method Detail

      • create

        public java.lang.Object create​(ICUService.Key key,
                                       ICUService service)
        Return the service instance if the factory's id is equal to the key's currentID. Service is ignored.
        Specified by:
        create in interface ICUService.Factory
      • updateVisibleIDs

        public void updateVisibleIDs​(java.util.Map<java.lang.String,​ICUService.Factory> result)
        If visible, adds a mapping from id -> this to the result, otherwise removes id from result.
        Specified by:
        updateVisibleIDs in interface ICUService.Factory
      • getDisplayName

        public java.lang.String getDisplayName​(java.lang.String identifier,
                                               ULocale locale)
        If this.id equals id, returns id regardless of locale, otherwise returns null. (This default implementation has no localized id information.)
        Specified by:
        getDisplayName in interface ICUService.Factory
      • toString

        public java.lang.String toString()
        For debugging.
        Overrides:
        toString in class java.lang.Object