Interface MaterialIterator
- All Known Implementing Classes:
MaterialTypeIterator,PriceRangeIterator,PriceSortedIterator
public interface MaterialIterator
Iterator interface for traversing collections of materials.
Provides a uniform way to iterate over materials with different traversal strategies.
This interface demonstrates the Iterator pattern by encapsulating traversal logic and allowing different iteration strategies to be implemented.
- Since:
- 2024-09-15
- Version:
- 3.0
- Author:
- Navid Mohaghegh
-
Method Summary
Modifier and TypeMethodDescriptionintGets the current position in the iteration.intGets the number of materials remaining to be iterated.intGets the total number of materials that can be iterated.booleanhasNext()Checks if there are more materials to iterate over.booleanChecks if the iterator is at the beginning.booleanisAtEnd()Checks if the iterator is at the end.next()Gets the next material in the iteration.voidreset()Resets the iterator to the beginning.
-
Method Details
-
hasNext
boolean hasNext()Checks if there are more materials to iterate over.- Returns:
- true if there are more materials
-
next
Material next()Gets the next material in the iteration.- Returns:
- the next material
- Throws:
NoSuchElementException- if there are no more materials
-
reset
void reset()Resets the iterator to the beginning. -
getCurrentPosition
int getCurrentPosition()Gets the current position in the iteration.- Returns:
- the current position (0-based)
-
getTotalCount
int getTotalCount()Gets the total number of materials that can be iterated.- Returns:
- the total count
-
getRemainingCount
int getRemainingCount()Gets the number of materials remaining to be iterated.- Returns:
- the remaining count
-
isAtBeginning
boolean isAtBeginning()Checks if the iterator is at the beginning.- Returns:
- true if at the beginning
-
isAtEnd
boolean isAtEnd()Checks if the iterator is at the end.- Returns:
- true if at the end
-