complex-barcode/address.js

const _MwWrapper = require("../_mwbridge/_mw-wrapper.js");
const MwAddress = require("../_mwbridge/_mw-bridge.js").MwAddress;
/**
 * Address of creditor or debtor.<br>
 * <br>
 * You can either set street, house number, postal code and town (type structured address)<br>
 * or address line 1 and 2 (type combined address elements). The type is automatically set<br>
 * once any of these fields is set. Before setting the fields, the address type is undetermined.<br>
 * If fields of both types are set, the address type becomes conflicting.<br>
 * Name and country code must always be set unless all fields are empty.<br>
 */
class Address extends _MwWrapper
{

    constructor()
    {
        super(new MwAddress());
        this._initializeWrapperMembers();
    }

    static fromMwObject(mwObject)
    {
        let address = new Address();
        address.setJavaClass(mwObject);
        address._initializeWrapperMembers();
        return address;
    }

    /**
     * Gets the address type.<br>
     * <br>
     * The address type is automatically set by either setting street / house number<br>
     * or address line 1 and 2. Before setting the fields, the address type is Undetermined.<br>
     * If fields of both types are set, the address type becomes Conflicting.<br>
     * @return The address type.
     */
    getType() {
        return this.getJavaClass().getTypeSync();
    }

    /**
     * Gets the name, either the first and last name of a natural person or the<br>
     * company name of a legal person.<br>
     * @return The name.
     */
    getName() {
        return this.getJavaClass().getNameSync();
    }

    /**
     * Sets the name, either the first and last name of a natural person or the<br>
     * company name of a legal person.<br>
     * @param value: The name.
     */
    setName(value) {
        this.getJavaClass().setNameSync(value);
    }

    /**
     * Gets the address line 1.<br>
     * <br>
     * Address line 1 contains street name, house number or P.O. box.<br>
     * <br>
     * Setting this field sets the address type to AddressType.COMBINED_ELEMENTS unless it's already<br>
     * AddressType.STRUCTURED, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for combined elements addresses and is optional.<br>
     * <br>
     * @return The address line 1.
     */
    getAddressLine1() {
        return this.getJavaClass().getAddressLine1Sync();
    }

    /**
     * Sets the address line 1.<br>
     * <br>
     * Address line 1 contains street name, house number or P.O. box.<br>
     * <br>
     * Setting this field sets the address type to AddressType.COMBINED_ELEMENTS unless it's already<br>
     * AddressType.STRUCTURED, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for combined elements addresses and is optional.<br>
     * <br>
     * @param value: The address line 1.<br>
     */
    setAddressLine1(value) {
        this.getJavaClass().setAddressLine1Sync(value);
    }

    /**
     * Gets the address line 2.<br>
     * Address line 2 contains postal code and town.<br>
     * Setting this field sets the address type to AddressType.COMBINED_ELEMENTS unless it's already<br>
     * AddressType.STRUCTURED, in which case it becomes AddressType.CONFLICTING.<br>
     * This field is only used for combined elements addresses. For this type, it's mandatory.<br>
     * @return The address line 2.
     */
    getAddressLine2() {
        return this.getJavaClass().getAddressLine2Sync();
    }

    /**
     * Sets the address line 2.<br>
     * Address line 2 contains postal code and town.<br>
     * Setting this field sets the address type to AddressType.COMBINED_ELEMENTS unless it's already<br>
     * AddressType.STRUCTURED, in which case it becomes AddressType.CONFLICTING.<br>
     * This field is only used for combined elements addresses. For this type, it's mandatory.<br>
     * @param value: The address line 2.
     */
    setAddressLine2(value) {
        this.getJavaClass().setAddressLine2Sync(value);
    }

    /**
     * Gets the street.<br>
     * The street must be speicfied without house number.<br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * This field is only used for structured addresses and is optional.<br>
     * @return The street.
     */
    getStreet() {
        return this.getJavaClass().getStreetSync();
    }

    /**
     * Sets the street.<br>
     * <br>
     * The street must be speicfied without house number.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses and is optional.<br>
     * <br>
     * @param value: The street.
     */
    setStreet(value) {
        this.getJavaClass().setStreetSync(value);
    }

    /**
     * Gets the house number.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses and is optional.<br>
     * <br>
     * @return The house number.<br>
     */
    getHouseNo() {
        return this.getJavaClass().getHouseNoSync();
    }

    /**
     * Sets the house number.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses and is optional.<br>
     * <br>
     * @param value: The house number.
     */
    setHouseNo(value) {
        this.getJavaClass().setHouseNoSync(value);
    }

    /**
     * Gets the postal code.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses. For this type, it's mandatory.<br>
     * <br>
     * @return The postal code.
     */
    getPostalCode() {
        return this.getJavaClass().getPostalCodeSync();
    }

    /**
     * Sets the postal code.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses. For this type, it's mandatory.<br>
     * <br>
     * @param value The postal code.
     */
    setPostalCode(value) {
        this.getJavaClass().setPostalCodeSync(value);
    }

    /**
     * Gets the town or  city.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses. For this type, it's mandatory.<br>
     * <br>
     * @return The town or city.
     */
    getTown() {
        return this.getJavaClass().getTownSync();
    }

    /**
     * Sets the town or city.<br>
     * <br>
     * Setting this field sets the address type to AddressType.STRUCTURED unless it's already<br>
     * AddressType.COMBINED_ELEMENTS, in which case it becomes AddressType.CONFLICTING.<br>
     * <br>
     * This field is only used for structured addresses. For this type, it's mandatory.<br>
     * <br>
     * @param value The town or city.
     */
    setTown(value) {
        this.getJavaClass().setTownSync(value);
    }

    /**
     * Gets the two-letter ISO country code.<br>
     * <br>
     * The country code is mandatory unless the entire address contains null or emtpy values. <br>
     * <br>
     * @return The ISO country code.<br>
     */
    getCountryCode() {
        return this.getJavaClass().getCountryCodeSync();
    }

    /**
     * Sets the two-letter ISO country code. <br>
     * <br>
     * The country code is mandatory unless the entire address contains null or emtpy values.<br>
     * <br>
     * @param value The ISO country code.<br>
     */
    setCountryCode(value) {
        this.getJavaClass().setCountryCodeSync(value);
    }

    /**
     * Clears all fields and sets the type to AddressType.UNDETERMINED.
     */
    clear() {
        this.setName(null);
        this.setAddressLine1(null);
        this.setAddressLine2(null);
        this.setStreet(null);
        this.setHouseNo(null);
        this.setPostalCode(null);
        this.setTown(null);
        this.setCountryCode(null);
    }

    /**
     * Determines whether the specified object is equal to the current object.<br>
     * @return true if the specified object is equal to the current object; otherwise, false.<br>
     * @param obj The object to compare with the current object.<br>
     */
    equals(obj) {
        return this.getJavaClass().equalsSync(obj.getJavaClass());
    }

    /**
     * Gets the hash code for this instance.<br>
     * @return A hash code for the current object<br>.
     */
    hashCode() {
        return this.getJavaClass().hashCodeSync();
    }

    _initializeWrapperMembers() {

    }
}

module.exports = Address;