From bc8103e2683861ecd8316b784009ccff06b46a35 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Sat, 30 Dec 2017 20:21:51 -0500 Subject: [PATCH] SQL: Break long lines in expression package (elastic/x-pack-elasticsearch#3456) Break lines over 140 characters in the expression package to make them a bit easier to read and to make checkstyle happy. Original commit: elastic/x-pack-elasticsearch@89487a79cc159f6d629577f536d3917eb22d7e72 --- dev-tools/checkstyle_suppressions.xml | 6 ------ .../xpack/sql/expression/Attribute.java | 18 ++++++++++++------ .../sql/expression/ExpressionIdGenerator.java | 3 ++- .../xpack/sql/expression/FieldAttribute.java | 5 +++-- .../xpack/sql/expression/LiteralAttribute.java | 3 ++- .../xpack/sql/expression/TypedAttribute.java | 3 ++- .../sql/expression/UnresolvedAttribute.java | 11 +++++++---- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/dev-tools/checkstyle_suppressions.xml b/dev-tools/checkstyle_suppressions.xml index 4238f7bdfdb..4c748169f5c 100644 --- a/dev-tools/checkstyle_suppressions.xml +++ b/dev-tools/checkstyle_suppressions.xml @@ -8,12 +8,6 @@ - - - - - - diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/Attribute.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/Attribute.java index a55638c2c3c..c3994f50dad 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/Attribute.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/Attribute.java @@ -59,26 +59,32 @@ public abstract class Attribute extends NamedExpression { } public Attribute withLocation(Location location) { - return Objects.equals(location(), location) ? this : clone(location, name(), dataType(), qualifier(), nullable(), id(), synthetic()); + return Objects.equals(location(), location) ? this : clone(location, name(), dataType(), qualifier(), + nullable(), id(), synthetic()); } public Attribute withQualifier(String qualifier) { - return Objects.equals(qualifier(), qualifier) ? this : clone(location(), name(), dataType(), qualifier, nullable(), id(), synthetic()); + return Objects.equals(qualifier(), qualifier) ? this : clone(location(), name(), dataType(), qualifier, + nullable(), id(), synthetic()); } public Attribute withName(String name) { - return Objects.equals(name(), name) ? this : clone(location(), name, dataType(), qualifier(), nullable(), id(), synthetic()); + return Objects.equals(name(), name) ? this : clone(location(), name, dataType(), qualifier(), nullable(), + id(), synthetic()); } public Attribute withNullability(boolean nullable) { - return Objects.equals(nullable(), nullable) ? this : clone(location(), name(), dataType(), qualifier(), nullable, id(), synthetic()); + return Objects.equals(nullable(), nullable) ? this : clone(location(), name(), dataType(), qualifier(), + nullable, id(), synthetic()); } public Attribute withId(ExpressionId id) { - return Objects.equals(id(), id) ? this : clone(location(), name(), dataType(), qualifier(), nullable(), id, synthetic()); + return Objects.equals(id(), id) ? this : clone(location(), name(), dataType(), qualifier(), nullable(), + id, synthetic()); } - protected abstract Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic); + protected abstract Attribute clone(Location location, String name, DataType dataType, String qualifier, + boolean nullable, ExpressionId id, boolean synthetic); @Override public Attribute toAttribute() { diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/ExpressionIdGenerator.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/ExpressionIdGenerator.java index 957898a84dc..ee23f41e8de 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/ExpressionIdGenerator.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/ExpressionIdGenerator.java @@ -8,7 +8,8 @@ package org.elasticsearch.xpack.sql.expression; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; -//TODO: this class is thread-safe but used across multiple sessions might cause the id to roll over and potentially generate an already assigned id +//TODO: this class is thread-safe but used across multiple sessions might cause the +// id to roll over and potentially generate an already assigned id // making this session scope would simplify things // (which also begs the question on whether thread-safety is needed than) diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/FieldAttribute.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/FieldAttribute.java index 7192f8eed3a..b2a8feed98c 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/FieldAttribute.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/FieldAttribute.java @@ -109,7 +109,8 @@ public class FieldAttribute extends TypedAttribute { } @Override - protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) { + protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, + ExpressionId id, boolean synthetic) { FieldAttribute qualifiedParent = parent != null ? (FieldAttribute) parent.withQualifier(qualifier) : null; return new FieldAttribute(location, qualifiedParent, name, dataType, qualifier, nullable, id, synthetic); } @@ -128,4 +129,4 @@ public class FieldAttribute extends TypedAttribute { protected String label() { return "f"; } -} \ No newline at end of file +} diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/LiteralAttribute.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/LiteralAttribute.java index c656a0d7975..f8b9f82eb5b 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/LiteralAttribute.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/LiteralAttribute.java @@ -29,7 +29,8 @@ public class LiteralAttribute extends TypedAttribute { } @Override - protected LiteralAttribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) { + protected LiteralAttribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, + ExpressionId id, boolean synthetic) { return new LiteralAttribute(location, name, qualifier, nullable, id, synthetic, dataType, literal); } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/TypedAttribute.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/TypedAttribute.java index ebd66f0ad0e..1c8034f059a 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/TypedAttribute.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/TypedAttribute.java @@ -18,7 +18,8 @@ public abstract class TypedAttribute extends Attribute { this(location, name, dataType, null, true, null, false); } - protected TypedAttribute(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) { + protected TypedAttribute(Location location, String name, DataType dataType, String qualifier, boolean nullable, + ExpressionId id, boolean synthetic) { super(location, name, qualifier, nullable, id, synthetic); this.dataType = dataType; } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/UnresolvedAttribute.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/UnresolvedAttribute.java index b87bd35cba3..9b3e87be026 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/UnresolvedAttribute.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/UnresolvedAttribute.java @@ -36,7 +36,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable { this(location, name, qualifier, null, unresolvedMessage, null); } - public UnresolvedAttribute(Location location, String name, String qualifier, ExpressionId id, String unresolvedMessage, Object resolutionMetadata) { + public UnresolvedAttribute(Location location, String name, String qualifier, ExpressionId id, String unresolvedMessage, + Object resolutionMetadata) { super(location, name, qualifier, id); this.customMessage = unresolvedMessage != null; this.unresolvedMsg = unresolvedMessage == null ? errorMessage(qualifiedName(), null) : unresolvedMessage; @@ -58,7 +59,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable { } @Override - protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) { + protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, + ExpressionId id, boolean synthetic) { return this; } @@ -94,7 +96,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable { public static String errorMessage(String name, List potentialMatches) { String msg = "Unknown column [" + name + "]"; if (!CollectionUtils.isEmpty(potentialMatches)) { - msg += ", did you mean " + (potentialMatches.size() == 1 ? "[" + potentialMatches.get(0) + "]": "any of " + potentialMatches.toString()) + "?"; + msg += ", did you mean " + (potentialMatches.size() == 1 ? "[" + potentialMatches.get(0) + + "]": "any of " + potentialMatches.toString()) + "?"; } return msg; } @@ -112,4 +115,4 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable { } return false; } -} \ No newline at end of file +}