将Assert用于函数参数以强制执行其有效性是一种好习惯.我正在浏览Spring Framework的源代码,我注意到它们使用Assert.notNull了很多.这是一个例子
public static ParsedSql parseSqlStatement(String sql) {
Assert.notNull(sql, "SQL must not be null");}
Run Code Online (Sandbox Code Playgroud)
这是另一个:
public NamedParameterJdbcTemplate(DataSource dataSource) {
Assert.notNull(dataSource,
"The [dataSource] argument cannot be null.");
this .classicJdbcTemplate = new JdbcTemplate(dataSource);
}
public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate) {
Assert.notNull(classicJdbcTemplate,
"JdbcTemplate must not be null");
this .classicJdbcTemplate = classicJdbcTemplate;
}
Run Code Online (Sandbox Code Playgroud)
FYI,Assert.notNull(不是assert语句)在util类中定义如下:
public abstract class Assert {
public static void notNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException (message);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想构建一个基于Web的实时数据图,我正在寻找不同的选项,例如:
实时我的意思是,客户端轮询Web服务器说每秒或使用反向ajax; 服务器在可用时将数据推送到客户端.
你能推荐一下吗?
我有一个通知视图,负责在页面顶部显示全局消息(信息,警告,确认消息......)
我为此创建了一个NotificationView,定义了它的content属性并提供了两个处理程序来显示和隐藏视图.
APP.NotificationView = Ember.View.extend({
templateName: 'notification',
classNames:['nNote'],
content:null,
didInsertElement : function(){
},
click: function() {
var _self = this;
_self.$().fadeTo(200, 0.00, function(){ //fade
_self.$().slideUp(200, function() { //slide up
_self.$().remove(); //then remove from the DOM
});
});
_self.destroy();
},
show: function() {
var _self = this;
_self.$().css('display','block').css('opacity', 0).slideDown('slow').animate(
{ opacity: 1 },
{ queue: false, duration: 'slow' }
);
}
});
Run Code Online (Sandbox Code Playgroud)
理想情况下,我应该能够从任何控制器或路线发送事件,以显示具有适当内容和样式的视图.什么是构建这个的最好方法
我想在我的应用程序模板中使用一个命名插座,但是插件并不适合动态视图.
<div id="content">
{{outlet notification}}
{{outlet}}
</div>
Run Code Online (Sandbox Code Playgroud)
我还在考虑将通知视图设计为对"应用程序"或"模块"状态的响应.
在Grails中,有没有办法限制枚举枚举的列的大小.在以下示例中,我希望列类型为char(2)
enum FooStatus {
BAR('br'), TAR('tr')
final static String id
}
class Foo {
FooStatus status
static constraints = {
status(inList:FooStatus.values()*.id,size:2..2)
}
}
Run Code Online (Sandbox Code Playgroud)
在导出模式时,inList和size都没有任何效果,列类型保持其默认值(varch(255))如果我定义一个新的UserType,也许我可以这样做.任何的想法 ?
谢谢你
有没有办法将Hudson配置为仅在SVN/CVS发生更改时才执行Build或Post Build操作
谢谢
为什么recaptcha图像的大小固定为300x57?即使在自定义注入图像的div时,div的宽度和高度也会被覆盖并设置为300x57.当然,图像可以在渲染后重新调整大小,但为什么没有选项来生成开发人员希望的大小的图像.
http://code.google.com/apis/recaptcha/docs/customization.html
reCAPTCHA将依赖具有以下ID的HTML元素的存在来向用户显示CAPTCHA:具有ID recaptcha_image的空div.这是放置实际图像的位置.div将是300x57像素
谢谢
任何人都可以解释为什么在调用[:]时调用地图上的[:].类会返回null.getClass()返回预期的结果Map.见下面的例子
1-
["test",[test:"test"],23].each {
println it.class
}
class java.lang.String
null
class java.lang.Integer
Run Code Online (Sandbox Code Playgroud)
2-
["test",[test:"test"],23].each {
println it.getClass()
}
class java.lang.String
class java.util.LinkedHashMap
class java.lang.Integer
Run Code Online (Sandbox Code Playgroud)
肯
我们如何通过arguments数组以动态,javascript样式检索groovy中的闭包/方法的参数列表
例如,我想以这种方式记录消息
def closure = {name,id ->
log.debug "Executing method with params name:${} id:${id}"
}
Run Code Online (Sandbox Code Playgroud)
要么
void method (String name,String id) {
log.debug "Executing method with params name:${} id:${id}"
}
Run Code Online (Sandbox Code Playgroud)
我读过一次关于引用闭包参数列表的方法,但我没有回忆这一点,看看Closure的groovy API 只显示了getParametersType()方法.至于方法,有一种方法可以将方法作为闭包调用,然后我可以检索方法参数
肯
这是一个有效的对象设计吗?我有一个域对象,我注入一个服务,并调用验证方法来更新对象的状态,如果一切顺利,发送一条确认消息.代码如下:
class Foo {
String bar
Service emailService
public boolean verify() {
bar = "foo"
if(this.save()) {
emailService.sendConfirmation()
}
}
}
Foo.get(1).verify()
Run Code Online (Sandbox Code Playgroud)
在这样的情况下调用emailService是否可以接受?是否有一种设计模式,我可以遵循这种情况使用.
谢谢 - 肯
任何人都可以向我解释为什么isLoaded在调用ajax调用的成功方法之前RecordArray状态设置为true.
来自ember-data源代码
findAll: function(store, type, since) {
var root = this.rootForType(type);
this.ajax(this.buildURL(root), "GET", {
data: this.sinceQuery(since),
success: function(json) {
debugger;
Ember.run(this, function(){
this.didFindAll(store, type, json);
});
}
});
},
Run Code Online (Sandbox Code Playgroud)
在视图中定义
handler: function() {
var content, controller = this.get('controller');
if(controller.get('content.isLoaded')) {
}
}.observes('controller.content.isLoaded')
Run Code Online (Sandbox Code Playgroud)