Skip to content

Commit

Permalink
refactor: Enum values should be compared with "=="
Browse files Browse the repository at this point in the history
  • Loading branch information
2 people authored and app committed Dec 24, 2024
1 parent 9354270 commit a034441
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public J visitUnary(J.Unary unary, ExecutionContext ctx) {
if (unary.getExpression() instanceof J.Binary &&
getCursor().pollMessage("replaced") != null) {
J.Binary binary = (J.Binary) unary.getExpression();
if (binary.getOperator().equals(J.Binary.Type.Equal)) {
if (binary.getOperator() == J.Binary.Type.Equal) {
return binary.withOperator(J.Binary.Type.NotEqual);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,18 @@ public Space visitSpace(Space space, Space.Location loc, P p) {
IndentType indentType = parent.getNearestMessage("indentType", IndentType.ALIGN);

// block spaces are always aligned to their parent
boolean alignBlockPrefixToParent = loc.equals(Space.Location.BLOCK_PREFIX) && space.getWhitespace().contains("\n") &&
boolean alignBlockPrefixToParent = loc == Space.Location.BLOCK_PREFIX && space.getWhitespace().contains("\n") &&
// ignore init blocks.
(value instanceof J.Block && !(getCursor().getParentTreeCursor().getValue() instanceof J.Block));

boolean alignBlockToParent = loc.equals(Space.Location.BLOCK_END) ||
loc.equals(Space.Location.NEW_ARRAY_INITIALIZER_SUFFIX) ||
loc.equals(Space.Location.CATCH_PREFIX) ||
loc.equals(Space.Location.TRY_FINALLY) ||
loc.equals(Space.Location.ELSE_PREFIX);
boolean alignBlockToParent = loc == Space.Location.BLOCK_END ||
loc == Space.Location.NEW_ARRAY_INITIALIZER_SUFFIX ||
loc == Space.Location.CATCH_PREFIX ||
loc == Space.Location.TRY_FINALLY ||
loc == Space.Location.ELSE_PREFIX;

if ((loc.equals(Space.Location.EXTENDS) && space.getWhitespace().contains("\n")) ||
Space.Location.EXTENDS.equals(getCursor().getParent().getMessage("lastLocation"))) {
if ((loc == Space.Location.EXTENDS && space.getWhitespace().contains("\n")) ||
Space.Location.EXTENDS == getCursor().getParent().getMessage("lastLocation")) {
indentType = IndentType.CONTINUATION_INDENT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public J visitDestructuringDeclaration(K.DestructuringDeclaration destructuringD
visit(destructuringDeclaration.getInitializer().getLeadingAnnotations(), p);
for (J.Modifier m : destructuringDeclaration.getInitializer().getModifiers()) {
delegate.visitModifier(m, p);
if (m.getType().equals(J.Modifier.Type.Final)) {
if (m.getType() == J.Modifier.Type.Final) {
p.append("val");
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ public J visitProperty(K.Property property, PrintOutputCapture<P> p) {
visit(vd.getLeadingAnnotations(), p);
for (J.Modifier m : vd.getModifiers()) {
delegate.visitModifier(m, p);
if (m.getType().equals(J.Modifier.Type.Final)) {
if (m.getType() == J.Modifier.Type.Final) {
p.append("val");
}
}
Expand Down

0 comments on commit a034441

Please sign in to comment.