Class FactoryCache

    • Constructor Detail

      • FactoryCache

        public FactoryCache()
    • Method Detail

      • put

        public <T> void put​(Class<?> type,
                            PrefabValueFactory<T> factory)
        Adds the given factory to the cache and associates it with the given type.
        Type Parameters:
        T - The type of the factory.
        Parameters:
        type - The type to associate with the factory.
        factory - The factory to associate with the type.
      • put

        public <T> void put​(String typeName,
                            PrefabValueFactory<T> factory)
        Adds the given factory to the cache and associates it with the given type name.
        Type Parameters:
        T - Should match typeName.
        Parameters:
        typeName - The fully qualified name of the type.
        factory - The factory to associate with typeName
      • get

        public <T> PrefabValueFactory<T> get​(Class<T> type)
        Retrieves the factory from the cache for the given type.

        What happens when there is no factory, is undefined. Always call contains(Class) first.

        Type Parameters:
        T - The returned factory will have this as generic type.
        Parameters:
        type - The type for which a factory is needed.
        Returns:
        A factory for the given type, or null if none is available.
      • contains

        public boolean contains​(Class<?> type)
        Parameters:
        type - The type for which a factory is needed.
        Returns:
        Whether a factory is available for the given type.
      • merge

        public FactoryCache merge​(FactoryCache other)
        Returns a new FactoryCache instance containing the factories from this and from the other cache.
        Parameters:
        other - The other cache
        Returns:
        a new instance containing factories from this and other