将表达式转换为 lambda
converting the expression to lambda
谁能帮我把这段代码转换成 lambda 表达式,
我对此感到震惊
Observable.create(new OnSubscribe<User>() {
@Override
public void call(Subscriber<? super User> arg0) {
User updatedUser = userService.updateuser(usermapper.userdtotoentity(user));
arg0.onNext(updatedUser);
}
}).subscribe(new Action1<User>() {
@Override
public void call(User user) {
if (user != null) {
response.resume(user);
} else
response.resume(Response.status(Status.NOT_FOUND).build());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable t) {
logger.debug("User with email_id:" + email_id + " is not present");
response.resume(t);
}
});
Observable.<User>create(subscriber -> {
User updatedUser = userService.updateuser(usermapper.userdtotoentity(user));
subscriber.onNext(updatedUser);
}).subscribe(
user -> {
if (user != null) {
response.resume(user);
} else {
response.resume(Response.status(Status.NOT_FOUND).build());
}
},
error -> {
logger.debug("User with email_id:" + email_id + " is not present");
response.resume(error);
}
);
谁能帮我把这段代码转换成 lambda 表达式, 我对此感到震惊
Observable.create(new OnSubscribe<User>() {
@Override
public void call(Subscriber<? super User> arg0) {
User updatedUser = userService.updateuser(usermapper.userdtotoentity(user));
arg0.onNext(updatedUser);
}
}).subscribe(new Action1<User>() {
@Override
public void call(User user) {
if (user != null) {
response.resume(user);
} else
response.resume(Response.status(Status.NOT_FOUND).build());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable t) {
logger.debug("User with email_id:" + email_id + " is not present");
response.resume(t);
}
});
Observable.<User>create(subscriber -> {
User updatedUser = userService.updateuser(usermapper.userdtotoentity(user));
subscriber.onNext(updatedUser);
}).subscribe(
user -> {
if (user != null) {
response.resume(user);
} else {
response.resume(Response.status(Status.NOT_FOUND).build());
}
},
error -> {
logger.debug("User with email_id:" + email_id + " is not present");
response.resume(error);
}
);