def convertToMapOrList()

in src/main/groovy/org/jetbrains/gradle/ext/IdeaExtPlugin.groovy [120:142]


  def convertToMapOrList(TypeOf<?> typeOfExt, def extension) {
    if (extension == null) {
      return null
    }

    if (TypeOf.typeOf(MapConvertible).isAssignableFrom(typeOfExt)) {
      def map = (extension as MapConvertible).toMap().findAll { it.value != null }
      return map.isEmpty() ? null : map
    }

    if (TypeOf.typeOf(Iterable).isAssignableFrom(typeOfExt)) {
      def converted = (extension as Iterable)
              .findAll { it instanceof MapConvertible }
              .collect { (it as MapConvertible).toMap().findAll { it.value != null }}
              .findAll { !it.isEmpty() }

      if (converted.size() > 0) {
        return converted
      } else {
        return null
      }
    }
  }