我的团队有一套相当丰富的格式规则并保存操作,这些规则也在不断发展.我们正在寻找一种机制来集中定义并自动传播它们.我们不想重新格式化代码库,但我们希望格式随着时间的推移逐步改进.我们使用Subversion进行源代码控制,但我们希望将存储的配置限制为规则和操作.
我正在尝试将这种MultiMap
特性混合在一起,HashMap
如下所示:
val children:MultiMap[Integer, TreeNode] =
new HashMap[Integer, Set[TreeNode]] with MultiMap[Integer, TreeNode]
Run Code Online (Sandbox Code Playgroud)
特征的定义MultiMap
是:
trait MultiMap[A, B] extends Map[A, Set[B]]
Run Code Online (Sandbox Code Playgroud)
这意味着一种MultiMap
类型A
&B
是一种Map
类型A
&Set[B]
,或者在我看来.但是,编译器抱怨:
C:\...\TestTreeDataModel.scala:87: error: illegal inheritance; template $anon inherits different type instances of trait Map: scala.collection.mutable.Map[Integer,scala.collection.mutable.Set[package.TreeNode]] and scala.collection.mutable.Map[Integer,Set[package.TreeNode]]
new HashMap[Integer, Set[TreeNode]] with MultiMap[Integer, TreeNode]
^ one error found
Run Code Online (Sandbox Code Playgroud)
仿制药似乎再次绊倒了我.
在所有探测之后该怎么办,据报道有效对象对于探测到的任何属性都返回'undefined'?我使用jQuery,$('selector').mouseover(function() { });
Everything $(this)
在函数范围内返回'undefined' .选择器是地图标签的"区域",我正在寻找其父属性.
我想知道Python内置set
结构的元素排序是否"足够随机".例如,取一个集合的迭代器,它可以被视为其元素的混乱视图吗?
(如果重要的话,我在Windows主机上运行Python 2.6.5.)
一般的问题是除了计算的实际结果之外,如何从方法返回附加信息.但我想,这些信息可以默默地被忽略.
就拿方法dropWhile
上Iterator
.返回的结果是变异的迭代器.但也许有时我可能会对丢弃的元素数量感兴趣.
在这种情况下dropWhile
,可以通过向迭代器添加索引并计算之后丢弃的步骤数来在外部生成此信息.但总的来说这是不可能的.
我简单的解决方案是返回一个包含实际结果和可选信息的元组.但是每当我调用方法时我都需要处理元组 - 即使我对可选信息不感兴趣.
所以问题是,是否有一些聪明的方式来收集这些可选信息?
也许通过Option[X => Unit]
带有回调函数的参数默认为None
?有更聪明的东西吗?
如果一个类定义了一个注释,是否有可能强制其子类定义相同的注释?
例如,我们有一个简单的类/子类对,它们共享@Author @interface.
我想要做的是强制每个进一步的子类来定义相同的@Author
注释,从而防止出现在RuntimeException
某个地方.
TestClass.java:
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@interface Author { String name(); }
@Author( name = "foo" )
public abstract class TestClass
{
public static String getInfo( Class<? extends TestClass> c )
{
return c.getAnnotation( Author.class ).name();
}
public static void main( String[] args )
{
System.out.println( "The test class was written by "
+ getInfo( TestClass.class ) );
System.out.println( "The test subclass was written by "
+ getInfo( TestSubClass.class ) );
}
} …
Run Code Online (Sandbox Code Playgroud) 我在堆栈跟踪中看到了这一点:
myorg.vignettemodules.customregistration.NewsCategoryVAPDAO.getEmailContentByID(I)Lmyorg/pushemail /模型/ EmailContent;
" (I)L
"是什么意思?
我正在开发一个基于OSGi的应用程序(使用Equinox),试图对我在OSGi + Equinox上发现的网络教程进行编组.在这个项目中,有些捆绑包取决于其他捆绑(报价服务取决于报价).编译阶段确实成功,但封装阶段没有.Maven抱怨如下:
[INFO] [bundle:bundle] [ERROR] Error building bundle de.vogella.osgi:quote-service:bundle:0.0.1 : Unresolved references to [de.vogella.osgi.quote] by class(es) on the Bundle-Classpath[Jar:dot]: [de/vogella/osgi/quoteservice/Activator.class, de/vogella/osgi/quoteservice/QuoteService.class] [ERROR] Error(s) found in bundle configuration
我确实理解了这个问题,但是没有看到如何让它发挥作用.这是引用的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>osgi-first-app</artifactId>
<groupId>de.vogella.osgi</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>de.vogella.osgi</groupId>
<artifactId>quote</artifactId>
<packaging>bundle</packaging>
<name>Quote Bundle</name>
<version>0.0.1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>src/main/resources/META-INF/MANIFEST.MF</_include>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
和报价的捆绑清单:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quote Plug-in
Bundle-SymbolicName: de.vogella.osgi.quote
Bundle-Activator: de.vogella.osgi.quote.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework;version="1.3.0" …
Run Code Online (Sandbox Code Playgroud) 可能重复:
在Java中创建临时目录
我有一个create DB方法的测试,我需要一个临时目录来放入它.测试完成后将删除该目录.我尝试过使用File.createTempFile()
,像这样:
tempDir = File.createTempFile("install", "dir");
tempDir.mkdir();
Run Code Online (Sandbox Code Playgroud)
但是tempDir
已经作为文件存在.如何创建临时目录而不是文件?
java ×4
scala ×2
annotations ×1
clojure ×1
dependencies ×1
eclipse ×1
eclipse-3.4 ×1
exception ×1
generics ×1
javascript ×1
jquery ×1
maven-2 ×1
osgi ×1
python ×1
random ×1
set ×1
shuffle ×1
stack-trace ×1
subclass ×1