org.inria.ns.reflex.util
Interface EntryFactory

All Superinterfaces:
EntryBuilder
All Known Implementing Classes:
EntryFactory.Impl

public interface EntryFactory
extends EntryBuilder

An entry factory can build entries requested for the first time from a deferred map.

An instance of this class encapsulates the logic for building the set of entries in a predictable way.

Author:
Philippe Poulard
See Also:
DeferredMap

Nested Class Summary
static class EntryFactory.Impl
          A partial implementation of an entry factory.
 
Method Summary
 boolean containsKey(Object key)
          Indicates whether the entry with the key given exists or not.
 Map.Entry getEntry(Object key)
          Build the entry that has the given key.
 Set getKeys()
          Return the set of keys.
 boolean hasRemovableEntries()
          Indicates whether some entries built by this factory can be removed or not.
 boolean hasUpdatableEntries()
          Indicates whether some entries built by this factory can be updated or not.
 Map.Entry newEntry(Object key, Object value)
          Create a new entry that has the given key and the given value.
 

Method Detail

getEntry

Map.Entry getEntry(Object key)
Build the entry that has the given key.

Parameters:
key - The entry key.
Returns:
The entry, or null.

newEntry

Map.Entry newEntry(Object key,
                   Object value)
                   throws UnsupportedOperationException
Create a new entry that has the given key and the given value.

This method is for creating entries that are not known by this factory (as a fallback).

It is different from getEntry() that supplies an entry that the factory can build with a specific recipe. On the opposite, this method just supply a { key, value } pair stored in an entry. For consistency, this is not done directly by the client deferred map to allow the factory to build an instance of the right class.

Specified by:
newEntry in interface EntryBuilder
Parameters:
key - The key of the entry.
value - The value of the entry.
Returns:
The entry.
Throws:
UnsupportedOperationException - When this factory doesn't allow the creation of new entries.

getKeys

Set getKeys()
Return the set of keys.

Returns:
The non-null set of keys.

containsKey

boolean containsKey(Object key)
Indicates whether the entry with the key given exists or not.

Parameters:
key - The key of the entry.
Returns:
true if there is an entry with the key given, false otherwise.

hasRemovableEntries

boolean hasRemovableEntries()
Indicates whether some entries built by this factory can be removed or not.

If the entry set is a static set, then this method should return false. If the factory doesn't know if some of its entries are removable, then this method should return true.

true implies that all entries to remove will be built by the factory in order to call their remove() method. false can preserve from this behaviour.

Returns:
false it all the entries are reputed static, true otherwise.

hasUpdatableEntries

boolean hasUpdatableEntries()
Indicates whether some entries built by this factory can be updated or not.

If all the entry values are not updatable, then this method should return false. If the factory doesn't know if some of its entry values are updatable, then this method should return true.

true implies that all entries to update will be built by the factory in order to call their setValue() method. false can preserve from this behaviour.

Returns:
false it all the entry values are reputed non-updatable, true otherwise.