Casting variable onto bigDecimal
<p>I am trying to make some changes to a program at work that is quite complicated. This program makes use of JAXB and has a host of different classes and features. At it's core the purpose is to allow a user to create an XML file that represents a card-based transaction. Right now the user has the ability to enter an amount which is then put into the final XML. I need to expand upon this by also giving the user the ability to split a transaction into multiple parts. This means that I need to be able to change the amount field. Unfortunately for me the way the author designed the amount field is a bit confusing, so I'm hoping someone could shed some light. There is tons of code and I can't paste it all but I'll do the best to show the issue. </p>

<p>The main section of code I'm working with is this: </p>

<pre><code>while(allocationCounter&gt;0){
            StructuredRemittanceInformation9 Strd = objectFactory
                    .createStructuredRemittanceInformation9(); // create Strd
            ReferredDocumentInformation3 RfrdDocInf = objectFactory
                    .createReferredDocumentInformation3(); // create RfrdDocInf
            ReferredDocumentType2 tpdoc = objectFactory
                    .createReferredDocumentType2(); // create tp
            ReferredDocumentType1Choice cdOrPrtry = objectFactory
                    .createReferredDocumentType1Choice(); // create CdOrPrtry
            cdOrPrtry.setCd(DocumentType5Code.SOAC);
            tpdoc.setCdOrPrtry(cdOrPrtry); // set CdorPrtry
            RfrdDocInf.setTp(tpdoc); // set Tp
            RfrdDocInf.setNb("0001");
            Strd.getRfrdDocInf().add(RfrdDocInf); // set RfrdDocInf

            RemittanceAmount2 RfrdDocAmt = objectFactory.createRemittanceAmount2(); // create
                                                                                    // RfrdDocAmt
            DocumentAdjustment1 adjstmntAmt = objectFactory
                    .createDocumentAdjustment1(); // create AdjstmntAmtAndRsn
            ActiveOrHistoricCurrencyAndAmount adjAmt = objectFactory
                    .createActiveOrHistoricCurrencyAndAmount(); // create Amt


            adjAmt.setCcy("USD");
            adjAmt.setValue((BigDecimal) transInfo.get("amount"));      
            adjstmntAmt.setAmt(adjAmt); // set Amt
            adjstmntAmt.setCdtDbtInd(CreditDebitCode.DBIT); // set CdtDbtInd
            adjstmntAmt.setAddtlInf(transInfo.get("dbtrName").toString()); // set
                                                                            // AddtlInf
            RfrdDocAmt.getAdjstmntAmtAndRsn().add(adjstmntAmt); // set
                                                                // AdjstmntAmtAndRsn
            Strd.setRfrdDocAmt(RfrdDocAmt); // set RfrdDocAmt

            CreditorReferenceInformation2 cdtrRefInf = objectFactory
                    .createCreditorReferenceInformation2(); // create CdtrRefInf
            CreditorReferenceType2 cdtrTp = objectFactory
                    .createCreditorReferenceType2(); // create Tp
            CreditorReferenceType1Choice CdorPrtryTp = objectFactory
                    .createCreditorReferenceType1Choice(); // create cdPrtry
            CdorPrtryTp.setPrtry("BNR");
            cdtrTp.setCdOrPrtry(CdorPrtryTp);// set CdPrtry
            cdtrRefInf.setTp(cdtrTp); // set Tp
            cdtrRefInf.setRef(transInfo.get("referenceNumber").toString());
            Strd.setCdtrRefInf(cdtrRefInf);// set CdtrRefInf

            rmtInf.getStrd().add(Strd); // set strd

            System.out.println("TEST PASSED");
            allocationCounter--;
            }
</code></pre>

<p>In particular this line of code</p>

<pre><code>adjstmntAmt.setAmt(adjAmt); // set Amt
</code></pre>

<p>That is what sets the amount, and that is what I need to change. That amount links back through several classes but begins here:</p>

<pre><code>transactionInfo.put("amount", amount);
</code></pre>

<p>In that class the user puts the amount into a text field and it is then saved 
The adjstmntAmt(adjAmt) I posted above is referenced in another class: 
into the transactionInfo hash and called later. </p>

<pre><code>//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 
// See &lt;a href="http://java.sun.com/xml/jaxb"&gt;http://java.sun.com/xml/jaxb&lt;/a&gt; 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2015.07.01 at 10:11:45 AM EDT 
//


package jaxBClasses;

import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;


/**
 * &lt;p&gt;Java class for ActiveOrHistoricCurrencyAndAmount complex type.
 * 
 * &lt;p&gt;The following schema fragment specifies the expected content contained within this class.
 * 
 * &lt;pre&gt;
 * &amp;lt;complexType name="ActiveOrHistoricCurrencyAndAmount"&gt;
 *   &amp;lt;simpleContent&gt;
 *     &amp;lt;extension base="&amp;lt;urn:iso:std:iso:20022:tech:xsd:pain.008.001.04&gt;ActiveOrHistoricCurrencyAndAmount_SimpleType"&gt;
 *       &amp;lt;attribute name="Ccy" use="required" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.04}ActiveOrHistoricCurrencyCode" /&gt;
 *     &amp;lt;/extension&gt;
 *   &amp;lt;/simpleContent&gt;
 * &amp;lt;/complexType&gt;
 * &lt;/pre&gt;
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ActiveOrHistoricCurrencyAndAmount", propOrder = {
    "value"
})
public class ActiveOrHistoricCurrencyAndAmount {

    @XmlValue
    protected BigDecimal value;
    @XmlAttribute(name = "Ccy", required = true)
    protected String ccy;

    /**
     * Gets the value of the value property.
     * 
     * @return
     *     possible object is
     *     {@link BigDecimal }
     *     
     */
    public BigDecimal getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigDecimal }
     *     
     */
    public void setValue(BigDecimal value) {
        this.value = value;
    }

    /**
     * Gets the value of the ccy property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCcy() {
        return ccy;
    }

    /**
     * Sets the value of the ccy property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCcy(String value) {
        this.ccy = value;
    }

}
</code></pre>

<p>and it also appears in this class: </p>

<pre><code>//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 
// See &lt;a href="http://java.sun.com/xml/jaxb"&gt;http://java.sun.com/xml/jaxb&lt;/a&gt; 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2015.07.01 at 10:11:45 AM EDT 
//


package jaxBClasses;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


/**
 * &lt;p&gt;Java class for DocumentAdjustment1 complex type.
 * 
 * &lt;p&gt;The following schema fragment specifies the expected content contained within this class.
 * 
 * &lt;pre&gt;
 * &amp;lt;complexType name="DocumentAdjustment1"&gt;
 *   &amp;lt;complexContent&gt;
 *     &amp;lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
 *       &amp;lt;sequence&gt;
 *         &amp;lt;element name="Amt" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.04}ActiveOrHistoricCurrencyAndAmount"/&gt;
 *         &amp;lt;element name="CdtDbtInd" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.04}CreditDebitCode" minOccurs="0"/&gt;
 *         &amp;lt;element name="Rsn" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.04}Max4Text" minOccurs="0"/&gt;
 *         &amp;lt;element name="AddtlInf" type="{urn:iso:std:iso:20022:tech:xsd:pain.008.001.04}Max140Text" minOccurs="0"/&gt;
 *       &amp;lt;/sequence&gt;
 *     &amp;lt;/restriction&gt;
 *   &amp;lt;/complexContent&gt;
 * &amp;lt;/complexType&gt;
 * &lt;/pre&gt;
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DocumentAdjustment1", propOrder = {
    "amt",
    "cdtDbtInd",
    "rsn",
    "addtlInf"
})
public class DocumentAdjustment1 {

    @XmlElement(name = "Amt", required = true)
    protected ActiveOrHistoricCurrencyAndAmount amt;
    @XmlElement(name = "CdtDbtInd")
    protected CreditDebitCode cdtDbtInd;
    @XmlElement(name = "Rsn")
    protected String rsn;
    @XmlElement(name = "AddtlInf")
    protected String addtlInf;

    /**
     * Gets the value of the amt property.
     * 
     * @return
     *     possible object is
     *     {@link ActiveOrHistoricCurrencyAndAmount }
     *     
     */
    public ActiveOrHistoricCurrencyAndAmount getAmt() {
        return amt;
    }

    /**
     * Sets the value of the amt property.
     * 
     * @param value
     *     allowed object is
     *     {@link ActiveOrHistoricCurrencyAndAmount }
     *     
     */
    public void setAmt(ActiveOrHistoricCurrencyAndAmount value) {

        this.amt = value;
    }

    /**
     * Gets the value of the cdtDbtInd property.
     * 
     * @return
     *     possible object is
     *     {@link CreditDebitCode }
     *     
     */
    public CreditDebitCode getCdtDbtInd() {
        return cdtDbtInd;
    }

    /**
     * Sets the value of the cdtDbtInd property.
     * 
     * @param value
     *     allowed object is
     *     {@link CreditDebitCode }
     *     
     */
    public void setCdtDbtInd(CreditDebitCode value) {
        this.cdtDbtInd = value;
    }

    /**
     * Gets the value of the rsn property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getRsn() {
        return rsn;
    }

    /**
     * Sets the value of the rsn property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setRsn(String value) {
        this.rsn = value;
    }

    /**
     * Gets the value of the addtlInf property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAddtlInf() {
        return addtlInf;
    }

    /**
     * Sets the value of the addtlInf property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAddtlInf(String value) {
        this.addtlInf = value;
    }

}
</code></pre>

<p>So my question is simply: What do I need to do to make it so that I can put any variable in that line of code that reads: </p>

<pre><code>adjstmntAmt.setAmt(adjAmt); // set Amt
</code></pre>

<p>I've tried replacing adjAmt with my own variable but I get an error that says the type must be ActiveOrHistoricCurrencyAndAmount.. </p>

<p>Any help is greatly appreciated!</p>