package com.braintree.translator;

import de.hybris.platform.impex.jalo.translators.AbstractValueTranslator;
import de.hybris.platform.jalo.Item;
import de.hybris.platform.jalo.JaloInvalidParameterException;

public class BraintreeSensitiveDataTranslator extends AbstractValueTranslator {

    private static final String EMPTY_STRING = "";
    private static final String ALL_CHARACTER_MATCHER = ".";
    private static final String MASKING_SYMBOL = "*";


    @Override
    public String exportValue(final Object value) throws JaloInvalidParameterException {
        if (value == null) {
            return EMPTY_STRING;
        } else {
            return value.toString().replaceAll(ALL_CHARACTER_MATCHER, MASKING_SYMBOL);
        }
    }

    @Override
    public Object importValue(String s, Item item) throws JaloInvalidParameterException { return s; }
}
