Commit 117f630a authored by Daniel Gerhardt's avatar Daniel Gerhardt

Move string literals to the left side of comparisons with equals

parent 9e63a098
......@@ -68,7 +68,7 @@ public class MotdController extends AbstractController {
client.setTime(Long.parseLong(clientdate));
}
if (adminview) {
if (sessionkey.equals("null")) {
if ("null".equals(sessionkey)) {
motds = motdService.getAdminMotds();
} else {
motds = motdService.getAllSessionMotds(sessionkey);
......@@ -92,7 +92,7 @@ public class MotdController extends AbstractController {
) {
if (motd != null) {
Motd newMotd;
if (motd.getAudience().equals("session") && motd.getSessionkey() != null) {
if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) {
newMotd = motdService.saveSessionMotd(motd.getSessionkey(), motd);
} else {
newMotd = motdService.saveMotd(motd);
......@@ -114,7 +114,7 @@ public class MotdController extends AbstractController {
@ApiParam(value = "motdkey from current motd", required = true) @PathVariable final String motdkey,
@ApiParam(value = "current motd", required = true) @RequestBody final Motd motd
) {
if (motd.getAudience().equals("session") && motd.getSessionkey() != null) {
if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) {
return motdService.updateSessionMotd(motd.getSessionkey(), motd);
} else {
return motdService.updateMotd(motd);
......@@ -125,7 +125,7 @@ public class MotdController extends AbstractController {
@RequestMapping(value = "/{motdkey}", method = RequestMethod.DELETE)
public void deleteMotd(@ApiParam(value = "Motd-key from the message that shall be deleted", required = true) @PathVariable final String motdkey) {
Motd motd = motdService.getMotd(motdkey);
if (motd.getAudience().equals("session")) {
if ("session".equals(motd.getAudience())) {
motdService.deleteSessionMotd(motd.getSessionkey(), motd);
} else {
motdService.deleteMotd(motd);
......
......@@ -172,7 +172,7 @@ public class SessionController extends PaginationController {
) {
List<Session> sessions;
if (!username.equals("")) {
if (!"".equals(username)) {
try {
if (ownedOnly && !visitedOnly) {
sessions = sessionService.getUserSessions(username);
......@@ -206,7 +206,7 @@ public class SessionController extends PaginationController {
return null;
}
if (sortby != null && sortby.equals("shortname")) {
if ("shortname".equals(sortby)) {
Collections.sort(sessions, new SessionShortNameComparator());
} else {
Collections.sort(sessions, new SessionNameComparator());
......@@ -242,7 +242,7 @@ public class SessionController extends PaginationController {
return null;
}
if (sortby != null && sortby.equals("shortname")) {
if ("shortname".equals(sortby)) {
Collections.sort(sessions, new SessionInfoShortNameComparator());
} else {
Collections.sort(sessions, new SessionInfoNameComparator());
......
......@@ -1200,9 +1200,9 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
} else if (fstkey.size() == 3) {
type = fstkey.getString(2);
}
if (type.equals("read")) {
if ("read".equals(type)) {
read = fst.optInt("value");
} else if (type.equals("unread")) {
} else if ("unread".equals(type)) {
unread = fst.optInt("value");
}
......@@ -1213,9 +1213,9 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
} else {
type = sndkey.getString(2);
}
if (type.equals("read")) {
if ("read".equals(type)) {
read = snd.optInt("value");
} else if (type.equals("unread")) {
} else if ("unread".equals(type)) {
unread = snd.optInt("value");
}
}
......@@ -2110,7 +2110,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
@Override
public void setVotingAdmissions(final Session session, final boolean disableVoting, List<Question> questions) {
for (final Question q : questions) {
if (!q.getQuestionType().equals("flashcard")) {
if (!"flashcard".equals(q.getQuestionType())) {
q.setVotingDisabled(disableVoting);
}
}
......@@ -2606,7 +2606,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
final Morpher dynaMorpher = new BeanMorpher(PossibleAnswer.class, morpherRegistry);
morpherRegistry.registerMorpher(dynaMorpher);
for (final Document document : questiondocs) {
if (!document.optString("error").equals("")) {
if (!"".equals(document.optString("error"))) {
// Skip documents we could not load. Maybe they were deleted.
continue;
}
......
......@@ -41,7 +41,7 @@ public class LearningProgressFactory implements NovaEventVisitor, ILearningProgr
@Override
public LearningProgress create(String progressType, String questionVariant) {
VariantLearningProgress learningProgress;
if (progressType.equals("questions")) {
if ("questions".equals(progressType)) {
learningProgress = new QuestionBasedLearningProgress(databaseDao);
} else {
learningProgress = new PointBasedLearningProgress(databaseDao);
......
......@@ -653,9 +653,9 @@ public class Question implements Serializable {
public int calculateValue(Answer answer) {
if (answer.isAbstention()) {
return 0;
} else if (this.questionType.equals("mc")) {
} else if ("mc".equals(this.questionType)) {
return calculateMultipleChoiceValue(answer);
} else if (this.questionType.equals("grid")) {
} else if ("grid".equals(this.questionType)) {
return calculateGridValue(answer);
} else {
return calculateRegularValue(answer);
......@@ -780,7 +780,7 @@ public class Question implements Serializable {
int value = 0;
String[] answers = answer.getAnswerText().split(",");
for (int i = 0; i < this.possibleAnswers.size() && i < answers.length; i++) {
if (answers[i].equals("1")) {
if ("1".equals(answers[i])) {
PossibleAnswer p = this.possibleAnswers.get(i);
value += p.getValue();
}
......
......@@ -103,9 +103,9 @@ public class ApplicationPermissionEvaluator implements PermissionEvaluator {
final Serializable targetId,
final Object permission
) {
if (permission instanceof String && (permission.equals("owner") || permission.equals("write"))) {
if (permission instanceof String && ("owner".equals(permission) || "write".equals(permission))) {
return dao.getSessionFromKeyword(targetId.toString()).getCreator().equals(username);
} else if (permission instanceof String && permission.equals("read")) {
} else if (permission instanceof String && "read".equals(permission)) {
return dao.getSessionFromKeyword(targetId.toString()).isActive();
}
return false;
......@@ -116,7 +116,7 @@ public class ApplicationPermissionEvaluator implements PermissionEvaluator {
final Serializable targetId,
final Object permission
) {
if (permission instanceof String && permission.equals("owner")) {
if (permission instanceof String && "owner".equals(permission)) {
final Question question = dao.getQuestion(targetId.toString());
if (question != null) {
final Session session = dao.getSessionFromId(question.getSessionId());
......@@ -132,7 +132,7 @@ public class ApplicationPermissionEvaluator implements PermissionEvaluator {
final Serializable targetId,
final Object permission
) {
if (permission instanceof String && permission.equals("owner")) {
if (permission instanceof String && "owner".equals(permission)) {
final InterposedQuestion question = dao.getInterposedQuestion(targetId.toString());
if (question != null) {
// Does the creator want to delete his own question?
......
......@@ -170,7 +170,7 @@ public class MotdService implements IMotdService {
@PreAuthorize("isAuthenticated()")
public MotdList getMotdListForUser(final String username) {
final User user = userService.getCurrentUser();
if (username.equals(user.getUsername()) && !user.getType().equals("guest")) {
if (username.equals(user.getUsername()) && !"guest".equals(user.getType())) {
return databaseDao.getMotdListForUser(username);
}
return null;
......
......@@ -202,7 +202,7 @@ public class UserService implements IUserService {
}
}
if (user == null || user.getUsername().equals("anonymous")) {
if (user == null || "anonymous".equals(user.getUsername())) {
throw new UnauthorizedException();
}
......
......@@ -512,9 +512,9 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
// Update the unanswered count for the question variant that was answered.
final de.thm.arsnova.entities.Question question = event.getQuestion();
if (question.getQuestionVariant().equals("lecture")) {
if ("lecture".equals(question.getQuestionVariant())) {
sendToUser(event.getUser(), "unansweredLecturerQuestions", questionService.getUnAnsweredLectureQuestionIds(sessionKey, event.getUser()));
} else if (question.getQuestionVariant().equals("preparation")) {
} else if ("preparation".equals(question.getQuestionVariant())) {
sendToUser(event.getUser(), "unansweredPreparationQuestions", questionService.getUnAnsweredPreparationQuestionIds(sessionKey, event.getUser()));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment