假设我有以下方法:
public void change(Map<String, String> map)
Run Code Online (Sandbox Code Playgroud)
如果map是的话null,我想抛出一个例外,如果不是的话,我会制作一个防御性的副本.
这会是首选:
public void change(Map<String, String> map)
{
Map<String, String> temp = null;
synchronized (map) {
if (map == null)
throw new NullPointerException("map is null");
temp = new HashMap<String, Object>(map);
}
Run Code Online (Sandbox Code Playgroud)
要么
public void change(Map<String, String> map)
try {
Map<String, String> temp = new HashMap<String, Object>(map);
}
catch (NullPointerException e) {
throw new NullPointerException("map is null");
}
Run Code Online (Sandbox Code Playgroud)
或者,还有更好的方法?为什么不呢.
编辑:
我修改了一些错字:
properties 应该 map
(String,Object)应该是 (String, String)
谢谢!
所以我有表foo,我想foo在触发器t_foo触发时删除其他行:
CREATE OR REPLACE TRIGGER "t_foo" AFTER INSERT OR DELETE OR UPDATE ON foo
/*delete some other records from foo that are not :NEW.* or :OLD.* \*
Run Code Online (Sandbox Code Playgroud)
如果没有获得ORA-04091:表名,我将如何进行此操作变异,触发器/函数可能看不到它.这甚至可能吗?
我正在尝试根据中的值将a转换Map为有序.ListMap
假设我有以下内容:
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("boo", 3);
map.put("bar", 2);
//list needs to be sorted by Integer Value -- ASC or DESC
List<String> list = //Elegant guava call? List should be: {foo, bar, boo}
Run Code Online (Sandbox Code Playgroud) 假设我在我的方法中有以下方法Controller:
@RequestMapping(method = {RequestMethod.GET}, value = "")
@ResponseBody
public Object getObject(@MyAnnotation String value) {
log.debug(value) //value is populated
...
}
Run Code Online (Sandbox Code Playgroud)
我如何将请求中的内容绑定到此注释值?Spring是否为绑定过程提供了任何钩子?如果有人能指出我正确的方向,那将会很棒.
谢谢!