Package model.handler
Class RoutesHandler
java.lang.Object
model.handler.RoutesHandler
- All Implemented Interfaces:
ObservableListener<Route>
,CollectionHandler<HashSet<Route>,
Route>
public class RoutesHandler
extends Object
implements CollectionHandler<HashSet<Route>,Route>, ObservableListener<Route>
Current implementation of CollectionsHandler for HashSet of Route.
- Since:
- 1.0
- Author:
- Zerumi
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollectionListener
(CollectionUpdateListener<Route> listener) Registers new listener for some collection operations.void
Adds element to collection.Returns actual collection reference.Returns first element of collection.Provides method for get collection initDate.static RoutesHandler
Singletone moment.Returns last element of collection.getMax
(Comparator<Route> comparator) Gets max element by given comparatorgetMin
(Comparator<Route> comparator) Gets min element by given comparatorProvides method for getting sorted variant of collection.void
listenAdd
(Collection<? extends Route> addedElements) void
listenRemove
(Collection<?> removedObjects) void
setCollection
(HashSet<Route> routes) Overrides current collection by provided value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface model.handler.CollectionHandler
sort
-
Method Details
-
getInstance
Singletone moment.- Returns:
- Single instance of handler.
-
getCollection
Returns actual collection reference.- Specified by:
getCollection
in interfaceCollectionHandler<HashSet<Route>,
Route> - Returns:
- Current collection
-
setCollection
Overrides current collection by provided value.- Specified by:
setCollection
in interfaceCollectionHandler<HashSet<Route>,
Route> - Parameters:
routes
- Collection
-
addElementToCollection
Adds element to collection.- Specified by:
addElementToCollection
in interfaceCollectionHandler<HashSet<Route>,
Route> - Parameters:
e
- Element to add
-
getSorted
Description copied from interface:CollectionHandler
Provides method for getting sorted variant of collection.- Specified by:
getSorted
in interfaceCollectionHandler<HashSet<Route>,
Route> - Returns:
- sorted collection
-
getFirstOrNew
Returns first element of collection.- Specified by:
getFirstOrNew
in interfaceCollectionHandler<HashSet<Route>,
Route> - Returns:
- First element of collection. If collection is empty, returns new object.
-
getInitDate
Description copied from interface:CollectionHandler
Provides method for get collection initDate.- Specified by:
getInitDate
in interfaceCollectionHandler<HashSet<Route>,
Route> - Returns:
- Date instance -- Collection created time.
- See Also:
-
getLastElement
Returns last element of collection.- Specified by:
getLastElement
in interfaceCollectionHandler<HashSet<Route>,
Route> - Returns:
- Last element of collection of null if collection is empty
-
getMin
Gets min element by given comparator- Specified by:
getMin
in interfaceCollectionHandler<HashSet<Route>,
Route> - Parameters:
comparator
- Comparator to compare.- Returns:
- Min element or null if collection is empty
-
getMax
Gets max element by given comparator- Specified by:
getMax
in interfaceCollectionHandler<HashSet<Route>,
Route> - Parameters:
comparator
- Comparator to compare.- Returns:
- Max element or null if collection is empty
-
addCollectionListener
Description copied from interface:CollectionHandler
Registers new listener for some collection operations.- Specified by:
addCollectionListener
in interfaceCollectionHandler<HashSet<Route>,
Route> - Parameters:
listener
- Listener
-
listenAdd
- Specified by:
listenAdd
in interfaceObservableListener<Route>
-
listenRemove
- Specified by:
listenRemove
in interfaceObservableListener<Route>
-
getListeners
-