Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala java 7中java.util.function.function的替代实现_Scala_Java 8_Java 7 - Fatal编程技术网

Scala java 7中java.util.function.function的替代实现

Scala java 7中java.util.function.function的替代实现,scala,java-8,java-7,Scala,Java 8,Java 7,我试图在JDK1.7和Scala2.10下重建GeoMesa源代码。但是它使用了Java8中的新特性,比如下面代码中的“java.util.function.function”。在Java8中,有没有替代这种函数的方法 /** * Gets table names and converters for each table (e.g. index) that supports the sft\n * * @param sft simple feature type

我试图在JDK1.7和Scala2.10下重建GeoMesa源代码。但是它使用了Java8中的新特性,比如下面代码中的“java.util.function.function”。在Java8中,有没有替代这种函数的方法

/**
    * Gets table names and converters for each table (e.g. index) that supports the sft\n
    *
    * @param sft simple feature type
    * @param ds data store
    * @param indices indices to write/delete
    * @return (table names, write converters, remove converters)
    */ 

def getTablesAndConverters[DS <: GeoMesaDataStore[DS, F, W], F<:WrappedFeature,W] (
      sft: SimpleFeatureType,
      ds: DS,
      indices: Option[Seq[GeoMesaFeatureIndex[DS, F, W]]] = None): (IndexedSeq[String], IndexedSeq[(F) => Seq[W]], IndexedSeq[(F) => Seq[W]]) = {

    val toWrite = indices.getOrElse(ds.manager.indices(sft, IndexMode.Write)).toIndexedSeq

    val key = s"${ds.config.catalog};${CacheKeyGenerator.cacheKey(sft)};${toWrite.map(_.identifier).mkString(",")}"
    val load = new java.util.function.Function[String, (IndexedSeq[String], IndexedSeq[(Any) => Seq[Any]], IndexedSeq[(Any) => Seq[Any]])] {
      override def apply(ignored: String): (IndexedSeq[String], IndexedSeq[(Any) => Seq[Any]], IndexedSeq[(Any) => Seq[Any]]) = {
        val tables = toWrite.map(_.getTableName(sft.getTypeName, ds))
        val writers = toWrite.map(_.writer(sft, ds))
        val removers = toWrite.map(_.remover(sft, ds))
        (tables, writers.asInstanceOf[IndexedSeq[(Any) => Seq[Any]]], removers.asInstanceOf[IndexedSeq[(Any) => Seq[Any]]])
      }
    }

    converterCache.get(key, load).asInstanceOf[(IndexedSeq[String], IndexedSeq[(F) => Seq[W]], IndexedSeq[(F) => Seq[W]])]
  }
/**
*获取支持sft的每个表(例如索引)的表名和转换器\n
*
*@param sft简单功能类型
*@param-ds数据存储
*@param索引要写入/删除的索引
*@return(表名、写入转换器、删除转换器)
*/ 
def GetTables和转换器[DS Seq[W]])={
val toWrite=index.getOrElse(ds.manager.index(sft,IndexMode.Write)).toIndexedSeq
val key=s“${ds.config.catalog};${CacheKeyGenerator.cacheKey(sft)};${toWrite.map(wk.identifier.mkString(“,”)}”
val load=new java.util.function.function[String,(IndexedSeq[String],IndexedSeq[(任意)=>Seq[Any]],IndexedSeq[(任意)=>Seq[Any]]{
覆盖def apply(忽略:字符串):(IndexedSeq[String]、IndexedSeq[(任意)=>Seq[Any]]、IndexedSeq[(任意)=>Seq[Any]])={
val tables=toWrite.map(u.getTableName(sft.getTypeName,ds))
val writers=toWrite.map(u.writer(sft,ds))
val removers=toWrite.map(u.remover(sft,ds))
(表、写入程序.asInstanceOf[IndexedSeq[(任何)=>Seq[Any]],移除程序.asInstanceOf[IndexedSeq[(任何)=>Seq[Any]])
}
}
converterCache.get(key,load).asInstanceOf[(IndexedSeq[String],IndexedSeq[(F)=>Seq[W]],IndexedSeq[(F)=>Seq[W]])]
}
有一种方法,除其他外,它将所有
java.util.function
接口后端口到另一个包中(显然没有默认和静态方法)。包含整个jar可能有些过分,但您可以使用源代码,只包含该包。