Skip to content

Commit 155c854

Browse files
authored
ATLAS-4957: checkstyle compliance updates - atlas-common module (#272)
1 parent 1d322d3 commit 155c854

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1291
-1333
lines changed

common/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
<name>Apache Atlas Common</name>
3232
<description>Apache Atlas Common</description>
3333

34+
<properties>
35+
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
36+
<checkstyle.skip>false</checkstyle.skip>
37+
</properties>
38+
3439
<dependencies>
3540

3641
<dependency>

common/src/main/java/org/apache/atlas/AtlasConstants.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,20 +22,20 @@
2222
* Constants used in Atlas configuration.
2323
*/
2424
public final class AtlasConstants {
25-
private AtlasConstants() {
26-
}
27-
2825
public static final String CLUSTER_NAME_KEY = "atlas.cluster.name";
2926
public static final String METADATA_NAMESPACE_KEY = "atlas.metadata.namespace";
3027
public static final String DEFAULT_CLUSTER_NAME = "primary";
3128
public static final String SYSTEM_PROPERTY_APP_PORT = "atlas.app.port";
3229
public static final String ATLAS_REST_ADDRESS_KEY = "atlas.rest.address";
3330
public static final String ATLAS_MIGRATION_MODE_FILENAME = "atlas.migration.data.filename";
3431
public static final String ATLAS_SERVICES_ENABLED = "atlas.services.enabled";
35-
3632
public static final String CLUSTER_NAME_ATTRIBUTE = "clusterName";
3733
public static final String DEFAULT_APP_PORT_STR = "21000";
3834
public static final String DEFAULT_ATLAS_REST_ADDRESS = "http://localhost:21000";
3935
public static final String DEFAULT_TYPE_VERSION = "1.0";
4036
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30;
41-
}
37+
38+
private AtlasConstants() {
39+
// to block instantiation
40+
}
41+
}

common/src/main/java/org/apache/atlas/annotation/ConditionalOnAtlasProperty.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
import java.lang.annotation.RetentionPolicy;
2626
import java.lang.annotation.Target;
2727

28-
@Target({ ElementType.TYPE, ElementType.METHOD })
28+
@Target({ElementType.TYPE, ElementType.METHOD})
2929
@Retention(RetentionPolicy.RUNTIME)
3030
@Conditional(OnAtlasPropertyCondition.class)
3131
public @interface ConditionalOnAtlasProperty {
3232
// Configured atlas property
3333
String property();
34+
3435
// The default interface implementation should declare this as true
3536
boolean isDefault() default false;
3637
}

common/src/main/java/org/apache/atlas/annotation/Timed.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,15 @@
1717
*/
1818
package org.apache.atlas.annotation;
1919

20-
2120
import java.lang.annotation.ElementType;
2221
import java.lang.annotation.Inherited;
2322
import java.lang.annotation.Retention;
2423
import java.lang.annotation.RetentionPolicy;
2524
import java.lang.annotation.Target;
2625

27-
@Target({ElementType.METHOD})
26+
@Target(ElementType.METHOD)
2827
@Retention(RetentionPolicy.RUNTIME)
2928
@Inherited
3029
public @interface Timed {
3130
String value() default "";
32-
}
31+
}

common/src/main/java/org/apache/atlas/groovy/AbstractFunctionExpression.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,9 +21,8 @@
2121
* Base class for all expression that can have a caller.
2222
*/
2323
public abstract class AbstractFunctionExpression extends AbstractGroovyExpression {
24-
2524
// null for global functions
26-
private GroovyExpression caller;
25+
private GroovyExpression caller;
2726
private TraversalStepType type = TraversalStepType.NONE;
2827

2928
public AbstractFunctionExpression(GroovyExpression target) {
@@ -32,26 +31,23 @@ public AbstractFunctionExpression(GroovyExpression target) {
3231

3332
public AbstractFunctionExpression(TraversalStepType type, GroovyExpression target) {
3433
this.caller = target;
35-
this.type = type;
34+
this.type = type;
3635
}
3736

38-
public GroovyExpression getCaller() {
37+
public GroovyExpression getCaller() {
3938
return caller;
4039
}
4140

4241
public void setCaller(GroovyExpression expr) {
4342
caller = expr;
4443
}
4544

46-
47-
public void setType(TraversalStepType type) {
48-
this.type = type;
49-
}
50-
5145
@Override
5246
public TraversalStepType getType() {
5347
return type;
5448
}
5549

56-
50+
public void setType(TraversalStepType type) {
51+
this.type = type;
52+
}
5753
}

common/src/main/java/org/apache/atlas/groovy/AbstractGroovyExpression.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,6 @@
2424
*
2525
*/
2626
public abstract class AbstractGroovyExpression implements GroovyExpression {
27-
2827
@Override
2928
public String toString() {
3029
GroovyGenerationContext ctx = new GroovyGenerationContext();
@@ -34,12 +33,12 @@ public String toString() {
3433
}
3534

3635
@Override
37-
public TraversalStepType getType() {
38-
return TraversalStepType.NONE;
36+
public GroovyExpression copy() {
37+
return copy(getChildren());
3938
}
4039

4140
@Override
42-
public GroovyExpression copy() {
43-
return copy(getChildren());
41+
public TraversalStepType getType() {
42+
return TraversalStepType.NONE;
4443
}
4544
}

common/src/main/java/org/apache/atlas/groovy/ArithmeticExpression.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,47 +25,47 @@
2525
* Represents an arithmetic expression such as a+b.
2626
*/
2727
public class ArithmeticExpression extends BinaryExpression {
28+
public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
29+
super(left, op.getGroovyValue(), right);
30+
}
31+
32+
private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
33+
super(left, op, right);
34+
}
35+
36+
@Override
37+
public GroovyExpression copy(List<GroovyExpression> newChildren) {
38+
return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
39+
}
2840

2941
/**
3042
* Allowed arithmetic operators.
3143
*/
32-
public enum ArithmeticOperator {
44+
public enum ArithmeticOperator {
3345
PLUS("+"),
3446
MINUS("-"),
3547
TIMES("*"),
3648
DIVIDE("/"),
3749
MODULUS("%");
3850

39-
private String groovyValue;
51+
private final String groovyValue;
52+
4053
ArithmeticOperator(String groovyValue) {
4154
this.groovyValue = groovyValue;
4255
}
43-
public String getGroovyValue() {
44-
return groovyValue;
45-
}
4656

4757
public static ArithmeticOperator lookup(String groovyValue) throws AtlasException {
48-
for(ArithmeticOperator op : ArithmeticOperator.values()) {
58+
for (ArithmeticOperator op : ArithmeticOperator.values()) {
4959
if (op.getGroovyValue().equals(groovyValue)) {
5060
return op;
5161
}
5262
}
63+
5364
throw new AtlasException("Unknown Operator:" + groovyValue);
5465
}
5566

56-
}
57-
58-
public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
59-
super(left, op.getGroovyValue(), right);
60-
}
61-
62-
private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
63-
super(left, op, right);
64-
}
65-
66-
@Override
67-
public GroovyExpression copy(List<GroovyExpression> newChildren) {
68-
assert newChildren.size() == 2;
69-
return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
67+
public String getGroovyValue() {
68+
return groovyValue;
69+
}
7070
}
7171
}

common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,25 +29,24 @@
2929
*
3030
*/
3131
public abstract class BinaryExpression extends AbstractGroovyExpression {
32-
33-
34-
private GroovyExpression left;
35-
private GroovyExpression right;
36-
protected String op;
32+
protected String op;
33+
private final GroovyExpression left;
34+
private final GroovyExpression right;
3735

3836
public BinaryExpression(GroovyExpression left, String op, GroovyExpression right) {
39-
this.left = left;
40-
this.op = op;
37+
this.left = left;
38+
this.op = op;
4139
this.right = right;
4240
}
4341

4442
@Override
4543
public void generateGroovy(GroovyGenerationContext context) {
46-
4744
left.generateGroovy(context);
45+
4846
context.append(" ");
4947
context.append(op);
5048
context.append(" ");
49+
5150
right.generateGroovy(context);
5251
}
5352

common/src/main/java/org/apache/atlas/groovy/CastExpression.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,32 +25,32 @@
2525
* Groovy expression that represents a cast.
2626
*/
2727
public class CastExpression extends AbstractGroovyExpression {
28-
29-
private GroovyExpression expr;
30-
private String className;
28+
private final GroovyExpression expr;
29+
private final String className;
3130

3231
public CastExpression(GroovyExpression expr, String className) {
33-
this.expr = expr;
34-
this.className = className;
32+
this.expr = expr;
33+
this.className = className;
3534
}
3635

3736
@Override
3837
public void generateGroovy(GroovyGenerationContext context) {
39-
4038
context.append("((");
4139
context.append(className);
4240
context.append(")");
41+
4342
expr.generateGroovy(context);
43+
4444
context.append(")");
4545
}
4646

4747
@Override
4848
public List<GroovyExpression> getChildren() {
4949
return Collections.singletonList(expr);
5050
}
51+
5152
@Override
5253
public GroovyExpression copy(List<GroovyExpression> newChildren) {
53-
assert newChildren.size() == 1;
5454
return new CastExpression(newChildren.get(0), className);
5555
}
5656
}

0 commit comments

Comments
 (0)