Package org.apache.sis.feature
Class CommonParentFinder
java.lang.Object
org.apache.sis.feature.CommonParentFinder
Finds a feature type common to all given types. This is either one of the given types, or a parent common to all types.
A feature F is considered a common parent if
F.isAssignableFrom
(type)
returns true
for all elements type in the given array.- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<DefaultFeatureType,
Boolean> All feature types examined by this class.private final int
Number of valid elements in therequired
array.private final DefaultFeatureType[]
The features types which must be assignable to the common parent. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
CommonParentFinder
(Map<DefaultFeatureType, Boolean> allTypes, DefaultFeatureType[] required, int count) Creates a finder for a common parent of the given types. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Returnstrue
if the given parent candidate is assignable from all required types.private void
Verifies if the given type has a parent which is assignable from all required types.(package private) DefaultFeatureType
select()
Invoked after all feature types have been examined.(package private) static DefaultFeatureType
select
(Iterable<? extends DefaultFeatureType> types) Finds a feature type common to all given types.private void
Invoked when the given feature type is assignable from all required types.
-
Field Details
-
allTypes
All feature types examined by this class. Values are whether a feature type is retained as a candidate for common parent. Those values are initiallyBoolean.FALSE
then updated after we find that a type is assignable from all required types. -
required
The features types which must be assignable to the common parent. This array may not contain all feature types given by user, since we try to remove redundant elements. -
count
private final int countNumber of valid elements in therequired
array.
-
-
Constructor Details
-
CommonParentFinder
private CommonParentFinder(Map<DefaultFeatureType, Boolean> allTypes, DefaultFeatureType[] required, int count) Creates a finder for a common parent of the given types. Invokesselect()
after construction time for getting the parent.
-
-
Method Details
-
select
Finds a feature type common to all given types. See class javadoc.- Parameters:
types
- types for which to find a common type.- Returns:
- a feature type which is assignable from all given types, or
null
if none.
-
isAssignableFromAll
Returnstrue
if the given parent candidate is assignable from all required types. The feature type to be returned byselect()
must met that condition. -
scanParents
Verifies if the given type has a parent which is assignable from all required types. This method verifies recursively parents of parents, skipping types that have already been examined in a previous invocation of this method. -
skipParents
Invoked when the given feature type is assignable from all required types. There is no need to verify the parents since they are not going to be a better match. -
select
DefaultFeatureType select()Invoked after all feature types have been examined. This method removes all features types that are not parent of required types, then select the one having the greatest number of properties.
-