]> git.basschouten.com Git - openhab-addons.git/blob
011e75c56fd2cd536b76d0754ab0a0dfbb0e1c66
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.denonmarantz.internal.xml.adapters;
14
15 import javax.xml.bind.annotation.adapters.XmlAdapter;
16
17 import org.apache.commons.lang3.StringUtils;
18
19 /**
20  * Adapter to clean up string values
21  *
22  * @author Jeroen Idserda - Initial contribution
23  */
24 public class StringAdapter extends XmlAdapter<String, String> {
25
26     @Override
27     public String unmarshal(String v) throws Exception {
28         String val = v;
29         if (val != null) {
30             val = StringUtils.trimToEmpty(val);
31         }
32         return val;
33     }
34
35     @Override
36     public String marshal(String v) throws Exception {
37         return v;
38     }
39 }