diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ObjectBlockHandler.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ObjectBlockHandler.java index fea495847..f3d497226 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ObjectBlockHandler.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ObjectBlockHandler.java @@ -90,10 +90,13 @@ public class ObjectBlockHandler extends BlockParentHandler public IndentLevel getLevelImpl() { DetailAST parentAST = getMainAst().getParent(); - final IndentLevel indent = getParent().getLevel(); + IndentLevel indent = getParent().getLevel(); if (parentAST.getType() == TokenTypes.LITERAL_NEW) { indent.addAcceptedIndent(super.getLevelImpl()); } + else if (parentAST.getType() == TokenTypes.ENUM_CONSTANT_DEF) { + indent = super.getLevelImpl(); + } return indent; } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidBlockIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidBlockIndent.java index 2c0256323..bb3dd68a3 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidBlockIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidBlockIndent.java @@ -69,3 +69,61 @@ public class InputValidBlockIndent { } + +public enum EquivalenceTester { + /** + * An equivalence tester that decides based on {@link Object#equals(Object) equals}. + */ + OBJECT_ATTRIBUTES { + /** + * {@inheritDoc} + */ + public boolean areEqual( final Object first, final Object second ) { + return Objects.areEqual( first, second ); + } + + /** + * {@inheritDoc} + */ + public int hashCode( final Object target ) { + return Objects.nullSafeHashCode( target ); + } + }, + + /** + * An equivalence tester that decides based on {@code ==}. + */ + OBJECT_IDENTITIES + { + /** + * {@inheritDoc} + */ + public boolean areEqual( final Object first, final Object second ) { + return first == second; + } + + /** + * {@inheritDoc} + */ + public int hashCode( final Object target ) { + return System.identityHashCode( target ); + } + }; + + /** + * Tells whether the two given objects are considered equivalent. + * + * @param first first comparand + * @param second second comparand + * @return whether {@code first} and {@code second} are considered equivalent + */ + public abstract boolean areEqual( Object first, Object second ); + + /** + * Computes a hash code for the given object. + * + * @param target object to compute a hash for + * @return the computed hash + */ + public abstract int hashCode( Object target ); +} diff --git a/src/xdocs/releasenotes.xml b/src/xdocs/releasenotes.xml index 0c6d99a9d..b57981591 100755 --- a/src/xdocs/releasenotes.xml +++ b/src/xdocs/releasenotes.xml @@ -17,6 +17,9 @@
  • DesignForExtension check skips enums now (they are final :). (bug# 1194470)
  • +
  • One more fix for Indentation check and enums (bug + 1193850)
  • +