Package org.cache2k.config
Class SectionContainer
- java.lang.Object
-
- java.util.AbstractCollection<ConfigSection<?,?>>
-
- org.cache2k.config.SectionContainer
-
- All Implemented Interfaces:
Iterable<ConfigSection<?,?>>
,Collection<ConfigSection<?,?>>
public class SectionContainer extends AbstractCollection<ConfigSection<?,?>> implements Collection<ConfigSection<?,?>>
Container for configuration objects. The container preserves the order of the sections and checks that one type is only added once.- Author:
- Jens Wilke
- See Also:
ConfigWithSections
-
-
Constructor Summary
Constructors Constructor Description SectionContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(ConfigSection<?,?> section)
Add a new configuration section to the container.<T extends ConfigSection<T,?>>
TgetSection(Class<T> sectionType)
<T extends ConfigSection<T,?>>
TgetSection(Class<T> sectionType, T defaultFallback)
Retrieve a single section from the container.Iterator<ConfigSection<?,?>>
iterator()
int
size()
String
toString()
-
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
add
public boolean add(ConfigSection<?,?> section)
Add a new configuration section to the container.- Specified by:
add
in interfaceCollection<ConfigSection<?,?>>
- Overrides:
add
in classAbstractCollection<ConfigSection<?,?>>
- Returns:
- always
true
- Throws:
IllegalArgumentException
- if same type is already present and a singleton
-
getSection
public <T extends ConfigSection<T,?>> T getSection(Class<T> sectionType, T defaultFallback)
Retrieve a single section from the container.
-
getSection
@Nullable public <T extends ConfigSection<T,?>> T getSection(Class<T> sectionType)
-
iterator
public Iterator<ConfigSection<?,?>> iterator()
- Specified by:
iterator
in interfaceCollection<ConfigSection<?,?>>
- Specified by:
iterator
in interfaceIterable<ConfigSection<?,?>>
- Specified by:
iterator
in classAbstractCollection<ConfigSection<?,?>>
-
size
public int size()
- Specified by:
size
in interfaceCollection<ConfigSection<?,?>>
- Specified by:
size
in classAbstractCollection<ConfigSection<?,?>>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<ConfigSection<?,?>>
-
-