Address JavaFormat Violations in Odm

Issue gh-743
This commit is contained in:
Josh Cummings
2023-05-09 16:44:35 -06:00
parent 01432fbe79
commit fad41841c9
6 changed files with 142 additions and 120 deletions

View File

@@ -84,18 +84,55 @@ public final class AttributeSchema {
return this.isMultiValued;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format(
"{ name=%1$s, syntax=%2$s, isMultiValued=%3$s, isPrimitive=%4$s, isBinary=%5$s, isArray=%6$s, scalarType=%7$s }",
this.name, this.syntax, this.isMultiValued, this.isPrimitive, this.isBinary, this.isArray,
this.scalarType);
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
AttributeSchema other = (AttributeSchema) obj;
if (this.isArray != other.isArray) {
return false;
}
if (this.isBinary != other.isBinary) {
return false;
}
if (this.isMultiValued != other.isMultiValued) {
return false;
}
if (this.isPrimitive != other.isPrimitive) {
return false;
}
if (this.name == null) {
if (other.name != null) {
return false;
}
}
else if (!this.name.equals(other.name)) {
return false;
}
if (this.scalarType == null) {
if (other.scalarType != null) {
return false;
}
}
else if (!this.scalarType.equals(other.scalarType)) {
return false;
}
if (this.syntax == null) {
if (other.syntax != null) {
return false;
}
}
else if (!this.syntax.equals(other.syntax)) {
return false;
}
return true;
}
@Override
@@ -112,42 +149,18 @@ public final class AttributeSchema {
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AttributeSchema other = (AttributeSchema) obj;
if (this.isArray != other.isArray)
return false;
if (this.isBinary != other.isBinary)
return false;
if (this.isMultiValued != other.isMultiValued)
return false;
if (this.isPrimitive != other.isPrimitive)
return false;
if (this.name == null) {
if (other.name != null)
return false;
}
else if (!this.name.equals(other.name))
return false;
if (this.scalarType == null) {
if (other.scalarType != null)
return false;
}
else if (!this.scalarType.equals(other.scalarType))
return false;
if (this.syntax == null) {
if (other.syntax != null)
return false;
}
else if (!this.syntax.equals(other.syntax))
return false;
return true;
public String toString() {
return String.format(
"{ name=%1$s, syntax=%2$s, isMultiValued=%3$s, isPrimitive=%4$s, isBinary=%5$s, isArray=%6$s, scalarType=%7$s }",
this.name, this.syntax, this.isMultiValued, this.isPrimitive, this.isBinary, this.isArray,
this.scalarType);
}
}

View File

@@ -66,14 +66,43 @@ public final class ObjectSchema {
return Collections.unmodifiableSet(this.objectClass);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format("objectClass=%1$s | must=%2$s | may=%3$s", this.objectClass, this.must, this.may);
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ObjectSchema other = (ObjectSchema) obj;
if (this.may == null) {
if (other.may != null) {
return false;
}
}
else if (!this.may.equals(other.may)) {
return false;
}
if (this.must == null) {
if (other.must != null) {
return false;
}
}
else if (!this.must.equals(other.must)) {
return false;
}
if (this.objectClass == null) {
if (other.objectClass != null) {
return false;
}
}
else if (!this.objectClass.equals(other.objectClass)) {
return false;
}
return true;
}
@Override
@@ -86,34 +115,14 @@ public final class ObjectSchema {
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ObjectSchema other = (ObjectSchema) obj;
if (this.may == null) {
if (other.may != null)
return false;
}
else if (!this.may.equals(other.may))
return false;
if (this.must == null) {
if (other.must != null)
return false;
}
else if (!this.must.equals(other.must))
return false;
if (this.objectClass == null) {
if (other.objectClass != null)
return false;
}
else if (!this.objectClass.equals(other.objectClass))
return false;
return true;
public String toString() {
return String.format("objectClass=%1$s | must=%2$s | may=%3$s", this.objectClass, this.must, this.may);
}
}

View File

@@ -360,8 +360,8 @@ public final class SchemaToJava {
try {
cmd = parser.parse(DEFAULT_OPTIONS, argv);
}
catch (ParseException e) {
error(e.toString());
catch (ParseException ex) {
error(ex.toString());
}
// If the help flag is specified ignore other flags, print a usage message and
@@ -390,8 +390,8 @@ public final class SchemaToJava {
try {
outputFile = makeOutputFile(outputDir, packageName, className);
}
catch (IOException e) {
error(e.toString());
catch (IOException ex) {
error(ex.toString());
}
// Get the flags we need to bind to the directory
@@ -418,9 +418,9 @@ public final class SchemaToJava {
try {
syntaxToJavaClass = new SyntaxToJavaClass(readSyntaxMap(syntaxMapFile));
}
catch (IOException e) {
catch (IOException ex) {
error(String.format("Error reading syntax map file %1$s - %2$s", syntaxMapFile.getAbsolutePath(),
e.toString()));
ex.toString()));
}
}
else {
@@ -441,8 +441,8 @@ public final class SchemaToJava {
try {
binarySet = readBinarySet(binarySetFile);
}
catch (IOException e) {
error(String.format("Error reading binary set file %1$s - %2$s", binarySetFile.getAbsolutePath(), e));
catch (IOException ex) {
error(String.format("Error reading binary set file %1$s - %2$s", binarySetFile.getAbsolutePath(), ex));
}
// Read schema from the directory

View File

@@ -201,8 +201,8 @@ public final class SchemaViewer {
try {
cmd = parser.parse(DEFAULT_OPTIONS, argv);
}
catch (ParseException e) {
System.out.println(e.getMessage());
catch (ParseException ex) {
System.out.println(ex.getMessage());
System.exit(1);
}
@@ -253,17 +253,17 @@ public final class SchemaViewer {
}
}
catch (AuthenticationException e) {
catch (AuthenticationException ex) {
System.err.println(String.format("Failed to bind to ldap server at %1$s", url));
}
catch (CommunicationException e) {
catch (CommunicationException ex) {
System.err.println(String.format("Failed to contact ldap server at %1$s", url));
}
catch (NameNotFoundException e) {
System.err.println(String.format("Can't find object %1$s", e.getMessage()));
catch (NameNotFoundException ex) {
System.err.println(String.format("Can't find object %1$s", ex.getMessage()));
}
catch (NamingException e) {
System.err.println(e.toString());
catch (NamingException ex) {
System.err.println(ex.toString());
}
}

View File

@@ -27,6 +27,29 @@ import java.util.Map.Entry;
*/
/* package */ final class SyntaxToJavaClass {
private final Map<String, ClassInfo> mapSyntaxToClassInfo = new HashMap<String, ClassInfo>();
public SyntaxToJavaClass(Map<String, String> mapSyntaxToClass) {
for (Entry<String, String> syntaxAndClass : mapSyntaxToClass.entrySet()) {
String fullClassName = syntaxAndClass.getValue().trim();
String packageName = null;
String className = null;
int lastDotIndex = fullClassName.lastIndexOf('.');
if (lastDotIndex != -1) {
className = fullClassName.substring(lastDotIndex + 1);
packageName = fullClassName.substring(0, lastDotIndex);
}
else {
className = fullClassName;
}
this.mapSyntaxToClassInfo.put(syntaxAndClass.getKey(), new ClassInfo(className, packageName));
}
}
public ClassInfo getClassInfo(String syntax) {
return this.mapSyntaxToClassInfo.get(syntax);
}
public static final class ClassInfo {
private final String className;
@@ -59,27 +82,4 @@ import java.util.Map.Entry;
}
private final Map<String, ClassInfo> mapSyntaxToClassInfo = new HashMap<String, ClassInfo>();
public SyntaxToJavaClass(Map<String, String> mapSyntaxToClass) {
for (Entry<String, String> syntaxAndClass : mapSyntaxToClass.entrySet()) {
String fullClassName = syntaxAndClass.getValue().trim();
String packageName = null;
String className = null;
int lastDotIndex = fullClassName.lastIndexOf('.');
if (lastDotIndex != -1) {
className = fullClassName.substring(lastDotIndex + 1);
packageName = fullClassName.substring(0, lastDotIndex);
}
else {
className = fullClassName;
}
this.mapSyntaxToClassInfo.put(syntaxAndClass.getKey(), new ClassInfo(className, packageName));
}
}
public ClassInfo getClassInfo(String syntax) {
return this.mapSyntaxToClassInfo.get(syntax);
}
}

View File

@@ -21,4 +21,4 @@
* @author Paul Harvey &lt;paul.at.pauls-place.me.uk&gt;
*/
package org.springframework.ldap.odm.tools;
package org.springframework.ldap.odm.tools;