adaptation du projet library en java8
Some checks failed
Java CI with Maven / build (push) Has been cancelled

This commit is contained in:
2026-06-03 23:15:37 +02:00
parent 9f22ce3b14
commit aff4f5080d
18 changed files with 52 additions and 57 deletions

View File

@@ -44,7 +44,7 @@
<github.global.server>github</github.global.server>
<additionalparam>-Xdoclint:none</additionalparam>
<!-- Skip error check for javadoc -->
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>8</maven.compiler.release>
<maven.deploy.skip>true</maven.deploy.skip><!-- do deploy to maven central, parent project does not and inherits -->
</properties>
<dependencies>
@@ -169,8 +169,8 @@
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
mvn clean compile assembly:single -->
<!-- or whatever version you use -->
<source>11</source>
<target>11</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
@@ -331,7 +331,7 @@
<configuration>
<toolchains>
<jdk>
<version>11</version>
<version>8</version>
<vendor>adopt</vendor>
</jdk>
</toolchains>

View File

@@ -5,6 +5,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/***
@@ -115,7 +118,7 @@ public class Contact implements IZUGFeRDExportableContact {
String localName = currentItemNode.getLocalName();
if (localName != null) {
Set<String> nameElements = Set.of("PersonName"/*CII*/, "Name"/*UBL*/);
Set<String> nameElements = new HashSet<>(Arrays.asList("PersonName"/*CII*/, "Name"/*UBL*/));
if (localName != null && nameElements.contains(localName)
&& currentItemNode.getFirstChild()!=null) {
setName(currentItemNode.getFirstChild().getNodeValue());

View File

@@ -335,7 +335,7 @@ public class Item implements IZUGFeRDExportableItem {
return this;
}
@Deprecated(since = "2.14.0")
@Deprecated()
public Item addReferencedLineID(String s) {
return addBuyerOrderReferencedDocumentLineID(s);
}

View File

@@ -1,8 +1,6 @@
package org.mustangproject;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -163,7 +161,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
NodeList taxSchemechilds = partyTaxScheme.item(partyTaxSchemeIndex).getChildNodes();
for (int taxSchemechildsIndex = 0; taxSchemechildsIndex < taxSchemechilds.getLength(); taxSchemechildsIndex++) {
if (taxSchemechilds.item(taxSchemechildsIndex).getLocalName() != null) {
Set<String> taxSchemeTypes = Set.of("FC", "NOVAT");
Set<String> taxSchemeTypes = new HashSet<>(Arrays.asList("FC", "NOVAT"));
String textContent = taxSchemechilds.item(taxSchemechildsIndex).getTextContent();
if (textContent != null && taxSchemeTypes.contains(textContent)) {
setTaxID(CompanyId);

View File

@@ -282,7 +282,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
itemVATAmount.setVatExemptionReasonText(reasonText);
}
final Optional<VATAmount> currentVatAmount = this.getCurrentVatAmount(vatAmounts, currentItem.getProduct().getTaxCategoryCode(), percent);
if (currentVatAmount.isEmpty()) {
if (!currentVatAmount.isPresent()) {
vatAmounts.add(itemVATAmount);
} else {
this.mergeAdding(currentVatAmount.get(), itemVATAmount);
@@ -299,7 +299,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
final BigDecimal chargeBasis = currentCharge.getTotalAmount(this);
final VATAmount chargeVatAmount = new VATAmount(chargeBasis, chargeBasis.multiply(taxPercent.divide(new BigDecimal(100))), vatCategoryCode,
vatDueDateTypeCode, taxPercent);
if (currentChargeVatAmount.isEmpty()) {
if (!currentChargeVatAmount.isPresent()) {
vatAmounts.add(chargeVatAmount);
} else {
this.mergeAdding(currentChargeVatAmount.get(), chargeVatAmount);
@@ -319,7 +319,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
allowanceNegativeBasis.multiply(taxPercent.divide(new BigDecimal(100))),
currentAllowance.getCategoryCode() != null ? currentAllowance.getCategoryCode() : "S",
vatDueDateTypeCode, taxPercent);
if (currentAllowanceVatAmount.isEmpty()) {
if (!currentAllowanceVatAmount.isPresent()) {
vatAmounts.add(allowanceVATAmount);
} else {
this.mergeAdding(currentAllowanceVatAmount.get(), allowanceVATAmount);
@@ -333,10 +333,13 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
public void mergeAdding(VATAmount vatAmount, VATAmount toAdd) {
vatAmount.setBasis(vatAmount.getBasis().add(toAdd.getBasis()));
vatAmount.setCalculated(vatAmount.getCalculated().add(toAdd.getCalculated()));
if (toAdd.getVatExemptionReasonText() != null && !toAdd.getVatExemptionReasonText().isBlank()) {
Optional.ofNullable(vatAmount.getVatExemptionReasonText()).filter(reasonText -> !reasonText.equals(toAdd.getVatExemptionReasonText())).ifPresentOrElse(
text -> vatAmount.setVatExemptionReasonText(String.join(", ", text, toAdd.getVatExemptionReasonText())),
() -> vatAmount.setVatExemptionReasonText(toAdd.getVatExemptionReasonText()));
if (toAdd.getVatExemptionReasonText() != null && !toAdd.getVatExemptionReasonText().trim().isEmpty()) {
Optional<String> text = Optional.ofNullable(vatAmount.getVatExemptionReasonText()).filter(reasonText -> !reasonText.equals(toAdd.getVatExemptionReasonText()));
if (text.isPresent()) {
vatAmount.setVatExemptionReasonText(String.join(", ", text.get(), toAdd.getVatExemptionReasonText()));
} else {
vatAmount.setVatExemptionReasonText(toAdd.getVatExemptionReasonText());
}
}
}

View File

@@ -76,7 +76,7 @@ public class ValidationLogVisualizer {
LOGGER.error("Failed to create PDF", e1);
}
return baos.toString(StandardCharsets.UTF_8);
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}
public byte[] createPDFBytes(String xmlLogfileContent) {

View File

@@ -56,7 +56,7 @@ public class XMLUpgrader {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
applySchematronXsl(new FileInputStream(xmlFilename), baos);
String res = null;
res = baos.toString(StandardCharsets.UTF_8);
res = new String(baos.toByteArray(), StandardCharsets.UTF_8);
return res;
}

View File

@@ -385,7 +385,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
String businessProcessId = trans.getBusinessProcessId();
if (businessProcessId != null && !businessProcessId.isBlank()) {
if (businessProcessId != null && !businessProcessId.trim().isEmpty()) {
xml += "<ram:BusinessProcessSpecifiedDocumentContextParameter>\n"
+ "<ram:ID>" + XMLTools.encodeXML(businessProcessId) + "</ram:ID>\n"
+ "</ram:BusinessProcessSpecifiedDocumentContextParameter>\n";

View File

@@ -36,16 +36,7 @@ import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -246,14 +237,14 @@ public class ZUGFeRDInvoiceImporter {
*/
final PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
Set<String> validFilenames = Set.of(
Set<String> validFilenames = new HashSet<>(Arrays.asList(
"ZUGFeRD-invoice.xml",
"zugferd-invoice.xml",
"factur-x.xml",
"xrechnung.xml",
"order-x.xml",
"cida.xml"
);
));
if (validFilenames.contains(filename)) {
containsMeta = true;
@@ -644,7 +635,7 @@ public class ZUGFeRDInvoiceImporter {
zpp.addNotes(includedNotes);
String rootNode = extractString("local-name(/*)");
String potentialCashDiscountTerms=null;
if (rootNode != null && Set.of("Invoice", "CreditNote").contains(rootNode)) {
if (rootNode != null && new HashSet<>(Arrays.asList("Invoice", "CreditNote")).contains(rootNode)) {
// UBL...
// //*[local-name()="Invoice" or local-name()="CreditNote"]
number = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"ID\"]").trim();
@@ -1374,7 +1365,7 @@ public class ZUGFeRDInvoiceImporter {
if (whichType != EStandard.despatchadvice && !ignoreCalculationErrors) {
// Check calculation if document type allows it and calculation errors should not be ignored
String payableTotalFromXml = XMLTools.nDigitFormat(Objects.requireNonNullElse(duePayableAmount, expectedGrandTotal), 2);
String payableTotalFromXml = XMLTools.nDigitFormat(Objects.requireNonNull(duePayableAmount != null ? duePayableAmount : expectedGrandTotal), 2);
if (!calculatedPayableTotal.equals(payableTotalFromXml)) {
String moreDetails = "";
try {

View File

@@ -142,7 +142,7 @@ public class ZUGFeRDVisualizer {
if (thestandard == EStandard.zugferd) {
applyZF1XSLT(xmlContentStream, htmlOutput);
return htmlOutput.toString(StandardCharsets.UTF_8);
return new String(htmlOutput.toByteArray(), StandardCharsets.UTF_8);
} else if (thestandard == EStandard.facturx) {
//zf2 or fx
applyZF2XSLT(xmlContentStream, htmlOutput);
@@ -164,7 +164,7 @@ public class ZUGFeRDVisualizer {
applyXSLTToHTML(in.get(), htmlOutStream, lang);
}
return htmlOutStream.toString(StandardCharsets.UTF_8);
return new String(htmlOutStream.toByteArray(), StandardCharsets.UTF_8);
}
/**
@@ -258,7 +258,7 @@ public class ZUGFeRDVisualizer {
if (in.isPresent()) {
applyXSLTToPDF(in.get(), baos, lang);
}
return baos.toString(StandardCharsets.UTF_8);
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}
public void toPDF(String xmlFilename, String pdfFilename) {

View File

@@ -66,7 +66,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ze.export(baos);
ze.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
@@ -106,7 +106,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ze.export(baos);
ze.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
@@ -144,7 +144,7 @@ public class BackwardCompatibilityTest extends TestCase implements IExportableTr
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ze.export(baos);
ze.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);

View File

@@ -63,10 +63,10 @@ public class DeSerializationTest extends ResourceCase {
public void testProduct() throws IOException, XPathExpressionException, ParseException {
File inputCII = getResourceAsFile("Extended_fremdwaehrung.xml");
var zii = new ZUGFeRDInvoiceImporter();
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter();
zii.doIgnoreCalculationErrors();
zii.fromXML(Files.readString(inputCII.toPath()));
var product = zii.extractInvoice()
zii.fromXML(new String(Files.readAllBytes(inputCII.toPath())));
IZUGFeRDExportableProduct product = zii.extractInvoice()
.getZFItems()[0]
.getProduct();

View File

@@ -271,7 +271,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
zea1.export(TARGET_PDF);
zea1.export(baos);
zea1.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
assertFalse(pdfContent.indexOf("<fx:ConformanceLevel>EN 16931</fx:ConformanceLevel>") == -1);
@@ -460,7 +460,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
zea1.export(TARGET_PDF);
zea1.export(baos);
zea1.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>") == -1);

View File

@@ -373,7 +373,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ze.export(baos);
ze.close();
String pdfContent = baos.toString(StandardCharsets.UTF_8);
String pdfContent = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
// check for pdf-a schema extension
// assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
@@ -445,7 +445,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
result.write(buffer, 0, length);
}
var bytes = result.toByteArray();
byte[] bytes = result.toByteArray();
ze.addAdditionalFile("test.pdf", bytes);
ze.setTransaction(this);

View File

@@ -90,7 +90,7 @@ public class UBLTest extends ResourceCase {
final ByteArrayOutputStream baos=new ByteArrayOutputStream();
oe.export(baos);
final String theXML = baos.toString(StandardCharsets.UTF_8);
final String theXML = new String(baos.toByteArray(), StandardCharsets.UTF_8);
assertTrue(theXML.contains("<DespatchAdvice"));
Files.write(Paths.get(TARGET_XML), theXML.getBytes(StandardCharsets.UTF_8));
} catch (final IOException e) {