Skip to content

Commit c0d91d2

Browse files
committed
Remove copy method. It is not needed since every withXxx() method returns a copy
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1508966 13f79535-47bb-0310-9956-ffa450edef68
1 parent 55eff9d commit c0d91d2

2 files changed

Lines changed: 13 additions & 26 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,6 @@ public static CSVFormat newFormat(final char delimiter) {
171171
return new CSVFormat(delimiter, null, null, null, null, false, false, null, null, null, false);
172172
}
173173

174-
/**
175-
* Creates a CSVFormatBuilder, using the values of the given CSVFormat.
176-
*
177-
* @param format
178-
* The format to use values from
179-
* @return a new CSVFormat
180-
*/
181-
public static CSVFormat copy(final CSVFormat format) {
182-
return new CSVFormat(format);
183-
}
184-
185174
/**
186175
* Creates a customized CSV format.
187176
*
@@ -230,12 +219,6 @@ public static CSVFormat copy(final CSVFormat format) {
230219
this.skipHeaderRecord = skipHeaderRecord;
231220
}
232221

233-
CSVFormat(final CSVFormat format) {
234-
this(format.getDelimiter(), format.getQuoteChar(), format.getQuotePolicy(), format.getCommentStart(),
235-
format.getEscape(), format.getIgnoreSurroundingSpaces(), format.getIgnoreEmptyLines(),
236-
format.getRecordSeparator(), format.getNullString(), format.getHeader(), format.getSkipHeaderRecord());
237-
}
238-
239222
@Override
240223
public boolean equals(final Object obj) {
241224
if (this == obj) {

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testDuplicateHeaderElements() {
6565
@Test
6666
public void testEquals() {
6767
final CSVFormat right = CSVFormat.DEFAULT;
68-
final CSVFormat left = CSVFormat.copy(right);
68+
final CSVFormat left = copy(right);
6969

7070
assertFalse(right.equals(null));
7171
assertFalse(right.equals("A String Instance"));
@@ -84,7 +84,7 @@ public void testEqualsCommentStart() {
8484
.withQuoteChar('"')
8585
.withCommentStart('#')
8686
.withQuotePolicy(Quote.ALL);
87-
final CSVFormat left = CSVFormat.copy(right)
87+
final CSVFormat left = right
8888
.withCommentStart('!');
8989

9090
assertNotEquals(right, left);
@@ -105,7 +105,7 @@ public void testEqualsEscape() {
105105
.withCommentStart('#')
106106
.withEscape('+')
107107
.withQuotePolicy(Quote.ALL);
108-
final CSVFormat left = CSVFormat.copy(right)
108+
final CSVFormat left = right
109109
.withEscape('!');
110110

111111
assertNotEquals(right, left);
@@ -122,7 +122,7 @@ public void testEqualsHeader() {
122122
.withIgnoreSurroundingSpaces(true)
123123
.withQuoteChar('"')
124124
.withQuotePolicy(Quote.ALL);
125-
final CSVFormat left = CSVFormat.copy(right)
125+
final CSVFormat left = right
126126
.withHeader("Three", "Two", "One");
127127

128128
assertNotEquals(right, left);
@@ -137,7 +137,7 @@ public void testEqualsIgnoreEmptyLines() {
137137
.withIgnoreSurroundingSpaces(true)
138138
.withQuoteChar('"')
139139
.withQuotePolicy(Quote.ALL);
140-
final CSVFormat left = CSVFormat.copy(right)
140+
final CSVFormat left = right
141141
.withIgnoreEmptyLines(false);
142142

143143
assertNotEquals(right, left);
@@ -151,7 +151,7 @@ public void testEqualsIgnoreSurroundingSpaces() {
151151
.withIgnoreSurroundingSpaces(true)
152152
.withQuoteChar('"')
153153
.withQuotePolicy(Quote.ALL);
154-
final CSVFormat left = CSVFormat.copy(right)
154+
final CSVFormat left = right
155155
.withIgnoreSurroundingSpaces(false);
156156

157157
assertNotEquals(right, left);
@@ -160,7 +160,7 @@ public void testEqualsIgnoreSurroundingSpaces() {
160160
@Test
161161
public void testEqualsQuoteChar() {
162162
final CSVFormat right = CSVFormat.newFormat('\'').withQuoteChar('"');
163-
final CSVFormat left = CSVFormat.copy(right).withQuoteChar('!');
163+
final CSVFormat left = right.withQuoteChar('!');
164164

165165
assertNotEquals(right, left);
166166
}
@@ -170,7 +170,7 @@ public void testEqualsQuotePolicy() {
170170
final CSVFormat right = CSVFormat.newFormat('\'')
171171
.withQuoteChar('"')
172172
.withQuotePolicy(Quote.ALL);
173-
final CSVFormat left = CSVFormat.copy(right)
173+
final CSVFormat left = right
174174
.withQuotePolicy(Quote.MINIMAL);
175175

176176
assertNotEquals(right, left);
@@ -186,7 +186,7 @@ public void testEqualsRecordSeparator() {
186186
.withIgnoreSurroundingSpaces(true)
187187
.withQuoteChar('"')
188188
.withQuotePolicy(Quote.ALL);
189-
final CSVFormat left = CSVFormat.copy(right)
189+
final CSVFormat left = right
190190
.withRecordSeparator('!');
191191

192192
assertNotEquals(right, left);
@@ -366,4 +366,8 @@ public void testWithRecordSeparator() throws Exception {
366366
CSVFormat formatWithRecordSeparator = CSVFormat.DEFAULT.withRecordSeparator('!');
367367
assertEquals("!", formatWithRecordSeparator.getRecordSeparator());
368368
}
369+
370+
private static CSVFormat copy(final CSVFormat format) {
371+
return format.withDelimiter(format.getDelimiter());
372+
}
369373
}

0 commit comments

Comments
 (0)