diff --git a/pom.xml b/pom.xml index 2e6df14b12ab3209e9d17e9709954a0325406e31..11f6854757f919815a208ef89836fcf4bb090b5c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ es.uvigo.esei.dai.ws calculator_service - 1.0.0 + 1.1.0 Ejemplos de DAI - Servicios Web: Calculator Service 2014 diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorException.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorException.java index 2984bcdf162898307c604af3d37ce5a4ddb07b4a..337e9b7a9458366fdf1aef9dfb058dfe642219cf 100644 --- a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorException.java +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorException.java @@ -25,17 +25,17 @@ public class CalculatorException extends RuntimeException { private static final long serialVersionUID = 1L; private final String faultInfo; - + public CalculatorException(String message) { this(message, message); } - + public CalculatorException(String message, String faultInfo) { super(message); - + this.faultInfo = faultInfo; } - + public String getFaultInfo() { return faultInfo; } diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorService.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorService.java index 6ca7cc67e02025c0b63de1dbce9649bff44cd774..c00541b0b59985478469c6b6b51134c9c0d2977e 100644 --- a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorService.java +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorService.java @@ -21,21 +21,57 @@ */ package es.uvigo.esei.dai.ws.calculator; +import java.util.Collection; + +import es.uvigo.esei.dai.ws.calculator.adapters.NamedOperations; +import es.uvigo.esei.dai.ws.calculator.adapters.NamedResults; import jakarta.jws.WebMethod; import jakarta.jws.WebService; @WebService -// @SOAPBinding(style = Style.RPC) public interface CalculatorService { @WebMethod public double add(double op1, double op2); - + @WebMethod public double subtract(double op1, double op2); - + @WebMethod public double multiply(double op1, double op2); - + + @WebMethod + public double divide(double op1, double op2) + throws CalculatorException; + + @WebMethod + public double operate(Operation operation, double op1, double op2) + throws CalculatorException; + + @WebMethod + public double serialOperate(Operation operation, double ... op) + throws CalculatorException; + + @WebMethod + public double arrayOperate(Operation operation, double[] op) + throws CalculatorException; + + @WebMethod + public double listOperate(Operation operation, Collection op) + throws CalculatorException; + + /* + * JAXB no soporta esta declaración de método porque hace uso de Map, + * que es una interfaz y JAXB no es capaz de trabajar con interfaces + * directamente. + * + * @WebMethod + * public Map mapOperate( + * Map operations, double op1, double op2 + * ) throws CalculatorException; + */ + @WebMethod - public double divide(double op1, double op2) throws CalculatorException; + public NamedResults mapOperate( + NamedOperations operations, double op1, double op2 + ) throws CalculatorException; } diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceClient.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceClient.java index 84e029ea1e85f2b38003ec488d51edabe91a6030..b942d09f495495063574df2bae20f29d8ebd7486 100644 --- a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceClient.java +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceClient.java @@ -23,9 +23,14 @@ package es.uvigo.esei.dai.ws.calculator; import java.net.MalformedURLException; import java.net.URL; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import javax.xml.namespace.QName; +import es.uvigo.esei.dai.ws.calculator.adapters.NamedOperations; +import es.uvigo.esei.dai.ws.calculator.adapters.NamedResults; import jakarta.xml.ws.Service; public class CalculatorServiceClient { @@ -41,10 +46,37 @@ public class CalculatorServiceClient { final CalculatorService calculator = service.getPort(CalculatorService.class); + System.out.println("Basic methods results"); System.out.println(calculator.add(20d, 30d)); System.out.println(calculator.subtract(20d, 30d)); - System.out.println(calculator.multiply(20d, 0d)); + System.out.println(calculator.multiply(20d, 30d)); System.out.println(calculator.divide(20d, 30d)); + + System.out.println("\nOperate results"); + System.out.println(calculator.operate(Operation.ADD, 20d, 30d)); + System.out.println(calculator.operate(Operation.SUB, 20d, 30d)); + System.out.println(calculator.operate(Operation.MUL, 20d, 30d)); + System.out.println(calculator.operate(Operation.DIV, 20d, 30d)); + + System.out.println("\nCollections results"); + System.out.println("Serial: " + calculator.serialOperate(Operation.ADD, 10d, 20d, 30d)); + System.out.println("Array: " + calculator.arrayOperate(Operation.ADD, new double[]{10d, 20d, 30d})); + System.out.println("List: " + calculator.listOperate(Operation.ADD, Arrays.asList(10d, 20d, 30d))); + + System.out.println("\nMap results"); + final Map operations = new HashMap(); + for (Operation operation : Operation.values()) { + operations.put(operation.name(), operation); + } + + final NamedResults results = calculator.mapOperate( + new NamedOperations(operations), 20d, 30d + ); + for (Map.Entry entry : results.getResults().entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + + System.out.println("\nException"); try { System.out.println(calculator.divide(20d, 0d)); } catch (CalculatorException e) { diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceImpl.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceImpl.java index ba85e1bf1a86366c55a2ce52bf915f9dc4a5f3fd..ba0bcba83d0a6c45bc4464d8339e13e780bf1587 100644 --- a/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceImpl.java +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/CalculatorServiceImpl.java @@ -21,30 +21,111 @@ */ package es.uvigo.esei.dai.ws.calculator; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import es.uvigo.esei.dai.ws.calculator.adapters.NamedOperations; +import es.uvigo.esei.dai.ws.calculator.adapters.NamedResults; import jakarta.jws.WebService; @WebService(endpointInterface = "es.uvigo.esei.dai.ws.calculator.CalculatorService") public class CalculatorServiceImpl implements CalculatorService { @Override public double add(double op1, double op2) { - return op1 + op2; + return this.operate(Operation.ADD, op1, op2); } @Override public double subtract(double op1, double op2) { - return op1 - op2; + return this.operate(Operation.SUB, op1, op2); } @Override public double multiply(double op1, double op2) { - return op1 * op2; + return this.operate(Operation.MUL, op1, op2); } @Override public double divide(double op1, double op2) throws CalculatorException { - if (op2 == 0d) - throw new CalculatorException("op2 can't be zero"); + return this.operate(Operation.DIV, op1, op2); + } + + @Override + public double operate(Operation operation, double op1, double op2) + throws CalculatorException { + return operation.calculate(op1, op2); + } + + @Override + public double serialOperate(Operation operation, double ... op) + throws CalculatorException { + if (op.length <= 1) { + throw new CalculatorException("There must be, at least, two operands"); + } else { + double result = op[0]; + + for (int i = 1; i < op.length; i++) { + result = operation.calculate(result, op[i]); + } + + return result; + } + } - return op1 / op2; + @Override + public double arrayOperate(Operation operation, double[] op) + throws CalculatorException { + return this.serialOperate(operation, op); + } + + @Override + public double listOperate(Operation operation, Collection op) + throws CalculatorException { + if (op.size() <= 1) { + throw new CalculatorException("There must be, at least, two operands"); + } else { + final List values = new ArrayList(op); + double result = values.get(0); + + for (int i = 1; i < op.size(); i++) { + result = operation.calculate(result, values.get(i)); + } + + return result; + } + } + + /* + * Ejemplo de implementación para declaración no válida de "mapOperate" + * + * @Override + * public Map mapOperate( + * Map operations, double op1, double op2 + * ) throws CalculatorException { + * final Map results = new HashMap(); + * + * for (Map.Entry entry : operations.entrySet()) { + * results.put(entry.getKey(), entry.getValue().calculate(op1, op2)); + * } + * return results; + * } + */ + + @Override + public NamedResults mapOperate( + NamedOperations operations, double op1, double op2 + ) throws CalculatorException { + final NamedResults results = new NamedResults(); + + final Map operationsMap = operations.getOperations(); + final Map resultsMap = results.getResults(); + + for (Map.Entry entry : operationsMap.entrySet()) { + resultsMap.put(entry.getKey(), entry.getValue().calculate(op1, op2)); + } + + return results; } } diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/Operation.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/Operation.java new file mode 100644 index 0000000000000000000000000000000000000000..142b9eaf546438594aaea66db64650069e1db535 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/Operation.java @@ -0,0 +1,48 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator; + +public enum Operation { + ADD, SUB, MUL, DIV; + + public double calculate(double op1, double op2) + throws CalculatorException { + switch(this) { + case ADD: return op1 + op2; + case SUB: return op1 - op2; + case MUL: return op1 * op2; + case DIV: + if (op2 == 0d) { + throw new CalculatorException( + "op2 can't be zero", "op2 can't be zero" + ); + } else { + return op1 / op2; + } + default: + throw new CalculatorException( + "Unknown operation: " + this, + "Unknown operation: " + this + ); + } + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperations.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperations.java new file mode 100644 index 0000000000000000000000000000000000000000..a5be6713d36315d821a4e36407c05d061c60be41 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperations.java @@ -0,0 +1,52 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.HashMap; +import java.util.Map; + +import es.uvigo.esei.dai.ws.calculator.Operation; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +@XmlRootElement +public class NamedOperations { + private Map operations; + + public NamedOperations() { + this.operations = new HashMap(); + } + + public NamedOperations(Map operations) { + super(); + this.operations = operations; + } + + @XmlJavaTypeAdapter(NamedOperationsMapAdapter.class) + public Map getOperations() { + return operations; + } + + public void setOperations(Map operations) { + this.operations = operations; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsEntry.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..13b4607c525c9020b3b3745df9fa4f1f67d8d850 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsEntry.java @@ -0,0 +1,59 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.Map; + +import es.uvigo.esei.dai.ws.calculator.Operation; + +public class NamedOperationsEntry { + private String key; + private Operation value; + + public NamedOperationsEntry() { + } + + public NamedOperationsEntry(String key, Operation value) { + this.key = key; + this.value = value; + } + + public NamedOperationsEntry(Map.Entry entry) { + this(entry.getKey(), entry.getValue()); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Operation getValue() { + return value; + } + + public void setValue(Operation value) { + this.value = value; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMap.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMap.java new file mode 100644 index 0000000000000000000000000000000000000000..64685caf9d5ad7ac9ad052e6a53214a7775e92b9 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMap.java @@ -0,0 +1,63 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import es.uvigo.esei.dai.ws.calculator.Operation; + +public class NamedOperationsMap { + private List entries; + + public NamedOperationsMap() { + this.entries = new LinkedList(); + } + + public NamedOperationsMap(Map map) { + this(); + + for (Map.Entry entry : map.entrySet()) { + this.entries.add(new NamedOperationsEntry(entry)); + } + } + + public Map createMap() { + final Map map = new HashMap(); + + for (NamedOperationsEntry entry : this.entries) { + map.put(entry.getKey(), entry.getValue()); + } + + return map; + } + + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMapAdapter.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMapAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..24dc1eede65980aabbbf3400b9dd000e677cdd37 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedOperationsMapAdapter.java @@ -0,0 +1,41 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.Map; + +import es.uvigo.esei.dai.ws.calculator.Operation; +import jakarta.xml.bind.annotation.adapters.XmlAdapter; + +public class NamedOperationsMapAdapter +extends XmlAdapter> { + + @Override + public Map unmarshal(NamedOperationsMap v) { + return v.createMap(); + } + + @Override + public NamedOperationsMap marshal(Map v) { + return new NamedOperationsMap(v); + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResults.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResults.java new file mode 100644 index 0000000000000000000000000000000000000000..bb9e83ac03f42fab226ecd13b818e5cca20a3ad3 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResults.java @@ -0,0 +1,50 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +@XmlRootElement +public class NamedResults { + private Map results; + + public NamedResults() { + this.results = new HashMap(); + } + + public NamedResults(Map results) { + this.results = results; + } + + @XmlJavaTypeAdapter(NamedResultsMapAdapter.class) + public Map getResults() { + return results; + } + + public void setResults(Map results) { + this.results = results; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsEntry.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..53956cd2ff66657bdd9fd8078286867903d904cb --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsEntry.java @@ -0,0 +1,57 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.Map; + +public class NamedResultsEntry { + private String key; + private Double value; + + public NamedResultsEntry() { + } + + public NamedResultsEntry(String key, Double value) { + this.key = key; + this.value = value; + } + + public NamedResultsEntry(Map.Entry entry) { + this(entry.getKey(), entry.getValue()); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMap.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMap.java new file mode 100644 index 0000000000000000000000000000000000000000..9d91d8597d3819aa7803bb79af1a578d16f0c6c3 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMap.java @@ -0,0 +1,61 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class NamedResultsMap { + private List entries; + + public NamedResultsMap() { + this.entries = new LinkedList(); + } + + public NamedResultsMap(Map map) { + this(); + + for (Map.Entry entry : map.entrySet()) { + this.entries.add(new NamedResultsEntry(entry)); + } + } + + public Map createMap() { + final Map map = new HashMap(); + + for (NamedResultsEntry entry : this.entries) { + map.put(entry.getKey(), entry.getValue()); + } + + return map; + } + + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } +} diff --git a/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMapAdapter.java b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMapAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..4a3edb1f2b1cda449d63b2678c7ac1433a603834 --- /dev/null +++ b/src/main/java/es/uvigo/esei/dai/ws/calculator/adapters/NamedResultsMapAdapter.java @@ -0,0 +1,40 @@ +/*- + * #%L + * Ejemplos de DAI - Servicios Web: Calculator Service + * %% + * Copyright (C) 2014 - 2025 Miguel Reboiro Jato + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ +package es.uvigo.esei.dai.ws.calculator.adapters; + +import java.util.Map; + +import jakarta.xml.bind.annotation.adapters.XmlAdapter; + +public class NamedResultsMapAdapter +extends XmlAdapter> { + + @Override + public Map unmarshal(NamedResultsMap v) { + return v.createMap(); + } + + @Override + public NamedResultsMap marshal(Map v) { + return new NamedResultsMap(v); + } +}