我正在考虑代码结构,并思考setter.这些曾经是void方法,那么为什么不使用一些可能的返回值,来启用一些新的代码结构呢?
我的想法是将所有属性setter从void更改为实例引用,因此我们可以按顺序执行setter或其他操作.这是一个例子:
public class MyClass {
private int foo;
private String bar;
public MyClass setFoo(int foo) {
this.foo = foo;
return this;
}
public MyClass setBar(String bar) {
this.bar = bar;
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我们可以做的代码中的其他地方:
...
MyClass myInstance = new MyClass();
myInstance.setFoo(auxFoo).setBar(auxBar);
...
Run Code Online (Sandbox Code Playgroud)
这允许在一行中设置所有类属性,这在转换方法中很有用.
甚至:
...
return myInstance.setFoo(auxFoo);
Run Code Online (Sandbox Code Playgroud)
这个是我的目标,例如在返回时可以设置错误属性.例如,这可以简化捕获块.
编辑: 经过一些答案我需要补充:
return
例如示例.我希望看到一些讨论.
我在应用程序中使用了一个方面来获取错误.
我需要什么来解决这个错误或者这对我说的是什么?
[AppClassLoader@13b8f62] error can't determine superclass of missing type xxx.yyy.zzz.execution.SystemVersion
when weaving type xxx.yyy.zzz.execution.DefaultDServerConfigurator
when weaving classes
when weaving
[Xlint:cantFindType]
Run Code Online (Sandbox Code Playgroud) 我还没有找到一个安装Eclipse 4.2 Juno.默认的Ubuntu存储库(我使用的是Ubuntu 10.04)向我推荐了古老的Galileo版本.我在Launchpad上发现了Eclipse的页面,该页面于2009年更新.
当然,我可以直接从http://www.eclipse.org/downloads/下载包含所有文件的存档,但这不是Debian方式,是吗?我的意思是,没有自动更新和其他能力管理的酷事.
那么,是否有任何存储库可以维护最新版本的Eclipse?
在Jmeter中,我经常遇到"响应太大而无法显示.大小:340188>最大:204800"错误的响应数据.虽然我试图将"View.Result.Tree.Max大小更新为0但是再次遇到同样的问题.
我需要(主要是出于测试目的)编写一个消费者,其目的是记住它被调用了多少次.但是,我不能这样做
int i = 0;
Consumer<Object> handler = o -> i++;
Run Code Online (Sandbox Code Playgroud)
因为i
必须是最终的,我不能增加最终变量.我想我需要像MutableInteger
课一样的东西.那么正确的计算方法是什么?编写我自己的新类或新方法只是为了正确的方法.
我跑
$ mvn clean compile
Run Code Online (Sandbox Code Playgroud)
得到以下输出:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tendiwa-core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tendiwa-core ---
[INFO] Deleting /home/suseika/Projects/tendiwa/core/target
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ tendiwa-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tendiwa-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION …
Run Code Online (Sandbox Code Playgroud) 这对我来说似乎太棘手了,因为ImmutableSet
实例只是用ImmutableSet.Builder
实例构建的,没有实现,Collection
所以你不能只使用Collectors.toCollection(ImmutableSet::new)
或Collectors.toCollection(ImmutableSet.Builder::new)
.
我在我的网站上使用 nodejs 和 php,但是当我想将它托管在服务器上时,他们告诉我没有可以同时运行 node 和 php 的服务器。
有什么东西可以代替 nodejs 并做同样的工作而不需要服务器吗?我正在使用 nodejs 和 socket 为我的网站进行实时更新。
我是 LLDB 的新手(实际上是大多数命令行工具的新手)。当我按照这篇极其简单且有用的文章来回溯段错误错误时,我发现使用 LLDB 在 Mac OS X 10.10 上的输出与使用 gdb 作为调试器的作者的输出不同。
为了让问题更清楚。当我使用 lldb 运行上面文章中的相同代码,遇到段错误错误,并使用bt
lldb 命令时,我得到了这条消息。
* thread #1: tid = 0x208541, 0x00007fff8869a05a libsystem_platform.dylib`_platform_memmove$VARIANT$Unknown + 186, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x00007fff8869a05a libsystem_platform.dylib`_platform_memmove$VARIANT$Unknown + 186
frame #1: 0x00007fff8fc08866 libsystem_c.dylib`fgets + 243
frame #2: 0x0000000100000f34 sf`main + 68
frame #3: 0x00007fff8e6535c9 libdyld.dylib`start + 1
Run Code Online (Sandbox Code Playgroud)
由于我将可执行文件命名为“sf”(段错误的缩写),因此我按照文章中的想法并使用了f 2
命令。
现在事情出了问题,因为我收到了这条消息。
frame #2: 0x0000000100000f34 sf`main + 68
sf`main:
0x100000f34 <+68>: leaq 0x5f(%rip), …
Run Code Online (Sandbox Code Playgroud) 由于完整性检查,我宁愿不使用WMI.
这是我有的不起作用:
$tempdir = Get-Location
$tempdir = $tempdir.tostring()
$reg32 = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
$reg64 = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
if((Get-ItemProperty $reg32 | Select-Object DisplayName | Where-Object { $_.DisplayName -Like '*Microsoft Interop Forms*' } -eq $null) -Or (Get-ItemProperty $reg64 | Select-Object DisplayName | Where-Object { $_.DisplayName -Like '*Microsoft Interop Forms*' } -eq $null))
{
(Start-Process -FilePath $tempdir"\microsoft.interopformsredist.msi" -ArgumentList "-qb" -Wait -Passthru).ExitCode
}
Run Code Online (Sandbox Code Playgroud)
它总是返回false.如果我将它切换到-ne $null
它总是返回true,所以我知道它正在检测$null
输出,即使我相信(但可能是错误的),Get-ItemProperty
返回的结果应该算作除了之外的其他东西$null
.
java ×3
java-8 ×2
aspectj ×1
c ×1
coding-style ×1
collectors ×1
concurrency ×1
eclipse ×1
groovy ×1
guava ×1
hosting ×1
if-statement ×1
installation ×1
jmeter ×1
lldb ×1
maven ×1
node.js ×1
php ×1
powershell ×1
repository ×1
ubuntu ×1