| 1 | /* | |
| 2 | * Copyright 2004 the original author or authors. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package com.ancientprogramming.fixedformat4j.io.write; | |
| 17 | ||
| 18 | import com.ancientprogramming.fixedformat4j.format.FixedFormatManager; | |
| 19 | import com.ancientprogramming.fixedformat4j.format.impl.FixedFormatManagerImpl; | |
| 20 | ||
| 21 | import java.nio.charset.Charset; | |
| 22 | import java.nio.charset.StandardCharsets; | |
| 23 | import java.util.Objects; | |
| 24 | ||
| 25 | /** | |
| 26 | * Fluent builder for {@link FixedFormatWriter}. | |
| 27 | * | |
| 28 | * <p>Obtain an instance via {@link FixedFormatWriter#builder()}. | |
| 29 | * All options are optional; sensible defaults are provided for each.</p> | |
| 30 | * | |
| 31 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 32 | * @since 1.9.0 | |
| 33 | */ | |
| 34 | public final class FixedFormatWriterBuilder { | |
| 35 | ||
| 36 |
2
1. <init> : removed call to com/ancientprogramming/fixedformat4j/format/impl/FixedFormatManagerImpl::create → KILLED 2. <init> : Removed assignment to member variable manager → KILLED |
FixedFormatManager manager = FixedFormatManagerImpl.create(); |
| 37 |
2
1. <init> : removed call to java/lang/System::lineSeparator → SURVIVED 2. <init> : Removed assignment to member variable lineSeparator → SURVIVED |
String lineSeparator = System.lineSeparator(); |
| 38 |
1
1. <init> : Removed assignment to member variable charset → SURVIVED |
Charset charset = StandardCharsets.UTF_8; |
| 39 | ||
| 40 | FixedFormatWriterBuilder() {} | |
| 41 | ||
| 42 | /** | |
| 43 | * Overrides the {@link FixedFormatManager} used to export each record to a string. | |
| 44 | * | |
| 45 | * @param manager the manager to use; must not be {@code null} | |
| 46 | * @return this builder | |
| 47 | */ | |
| 48 | public FixedFormatWriterBuilder manager(FixedFormatManager manager) { | |
| 49 |
2
1. manager : removed call to java/util/Objects::requireNonNull → KILLED 2. manager : replaced call to java/util/Objects::requireNonNull with argument → KILLED |
Objects.requireNonNull(manager, "manager must not be null"); |
| 50 |
1
1. manager : Removed assignment to member variable manager → KILLED |
this.manager = manager; |
| 51 |
1
1. manager : replaced return value with null for com/ancientprogramming/fixedformat4j/io/write/FixedFormatWriterBuilder::manager → KILLED |
return this; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Overrides the line separator written after each exported record. | |
| 56 | * Defaults to {@link System#lineSeparator()}. | |
| 57 | * | |
| 58 | * @param lineSeparator the line separator string; must not be {@code null} | |
| 59 | * @return this builder | |
| 60 | */ | |
| 61 | public FixedFormatWriterBuilder lineSeparator(String lineSeparator) { | |
| 62 |
2
1. lineSeparator : replaced call to java/util/Objects::requireNonNull with argument → KILLED 2. lineSeparator : removed call to java/util/Objects::requireNonNull → KILLED |
Objects.requireNonNull(lineSeparator, "lineSeparator must not be null"); |
| 63 |
1
1. lineSeparator : Removed assignment to member variable lineSeparator → KILLED |
this.lineSeparator = lineSeparator; |
| 64 |
1
1. lineSeparator : replaced return value with null for com/ancientprogramming/fixedformat4j/io/write/FixedFormatWriterBuilder::lineSeparator → KILLED |
return this; |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Sets the default charset used when writing to {@link java.io.OutputStream} or | |
| 69 | * {@link java.nio.file.Path} targets without an explicit charset argument. | |
| 70 | * Defaults to {@link StandardCharsets#UTF_8}. | |
| 71 | * | |
| 72 | * @param charset the default charset; must not be {@code null} | |
| 73 | * @return this builder | |
| 74 | */ | |
| 75 | public FixedFormatWriterBuilder charset(Charset charset) { | |
| 76 |
2
1. charset : replaced call to java/util/Objects::requireNonNull with argument → KILLED 2. charset : removed call to java/util/Objects::requireNonNull → KILLED |
Objects.requireNonNull(charset, "charset must not be null"); |
| 77 |
1
1. charset : Removed assignment to member variable charset → SURVIVED |
this.charset = charset; |
| 78 |
1
1. charset : replaced return value with null for com/ancientprogramming/fixedformat4j/io/write/FixedFormatWriterBuilder::charset → KILLED |
return this; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Builds and returns a configured {@link FixedFormatWriter}. | |
| 83 | * | |
| 84 | * @return a new writer instance | |
| 85 | */ | |
| 86 | public FixedFormatWriter build() { | |
| 87 |
2
1. build : replaced return value with null for com/ancientprogramming/fixedformat4j/io/write/FixedFormatWriterBuilder::build → KILLED 2. build : removed call to com/ancientprogramming/fixedformat4j/io/write/FixedFormatWriter::<init> → KILLED |
return new FixedFormatWriter(this); |
| 88 | } | |
| 89 | } | |
Mutations | ||
| 36 |
1.1 2.2 |
|
| 37 |
1.1 2.2 |
|
| 38 |
1.1 |
|
| 49 |
1.1 2.2 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |
|
| 62 |
1.1 2.2 |
|
| 63 |
1.1 |
|
| 64 |
1.1 |
|
| 76 |
1.1 2.2 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 87 |
1.1 2.2 |