Class CommonParentFinder

java.lang.Object
org.apache.sis.feature.CommonParentFinder

final class CommonParentFinder extends Object
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 Details

    • allTypes

      private final Map<DefaultFeatureType,Boolean> 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 initially Boolean.FALSE then updated after we find that a type is assignable from all required types.
    • required

      private final DefaultFeatureType[] 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 count
      Number of valid elements in the required array.
  • Constructor Details

  • Method Details

    • select

      static DefaultFeatureType select(Iterable<? extends DefaultFeatureType> types)
      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

      private boolean isAssignableFromAll(DefaultFeatureType parent)
      Returns true if the given parent candidate is assignable from all required types. The feature type to be returned by select() must met that condition.
    • scanParents

      private void scanParents(DefaultFeatureType type)
      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

      private void skipParents(DefaultFeatureType type)
      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

      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.