Class UniqueResultStructure<R>
java.lang.Object
org.faktorips.runtime.internal.tableindex.SearchStructure<R>
org.faktorips.runtime.internal.tableindex.UniqueResultStructure<R>
- All Implemented Interfaces:
MergeAndCopyStructure<UniqueResultStructure<R>>
public class UniqueResultStructure<R>
extends SearchStructure<R>
implements MergeAndCopyStructure<UniqueResultStructure<R>>
UniqueResultStructures are the leaves in the tree of nested
SearchStructures. Each UniqueResultStructure defines a result of
a search. It is designed to hold exactly one value, in contrast to ResultStructures. Because of this UniqueResultStructures throw an
UnsupportedOperationException when trying to merge them. The benefit is that setting up a
SearchStructure with ambiguous results provokes an exception, even before it is put to
use.-
Method Summary
Modifier and TypeMethodDescriptioncopy()This method copies the object which calls it.static <R> UniqueResultStructure<R>createWith(R resultValue) Creates a newResultSetwith the given resultValue as its only result value.booleanget()Returns the set of resulting values.Returns the nestedSearchStructurefor the given key.Returns the value if there is exactly one value.Returns the value if there is exactly one value or the given defaultValue if this structure is empty.inthashCode()voidmerge(UniqueResultStructure<R> otherStructure) Merging adds the contents of the otherMergable to this object.toString()
-
Method Details
-
createWith
Creates a newResultSetwith the given resultValue as its only result value. The resultValue must not be null. -
get
Description copied from class:SearchStructureReturns the nestedSearchStructurefor the given key. This method never returnsnull. If no value exists for a given key anEmptySearchStructureis returned as a fall-back.- Specified by:
getin classSearchStructure<R>- Parameters:
key- The key for the requested nestedSearchStructure- Returns:
- The nested
SearchStructureor anEmptySearchStructureif the key does not exist.
-
get
Description copied from class:SearchStructureReturns the set of resulting values. If thisSearchStructureis noResultStructurethis method simply aggregates every nestedstructures'results. Beware that the aggregation of nested elements has linear complexity.- Specified by:
getin classSearchStructure<R>- Returns:
- The set of resulting values that are reachable by this
SearchStructure
-
merge
Description copied from interface:MergeAndCopyStructureMerging adds the contents of the otherMergable to this object. This object then contains the combined content. The other object remains unchanged.Merging aSearchStructuredeletes no content, instead equal values are being merged recursively.- Specified by:
mergein interfaceMergeAndCopyStructure<R>- Parameters:
otherStructure- The object that should be merged into this object
-
getUnique
Description copied from class:SearchStructureReturns the value if there is exactly one value or the given defaultValue if this structure is empty.Use this method if you know there should be at most one result value. This method throws an
AssertionErrorif there is more than one value.- Overrides:
getUniquein classSearchStructure<R>- Parameters:
defaultValue- The defaultValue which is returned if thisSearchStructureis empty.- Returns:
- The result hold by this
SearchStructureor the defaultValue if the structure is empty.
-
getUnique
Description copied from class:SearchStructureReturns the value if there is exactly one value.Use this method if you know there should be exactly one result value. This method throws an
AssertionErrorif there is more than one values. If there is no value it throws anNoSuchElementExceptionexception.- Overrides:
getUniquein classSearchStructure<R>- Returns:
- The one and only result hold by this
SearchStructure.
-
hashCode
public int hashCode() -
equals
-
toString
-
copy
This method copies the object which calls it. The newly created object has the same properties like the object callingMergeAndCopyStructure.copy().The
UniqueResultStructureis immutable. Hence it is not needed to create a copy.- Specified by:
copyin interfaceMergeAndCopyStructure<R>- Returns:
- T that is a copy of the calling object
-