Skip to content

Commit

Permalink
ATLAS-4957: checkstyle compliance updates - atlas-common module (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
mneethiraj authored Jan 24, 2025
1 parent 1d322d3 commit 155c854
Show file tree
Hide file tree
Showing 54 changed files with 1,291 additions and 1,333 deletions.
5 changes: 5 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<name>Apache Atlas Common</name>
<description>Apache Atlas Common</description>

<properties>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
</properties>

<dependencies>

<dependency>
Expand Down
16 changes: 8 additions & 8 deletions common/src/main/java/org/apache/atlas/AtlasConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -22,20 +22,20 @@
* Constants used in Atlas configuration.
*/
public final class AtlasConstants {
private AtlasConstants() {
}

public static final String CLUSTER_NAME_KEY = "atlas.cluster.name";
public static final String METADATA_NAMESPACE_KEY = "atlas.metadata.namespace";
public static final String DEFAULT_CLUSTER_NAME = "primary";
public static final String SYSTEM_PROPERTY_APP_PORT = "atlas.app.port";
public static final String ATLAS_REST_ADDRESS_KEY = "atlas.rest.address";
public static final String ATLAS_MIGRATION_MODE_FILENAME = "atlas.migration.data.filename";
public static final String ATLAS_SERVICES_ENABLED = "atlas.services.enabled";

public static final String CLUSTER_NAME_ATTRIBUTE = "clusterName";
public static final String DEFAULT_APP_PORT_STR = "21000";
public static final String DEFAULT_ATLAS_REST_ADDRESS = "http://localhost:21000";
public static final String DEFAULT_TYPE_VERSION = "1.0";
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30;
}

private AtlasConstants() {
// to block instantiation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ ElementType.TYPE, ElementType.METHOD })
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Conditional(OnAtlasPropertyCondition.class)
public @interface ConditionalOnAtlasProperty {
// Configured atlas property
String property();

// The default interface implementation should declare this as true
boolean isDefault() default false;
}
11 changes: 5 additions & 6 deletions common/src/main/java/org/apache/atlas/annotation/Timed.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -17,16 +17,15 @@
*/
package org.apache.atlas.annotation;


import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD})
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Timed {
String value() default "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -21,9 +21,8 @@
* Base class for all expression that can have a caller.
*/
public abstract class AbstractFunctionExpression extends AbstractGroovyExpression {

// null for global functions
private GroovyExpression caller;
private GroovyExpression caller;
private TraversalStepType type = TraversalStepType.NONE;

public AbstractFunctionExpression(GroovyExpression target) {
Expand All @@ -32,26 +31,23 @@ public AbstractFunctionExpression(GroovyExpression target) {

public AbstractFunctionExpression(TraversalStepType type, GroovyExpression target) {
this.caller = target;
this.type = type;
this.type = type;
}

public GroovyExpression getCaller() {
public GroovyExpression getCaller() {
return caller;
}

public void setCaller(GroovyExpression expr) {
caller = expr;
}


public void setType(TraversalStepType type) {
this.type = type;
}

@Override
public TraversalStepType getType() {
return type;
}


public void setType(TraversalStepType type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -24,7 +24,6 @@
*
*/
public abstract class AbstractGroovyExpression implements GroovyExpression {

@Override
public String toString() {
GroovyGenerationContext ctx = new GroovyGenerationContext();
Expand All @@ -34,12 +33,12 @@ public String toString() {
}

@Override
public TraversalStepType getType() {
return TraversalStepType.NONE;
public GroovyExpression copy() {
return copy(getChildren());
}

@Override
public GroovyExpression copy() {
return copy(getChildren());
public TraversalStepType getType() {
return TraversalStepType.NONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -25,47 +25,47 @@
* Represents an arithmetic expression such as a+b.
*/
public class ArithmeticExpression extends BinaryExpression {
public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
super(left, op.getGroovyValue(), right);
}

private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
super(left, op, right);
}

@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
}

/**
* Allowed arithmetic operators.
*/
public enum ArithmeticOperator {
public enum ArithmeticOperator {
PLUS("+"),
MINUS("-"),
TIMES("*"),
DIVIDE("/"),
MODULUS("%");

private String groovyValue;
private final String groovyValue;

ArithmeticOperator(String groovyValue) {
this.groovyValue = groovyValue;
}
public String getGroovyValue() {
return groovyValue;
}

public static ArithmeticOperator lookup(String groovyValue) throws AtlasException {
for(ArithmeticOperator op : ArithmeticOperator.values()) {
for (ArithmeticOperator op : ArithmeticOperator.values()) {
if (op.getGroovyValue().equals(groovyValue)) {
return op;
}
}

throw new AtlasException("Unknown Operator:" + groovyValue);
}

}

public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
super(left, op.getGroovyValue(), right);
}

private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
super(left, op, right);
}

@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
assert newChildren.size() == 2;
return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
public String getGroovyValue() {
return groovyValue;
}
}
}
21 changes: 10 additions & 11 deletions common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -29,25 +29,24 @@
*
*/
public abstract class BinaryExpression extends AbstractGroovyExpression {


private GroovyExpression left;
private GroovyExpression right;
protected String op;
protected String op;
private final GroovyExpression left;
private final GroovyExpression right;

public BinaryExpression(GroovyExpression left, String op, GroovyExpression right) {
this.left = left;
this.op = op;
this.left = left;
this.op = op;
this.right = right;
}

@Override
public void generateGroovy(GroovyGenerationContext context) {

left.generateGroovy(context);

context.append(" ");
context.append(op);
context.append(" ");

right.generateGroovy(context);
}

Expand Down
20 changes: 10 additions & 10 deletions common/src/main/java/org/apache/atlas/groovy/CastExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -25,32 +25,32 @@
* Groovy expression that represents a cast.
*/
public class CastExpression extends AbstractGroovyExpression {

private GroovyExpression expr;
private String className;
private final GroovyExpression expr;
private final String className;

public CastExpression(GroovyExpression expr, String className) {
this.expr = expr;
this.className = className;
this.expr = expr;
this.className = className;
}

@Override
public void generateGroovy(GroovyGenerationContext context) {

context.append("((");
context.append(className);
context.append(")");

expr.generateGroovy(context);

context.append(")");
}

@Override
public List<GroovyExpression> getChildren() {
return Collections.singletonList(expr);
}

@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
assert newChildren.size() == 1;
return new CastExpression(newChildren.get(0), className);
}
}
Loading

0 comments on commit 155c854

Please sign in to comment.