Skip to content

Commit

Permalink
Replace usage of Apache commons-lang3
Browse files Browse the repository at this point in the history
- Introduce compact custom implementations
- Avoid dependency on commons-lang3 completely
- More toString refinements to follow soon (do away with
reflectionToString etc.)
  • Loading branch information
spannm committed Feb 15, 2024
1 parent 3b26380 commit d064f6a
Show file tree
Hide file tree
Showing 33 changed files with 564 additions and 418 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@

<developerId>spannm</developerId>

<dep.commons-lang3.version>3.14.0</dep.commons-lang3.version>
<dep.commons-logging.version>1.3.0</dep.commons-logging.version>
<dep.poi.version>4.1.2</dep.poi.version>

Expand All @@ -116,11 +115,6 @@

<dependencies>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${dep.commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
37 changes: 17 additions & 20 deletions src/main/java/io/github/spannm/jackcess/impl/ColumnImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.github.spannm.jackcess.impl.expr.NumberFormatter;
import io.github.spannm.jackcess.util.ColumnValidator;
import io.github.spannm.jackcess.util.SimpleColumnValidator;
import org.apache.commons.lang3.builder.ToStringBuilder;
import io.github.spannm.jackcess.util.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -1624,21 +1624,18 @@ private static byte getColumnBitFlags(ColumnBuilder col) {

@Override
public String toString() {
ToStringBuilder sb = CustomToStringStyle.builder(this)
.append("name", "(" + _table.getName() + ") " + _name);
byte typeValue = getOriginalDataType();
sb.append("type", "0x" + Integer.toHexString(typeValue) + " (" + _type + ")")
.append("number", _columnNumber)
.append("length", _columnLength)
.append("variableLength", _variableLength);
ToStringBuilder sb = ToStringBuilder.builder(this)
.append("name", "(" + _table.getName() + ") " + _name)
.append("type", "0x" + Integer.toHexString(getOriginalDataType()) + " (" + _type + ")")
.append("number", _columnNumber)
.append("length", _columnLength)
.append("variableLength", _variableLength);
if (_calculated) {
sb.append("calculated", _calculated)
.append("expression",
CustomToStringStyle.ignoreNull(getCalculationContext()));
.appendIgnoreNull("expression", getCalculationContext());
}
if (_type.isTextual()) {
sb.append("compressedUnicode", isCompressedUnicode())
.append("textSortOrder", getTextSortOrder());
sb.append("compressedUnicode", isCompressedUnicode()).append("textSortOrder", getTextSortOrder());
if (getTextCodePage() > 0) {
sb.append("textCodePage", getTextCodePage());
}
Expand All @@ -1651,16 +1648,16 @@ public String toString() {
}
if (_type.getHasScalePrecision()) {
sb.append("precision", getPrecision())
.append("scale", getScale());
.append("scale", getScale());
}
if (_autoNumber) {
sb.append("lastAutoNumber", _autoNumberGenerator.getLast());
}
sb.append("complexInfo", CustomToStringStyle.ignoreNull(getComplexInfo()))
.append("validator", CustomToStringStyle.ignoreNull(
_validator != SimpleColumnValidator.INSTANCE ? _validator : null))
.append("defaultValue", CustomToStringStyle.ignoreNull(_defValue));
return sb.toString();
return sb
.appendIgnoreNull("complexInfo", getComplexInfo())
.appendIgnoreNull("validator", _validator != SimpleColumnValidator.INSTANCE ? _validator : null)
.appendIgnoreNull("defaultValue", _defValue)
.toString();
}

/**
Expand Down Expand Up @@ -2217,7 +2214,7 @@ public byte[] getBytes() {

@Override
public String toString() {
return CustomToStringStyle.valueBuilder(this)
return ToStringBuilder.valueBuilder(this)
.append(null, getBytes())
.toString();
}
Expand Down Expand Up @@ -2490,7 +2487,7 @@ public boolean equals(Object o) {

@Override
public String toString() {
return CustomToStringStyle.valueBuilder(this)
return ToStringBuilder.valueBuilder(this)
.append(null, _value + "(" + _version + ")")
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.github.spannm.jackcess.util.MemFileChannel;
import io.github.spannm.jackcess.util.OleBlob.CompoundContent;
import io.github.spannm.jackcess.util.OleBlob.ContentType;
import org.apache.commons.lang3.builder.ToStringBuilder;
import io.github.spannm.jackcess.util.ToStringBuilder;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
Expand Down Expand Up @@ -185,7 +185,7 @@ private List<Entry> getEntries(List<Entry> entries, DirectoryEntry dir,
// .. recurse into this directory
getEntries(entries, (DirectoryEntry) entry, prefix + ENTRY_SEPARATOR);
} else if (entry instanceof DocumentEntry) {
// grab the entry name/detils
// grab the entry name/details
DocumentEntry de = (DocumentEntry) entry;
String entryName = prefix + encodeEntryName(entry.getName());
entries.add(new EntryImpl(entryName, de));
Expand All @@ -203,13 +203,11 @@ public void close() {

@Override
public String toString() {
ToStringBuilder sb = toString(CustomToStringStyle.builder(this));
ToStringBuilder sb = toString(ToStringBuilder.builder(this));

try {
sb.append("hasContentsEntry", hasContentsEntry());
sb.append("entries", getEntries(new ArrayList<>(),
getFileSystem().getRoot(),
ENTRY_SEPARATOR));
sb.append("hasContentsEntry", hasContentsEntry())
.append("entries", getEntries(new ArrayList<Entry>(), getFileSystem().getRoot(), ENTRY_SEPARATOR));
} catch (IOException e) {
sb.append("entries", "<" + e + ">");
}
Expand Down Expand Up @@ -265,7 +263,7 @@ public void writeTo(OutputStream out) throws IOException {

@Override
public String toString() {
return CustomToStringStyle.valueBuilder(this)
return ToStringBuilder.valueBuilder(this)
.append("name", _name)
.append("length", length())
.toString();
Expand Down
208 changes: 0 additions & 208 deletions src/main/java/io/github/spannm/jackcess/impl/CustomToStringStyle.java

This file was deleted.

Loading

0 comments on commit d064f6a

Please sign in to comment.