text:
<?php

namespace DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIREncounter;

use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference;
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRConstants;
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRTypeInterface;

/**
 * An interaction between a patient and healthcare provider(s) for the purpose of
 * providing healthcare service(s) or assessing the health status of a patient.
 *
 * Class FHIREncounterHospitalization
 * @package \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIREncounter
 */
class FHIREncounterHospitalization extends FHIRBackboneElement
{
    // name of FHIR type this class describes
    const FHIR_TYPE_NAME = PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION;
    const FIELD_ADMIT_SOURCE = 'admitSource';
    const FIELD_DESTINATION = 'destination';
    const FIELD_DIET_PREFERENCE = 'dietPreference';
    const FIELD_DISCHARGE_DISPOSITION = 'dischargeDisposition';
    const FIELD_ORIGIN = 'origin';
    const FIELD_PRE_ADMISSION_IDENTIFIER = 'preAdmissionIdentifier';
    const FIELD_RE_ADMISSION = 'reAdmission';
    const FIELD_SPECIAL_ARRANGEMENT = 'specialArrangement';
    const FIELD_SPECIAL_COURTESY = 'specialCourtesy';

    /** @var string */
    private $_xmlns = 'http://hl7.org/fhir';

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * From where patient was admitted (physician referral, transfer).
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    protected $admitSource = null;

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Location/organization to which the patient is discharged.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference
     */
    protected $destination = null;

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Diet preferences reported by the patient.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    protected $dietPreference = [];

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Category or kind of location after discharge.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    protected $dischargeDisposition = null;

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The location/organization from which the patient came before admission.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference
     */
    protected $origin = null;

    /**
     * An identifier - identifies some entity uniquely and unambiguously. Typically
     * this is used for business identifiers.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Pre-admission identifier.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier
     */
    protected $preAdmissionIdentifier = null;

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Whether this hospitalization is a readmission and why if known.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    protected $reAdmission = null;

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Any special requests that have been made for this hospitalization encounter,
     * such as the provision of specific equipment or other things.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    protected $specialArrangement = [];

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Special courtesies (VIP, board member).
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    protected $specialCourtesy = [];

    /**
     * Validation map for fields in type Encounter.Hospitalization
     * @var array
     */
    private static $_validationRules = [    ];

    /**
     * FHIREncounterHospitalization Constructor
     * @param null|array $data
     */
    public function __construct($data = null)
    {
        if (null === $data || [] === $data) {
            return;
        }
        if (!is_array($data)) {
            throw new \InvalidArgumentException(sprintf(
                'FHIREncounterHospitalization::_construct - $data expected to be null or array, %s seen',
                gettype($data)
            ));
        }
        parent::__construct($data);
        if (isset($data[self::FIELD_ADMIT_SOURCE])) {
            if ($data[self::FIELD_ADMIT_SOURCE] instanceof FHIRCodeableConcept) {
                $this->setAdmitSource($data[self::FIELD_ADMIT_SOURCE]);
            } else {
                $this->setAdmitSource(new FHIRCodeableConcept($data[self::FIELD_ADMIT_SOURCE]));
            }
        }
        if (isset($data[self::FIELD_DESTINATION])) {
            if ($data[self::FIELD_DESTINATION] instanceof FHIRReference) {
                $this->setDestination($data[self::FIELD_DESTINATION]);
            } else {
                $this->setDestination(new FHIRReference($data[self::FIELD_DESTINATION]));
            }
        }
        if (isset($data[self::FIELD_DIET_PREFERENCE])) {
            if (is_array($data[self::FIELD_DIET_PREFERENCE])) {
                foreach($data[self::FIELD_DIET_PREFERENCE] as $v) {
                    if (null === $v) {
                        continue;
                    }
                    if ($v instanceof FHIRCodeableConcept) {
                        $this->addDietPreference($v);
                    } else {
                        $this->addDietPreference(new FHIRCodeableConcept($v));
                    }
                }
            } else if ($data[self::FIELD_DIET_PREFERENCE] instanceof FHIRCodeableConcept) {
                $this->addDietPreference($data[self::FIELD_DIET_PREFERENCE]);
            } else {
                $this->addDietPreference(new FHIRCodeableConcept($data[self::FIELD_DIET_PREFERENCE]));
            }
        }
        if (isset($data[self::FIELD_DISCHARGE_DISPOSITION])) {
            if ($data[self::FIELD_DISCHARGE_DISPOSITION] instanceof FHIRCodeableConcept) {
                $this->setDischargeDisposition($data[self::FIELD_DISCHARGE_DISPOSITION]);
            } else {
                $this->setDischargeDisposition(new FHIRCodeableConcept($data[self::FIELD_DISCHARGE_DISPOSITION]));
            }
        }
        if (isset($data[self::FIELD_ORIGIN])) {
            if ($data[self::FIELD_ORIGIN] instanceof FHIRReference) {
                $this->setOrigin($data[self::FIELD_ORIGIN]);
            } else {
                $this->setOrigin(new FHIRReference($data[self::FIELD_ORIGIN]));
            }
        }
        if (isset($data[self::FIELD_PRE_ADMISSION_IDENTIFIER])) {
            if ($data[self::FIELD_PRE_ADMISSION_IDENTIFIER] instanceof FHIRIdentifier) {
                $this->setPreAdmissionIdentifier($data[self::FIELD_PRE_ADMISSION_IDENTIFIER]);
            } else {
                $this->setPreAdmissionIdentifier(new FHIRIdentifier($data[self::FIELD_PRE_ADMISSION_IDENTIFIER]));
            }
        }
        if (isset($data[self::FIELD_RE_ADMISSION])) {
            if ($data[self::FIELD_RE_ADMISSION] instanceof FHIRCodeableConcept) {
                $this->setReAdmission($data[self::FIELD_RE_ADMISSION]);
            } else {
                $this->setReAdmission(new FHIRCodeableConcept($data[self::FIELD_RE_ADMISSION]));
            }
        }
        if (isset($data[self::FIELD_SPECIAL_ARRANGEMENT])) {
            if (is_array($data[self::FIELD_SPECIAL_ARRANGEMENT])) {
                foreach($data[self::FIELD_SPECIAL_ARRANGEMENT] as $v) {
                    if (null === $v) {
                        continue;
                    }
                    if ($v instanceof FHIRCodeableConcept) {
                        $this->addSpecialArrangement($v);
                    } else {
                        $this->addSpecialArrangement(new FHIRCodeableConcept($v));
                    }
                }
            } else if ($data[self::FIELD_SPECIAL_ARRANGEMENT] instanceof FHIRCodeableConcept) {
                $this->addSpecialArrangement($data[self::FIELD_SPECIAL_ARRANGEMENT]);
            } else {
                $this->addSpecialArrangement(new FHIRCodeableConcept($data[self::FIELD_SPECIAL_ARRANGEMENT]));
            }
        }
        if (isset($data[self::FIELD_SPECIAL_COURTESY])) {
            if (is_array($data[self::FIELD_SPECIAL_COURTESY])) {
                foreach($data[self::FIELD_SPECIAL_COURTESY] as $v) {
                    if (null === $v) {
                        continue;
                    }
                    if ($v instanceof FHIRCodeableConcept) {
                        $this->addSpecialCourtesy($v);
                    } else {
                        $this->addSpecialCourtesy(new FHIRCodeableConcept($v));
                    }
                }
            } else if ($data[self::FIELD_SPECIAL_COURTESY] instanceof FHIRCodeableConcept) {
                $this->addSpecialCourtesy($data[self::FIELD_SPECIAL_COURTESY]);
            } else {
                $this->addSpecialCourtesy(new FHIRCodeableConcept($data[self::FIELD_SPECIAL_COURTESY]));
            }
        }
    }

    /**
     * @return string
     */
    public function _getFHIRTypeName()
    {
        return self::FHIR_TYPE_NAME;
    }

    /**
     * @return string
     */
    public function _getFHIRXMLElementDefinition()
    {
        $xmlns = $this->_getFHIRXMLNamespace();
        if (null !== $xmlns) {
            $xmlns = " xmlns=\"{$xmlns}\"";
        }
        return "<EncounterHospitalization{$xmlns}></EncounterHospitalization>";
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * From where patient was admitted (physician referral, transfer).
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    public function getAdmitSource()
    {
        return $this->admitSource;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * From where patient was admitted (physician referral, transfer).
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $admitSource
     * @return static
     */
    public function setAdmitSource(FHIRCodeableConcept $admitSource = null)
    {
        $this->admitSource = $admitSource;
        return $this;
    }

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Location/organization to which the patient is discharged.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference
     */
    public function getDestination()
    {
        return $this->destination;
    }

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Location/organization to which the patient is discharged.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference $destination
     * @return static
     */
    public function setDestination(FHIRReference $destination = null)
    {
        $this->destination = $destination;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Diet preferences reported by the patient.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    public function getDietPreference()
    {
        return $this->dietPreference;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Diet preferences reported by the patient.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $dietPreference
     * @return static
     */
    public function addDietPreference(FHIRCodeableConcept $dietPreference = null)
    {
        $this->dietPreference[] = $dietPreference;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Diet preferences reported by the patient.
     *
     * @param \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[] $dietPreference
     * @return static
     */
    public function setDietPreference(array $dietPreference = [])
    {
        $this->dietPreference = [];
        if ([] === $dietPreference) {
            return $this;
        }
        foreach($dietPreference as $v) {
            if ($v instanceof FHIRCodeableConcept) {
                $this->addDietPreference($v);
            } else {
                $this->addDietPreference(new FHIRCodeableConcept($v));
            }
        }
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Category or kind of location after discharge.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    public function getDischargeDisposition()
    {
        return $this->dischargeDisposition;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Category or kind of location after discharge.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $dischargeDisposition
     * @return static
     */
    public function setDischargeDisposition(FHIRCodeableConcept $dischargeDisposition = null)
    {
        $this->dischargeDisposition = $dischargeDisposition;
        return $this;
    }

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The location/organization from which the patient came before admission.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference
     */
    public function getOrigin()
    {
        return $this->origin;
    }

    /**
     * A reference from one resource to another.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The location/organization from which the patient came before admission.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRReference $origin
     * @return static
     */
    public function setOrigin(FHIRReference $origin = null)
    {
        $this->origin = $origin;
        return $this;
    }

    /**
     * An identifier - identifies some entity uniquely and unambiguously. Typically
     * this is used for business identifiers.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Pre-admission identifier.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier
     */
    public function getPreAdmissionIdentifier()
    {
        return $this->preAdmissionIdentifier;
    }

    /**
     * An identifier - identifies some entity uniquely and unambiguously. Typically
     * this is used for business identifiers.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Pre-admission identifier.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier $preAdmissionIdentifier
     * @return static
     */
    public function setPreAdmissionIdentifier(FHIRIdentifier $preAdmissionIdentifier = null)
    {
        $this->preAdmissionIdentifier = $preAdmissionIdentifier;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Whether this hospitalization is a readmission and why if known.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept
     */
    public function getReAdmission()
    {
        return $this->reAdmission;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Whether this hospitalization is a readmission and why if known.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $reAdmission
     * @return static
     */
    public function setReAdmission(FHIRCodeableConcept $reAdmission = null)
    {
        $this->reAdmission = $reAdmission;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Any special requests that have been made for this hospitalization encounter,
     * such as the provision of specific equipment or other things.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    public function getSpecialArrangement()
    {
        return $this->specialArrangement;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Any special requests that have been made for this hospitalization encounter,
     * such as the provision of specific equipment or other things.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $specialArrangement
     * @return static
     */
    public function addSpecialArrangement(FHIRCodeableConcept $specialArrangement = null)
    {
        $this->specialArrangement[] = $specialArrangement;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Any special requests that have been made for this hospitalization encounter,
     * such as the provision of specific equipment or other things.
     *
     * @param \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[] $specialArrangement
     * @return static
     */
    public function setSpecialArrangement(array $specialArrangement = [])
    {
        $this->specialArrangement = [];
        if ([] === $specialArrangement) {
            return $this;
        }
        foreach($specialArrangement as $v) {
            if ($v instanceof FHIRCodeableConcept) {
                $this->addSpecialArrangement($v);
            } else {
                $this->addSpecialArrangement(new FHIRCodeableConcept($v));
            }
        }
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Special courtesies (VIP, board member).
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[]
     */
    public function getSpecialCourtesy()
    {
        return $this->specialCourtesy;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Special courtesies (VIP, board member).
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept $specialCourtesy
     * @return static
     */
    public function addSpecialCourtesy(FHIRCodeableConcept $specialCourtesy = null)
    {
        $this->specialCourtesy[] = $specialCourtesy;
        return $this;
    }

    /**
     * A concept that may be defined by a formal reference to a terminology or ontology
     * or may be provided by text.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Special courtesies (VIP, board member).
     *
     * @param \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRCodeableConcept[] $specialCourtesy
     * @return static
     */
    public function setSpecialCourtesy(array $specialCourtesy = [])
    {
        $this->specialCourtesy = [];
        if ([] === $specialCourtesy) {
            return $this;
        }
        foreach($specialCourtesy as $v) {
            if ($v instanceof FHIRCodeableConcept) {
                $this->addSpecialCourtesy($v);
            } else {
                $this->addSpecialCourtesy(new FHIRCodeableConcept($v));
            }
        }
        return $this;
    }

    /**
     * Returns the validation rules that this type's fields must comply with to be considered "valid"
     * The returned array is in ["fieldname[.offset]" => ["rule" => {constraint}]]
     *
     * @return array
     */
    public function _getValidationRules()
    {
        return self::$_validationRules;
    }

    /**
     * Validates that this type conforms to the specifications set forth for it by FHIR.  An empty array must be seen as
     * passing.
     *
     * @return array
     */
    public function _getValidationErrors()
    {
        $errs = parent::_getValidationErrors();
        $validationRules = $this->_getValidationRules();
        if (null !== ($v = $this->getAdmitSource())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_ADMIT_SOURCE] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getDestination())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_DESTINATION] = $fieldErrs;
            }
        }
        if ([] !== ($vs = $this->getDietPreference())) {
            foreach($vs as $i => $v) {
                if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                    $errs[sprintf('%s.%d', self::FIELD_DIET_PREFERENCE, $i)] = $fieldErrs;
                }
            }
        }
        if (null !== ($v = $this->getDischargeDisposition())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_DISCHARGE_DISPOSITION] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getOrigin())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_ORIGIN] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getPreAdmissionIdentifier())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_PRE_ADMISSION_IDENTIFIER] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getReAdmission())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_RE_ADMISSION] = $fieldErrs;
            }
        }
        if ([] !== ($vs = $this->getSpecialArrangement())) {
            foreach($vs as $i => $v) {
                if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                    $errs[sprintf('%s.%d', self::FIELD_SPECIAL_ARRANGEMENT, $i)] = $fieldErrs;
                }
            }
        }
        if ([] !== ($vs = $this->getSpecialCourtesy())) {
            foreach($vs as $i => $v) {
                if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                    $errs[sprintf('%s.%d', self::FIELD_SPECIAL_COURTESY, $i)] = $fieldErrs;
                }
            }
        }
        if (isset($validationRules[self::FIELD_ADMIT_SOURCE])) {
            $v = $this->getAdmitSource();
            foreach($validationRules[self::FIELD_ADMIT_SOURCE] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_ADMIT_SOURCE, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_ADMIT_SOURCE])) {
                        $errs[self::FIELD_ADMIT_SOURCE] = [];
                    }
                    $errs[self::FIELD_ADMIT_SOURCE][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_DESTINATION])) {
            $v = $this->getDestination();
            foreach($validationRules[self::FIELD_DESTINATION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_DESTINATION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_DESTINATION])) {
                        $errs[self::FIELD_DESTINATION] = [];
                    }
                    $errs[self::FIELD_DESTINATION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_DIET_PREFERENCE])) {
            $v = $this->getDietPreference();
            foreach($validationRules[self::FIELD_DIET_PREFERENCE] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_DIET_PREFERENCE, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_DIET_PREFERENCE])) {
                        $errs[self::FIELD_DIET_PREFERENCE] = [];
                    }
                    $errs[self::FIELD_DIET_PREFERENCE][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_DISCHARGE_DISPOSITION])) {
            $v = $this->getDischargeDisposition();
            foreach($validationRules[self::FIELD_DISCHARGE_DISPOSITION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_DISCHARGE_DISPOSITION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_DISCHARGE_DISPOSITION])) {
                        $errs[self::FIELD_DISCHARGE_DISPOSITION] = [];
                    }
                    $errs[self::FIELD_DISCHARGE_DISPOSITION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_ORIGIN])) {
            $v = $this->getOrigin();
            foreach($validationRules[self::FIELD_ORIGIN] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_ORIGIN, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_ORIGIN])) {
                        $errs[self::FIELD_ORIGIN] = [];
                    }
                    $errs[self::FIELD_ORIGIN][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_PRE_ADMISSION_IDENTIFIER])) {
            $v = $this->getPreAdmissionIdentifier();
            foreach($validationRules[self::FIELD_PRE_ADMISSION_IDENTIFIER] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_PRE_ADMISSION_IDENTIFIER, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_PRE_ADMISSION_IDENTIFIER])) {
                        $errs[self::FIELD_PRE_ADMISSION_IDENTIFIER] = [];
                    }
                    $errs[self::FIELD_PRE_ADMISSION_IDENTIFIER][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_RE_ADMISSION])) {
            $v = $this->getReAdmission();
            foreach($validationRules[self::FIELD_RE_ADMISSION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_RE_ADMISSION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_RE_ADMISSION])) {
                        $errs[self::FIELD_RE_ADMISSION] = [];
                    }
                    $errs[self::FIELD_RE_ADMISSION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_SPECIAL_ARRANGEMENT])) {
            $v = $this->getSpecialArrangement();
            foreach($validationRules[self::FIELD_SPECIAL_ARRANGEMENT] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_SPECIAL_ARRANGEMENT, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_SPECIAL_ARRANGEMENT])) {
                        $errs[self::FIELD_SPECIAL_ARRANGEMENT] = [];
                    }
                    $errs[self::FIELD_SPECIAL_ARRANGEMENT][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_SPECIAL_COURTESY])) {
            $v = $this->getSpecialCourtesy();
            foreach($validationRules[self::FIELD_SPECIAL_COURTESY] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ENCOUNTER_DOT_HOSPITALIZATION, self::FIELD_SPECIAL_COURTESY, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_SPECIAL_COURTESY])) {
                        $errs[self::FIELD_SPECIAL_COURTESY] = [];
                    }
                    $errs[self::FIELD_SPECIAL_COURTESY][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_MODIFIER_EXTENSION])) {
            $v = $this->getModifierExtension();
            foreach($validationRules[self::FIELD_MODIFIER_EXTENSION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_BACKBONE_ELEMENT, self::FIELD_MODIFIER_EXTENSION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_MODIFIER_EXTENSION])) {
                        $errs[self::FIELD_MODIFIER_EXTENSION] = [];
                    }
                    $errs[self::FIELD_MODIFIER_EXTENSION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_EXTENSION])) {
            $v = $this->getExtension();
            foreach($validationRules[self::FIELD_EXTENSION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ELEMENT, self::FIELD_EXTENSION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_EXTENSION])) {
                        $errs[self::FIELD_EXTENSION] = [];
                    }
                    $errs[self::FIELD_EXTENSION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_ID])) {
            $v = $this->getId();
            foreach($validationRules[self::FIELD_ID] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ELEMENT, self::FIELD_ID, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_ID])) {
                        $errs[self::FIELD_ID] = [];
                    }
                    $errs[self::FIELD_ID][$rule] = $err;
                }
            }
        }
        return $errs;
    }

    /**
     * @param \SimpleXMLElement|string|null $sxe
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIREncounter\FHIREncounterHospitalization $type
     * @param null|int $libxmlOpts
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIREncounter\FHIREncounterHospitalization
     */
    public static function xmlUnserialize($sxe = null, PHPFHIRTypeInterface $type = null, $libxmlOpts = 591872)
    {
        if (null === $sxe) {
            return null;
        }
        if (is_string($sxe)) {
            libxml_use_internal_errors(true);
            $sxe = new \SimpleXMLElement($sxe, $libxmlOpts, false);
            if ($sxe === false) {
                throw new \DomainException(sprintf('FHIREncounterHospitalization::xmlUnserialize - String provided is not parseable as XML: %s', implode(', ', array_map(function(\libXMLError $err) { return $err->message; }, libxml_get_errors()))));
            }
            libxml_use_internal_errors(false);
        }
        if (!($sxe instanceof \SimpleXMLElement)) {
            throw new \InvalidArgumentException(sprintf('FHIREncounterHospitalization::xmlUnserialize - $sxe value must be null, \\SimpleXMLElement, or valid XML string, %s seen', gettype($sxe)));
        }
        if (null === $type) {
            $type = new FHIREncounterHospitalization;
        } elseif (!is_object($type) || !($type instanceof FHIREncounterHospitalization)) {
            throw new \RuntimeException(sprintf(
                'FHIREncounterHospitalization::xmlUnserialize - $type must be instance of \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIREncounter\FHIREncounterHospitalization or null, %s seen.',
                is_object($type) ? get_class($type) : gettype($type)
            ));
        }
        FHIRBackboneElement::xmlUnserialize($sxe, $type);
        $xmlNamespaces = $sxe->getDocNamespaces(false, false);
        if ([] !== $xmlNamespaces) {
            $ns = reset($xmlNamespaces);
            if (false !== $ns && '' !== $ns) {
                $type->_xmlns = $ns;
            }
        }
        $attributes = $sxe->attributes();
        $children = $sxe->children();
        if (isset($children->admitSource)) {
            $type->setAdmitSource(FHIRCodeableConcept::xmlUnserialize($children->admitSource));
        }
        if (isset($children->destination)) {
            $type->setDestination(FHIRReference::xmlUnserialize($children->destination));
        }
        if (isset($children->dietPreference)) {
            foreach($children->dietPreference as $child) {
                $type->addDietPreference(FHIRCodeableConcept::xmlUnserialize($child));
            }
        }
        if (isset($children->dischargeDisposition)) {
            $type->setDischargeDisposition(FHIRCodeableConcept::xmlUnserialize($children->dischargeDisposition));
        }
        if (isset($children->origin)) {
            $type->setOrigin(FHIRReference::xmlUnserialize($children->origin));
        }
        if (isset($children->preAdmissionIdentifier)) {
            $type->setPreAdmissionIdentifier(FHIRIdentifier::xmlUnserialize($children->preAdmissionIdentifier));
        }
        if (isset($children->reAdmission)) {
            $type->setReAdmission(FHIRCodeableConcept::xmlUnserialize($children->reAdmission));
        }
        if (isset($children->specialArrangement)) {
            foreach($children->specialArrangement as $child) {
                $type->addSpecialArrangement(FHIRCodeableConcept::xmlUnserialize($child));
            }
        }
        if (isset($children->specialCourtesy)) {
            foreach($children->specialCourtesy as $child) {
                $type->addSpecialCourtesy(FHIRCodeableConcept::xmlUnserialize($child));
            }
        }
        return $type;
    }

    /**
     * @param null|\SimpleXMLElement $sxe
     * @param null|int $libxmlOpts
     * @return \SimpleXMLElement
     */
    public function xmlSerialize(\SimpleXMLElement $sxe = null, $libxmlOpts = 591872)
    {
        if (null === $sxe) {
            $sxe = new \SimpleXMLElement($this->_getFHIRXMLElementDefinition(), $libxmlOpts, false);
        }
        parent::xmlSerialize($sxe);
        if (null !== ($v = $this->getAdmitSource())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_ADMIT_SOURCE, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getDestination())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_DESTINATION, null, $v->_getFHIRXMLNamespace()));
        }
        if ([] !== ($vs = $this->getDietPreference())) {
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $v->xmlSerialize($sxe->addChild(self::FIELD_DIET_PREFERENCE, null, $v->_getFHIRXMLNamespace()));
            }
        }
        if (null !== ($v = $this->getDischargeDisposition())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_DISCHARGE_DISPOSITION, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getOrigin())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_ORIGIN, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getPreAdmissionIdentifier())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_PRE_ADMISSION_IDENTIFIER, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getReAdmission())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_RE_ADMISSION, null, $v->_getFHIRXMLNamespace()));
        }
        if ([] !== ($vs = $this->getSpecialArrangement())) {
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $v->xmlSerialize($sxe->addChild(self::FIELD_SPECIAL_ARRANGEMENT, null, $v->_getFHIRXMLNamespace()));
            }
        }
        if ([] !== ($vs = $this->getSpecialCourtesy())) {
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $v->xmlSerialize($sxe->addChild(self::FIELD_SPECIAL_COURTESY, null, $v->_getFHIRXMLNamespace()));
            }
        }
        return $sxe;
    }

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        $a = parent::jsonSerialize();
        if (null !== ($v = $this->getAdmitSource())) {
            $a[self::FIELD_ADMIT_SOURCE] = $v;
        }
        if (null !== ($v = $this->getDestination())) {
            $a[self::FIELD_DESTINATION] = $v;
        }
        if ([] !== ($vs = $this->getDietPreference())) {
            $a[self::FIELD_DIET_PREFERENCE] = [];
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $a[self::FIELD_DIET_PREFERENCE][] = $v;
            }
        }
        if (null !== ($v = $this->getDischargeDisposition())) {
            $a[self::FIELD_DISCHARGE_DISPOSITION] = $v;
        }
        if (null !== ($v = $this->getOrigin())) {
            $a[self::FIELD_ORIGIN] = $v;
        }
        if (null !== ($v = $this->getPreAdmissionIdentifier())) {
            $a[self::FIELD_PRE_ADMISSION_IDENTIFIER] = $v;
        }
        if (null !== ($v = $this->getReAdmission())) {
            $a[self::FIELD_RE_ADMISSION] = $v;
        }
        if ([] !== ($vs = $this->getSpecialArrangement())) {
            $a[self::FIELD_SPECIAL_ARRANGEMENT] = [];
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $a[self::FIELD_SPECIAL_ARRANGEMENT][] = $v;
            }
        }
        if ([] !== ($vs = $this->getSpecialCourtesy())) {
            $a[self::FIELD_SPECIAL_COURTESY] = [];
            foreach($vs as $v) {
                if (null === $v) {
                    continue;
                }
                $a[self::FIELD_SPECIAL_COURTESY][] = $v;
            }
        }
        if ([] !== ($vs = $this->_getFHIRComments())) {
            $a[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS] = $vs;
        }
        return $a;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return self::FHIR_TYPE_NAME;
    }
}


text:
macro (escape str)
  message("${str}")
endmacro ()

escape("\\")

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using Mozu.Api.Security;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace Mozu.Api.Resources.Commerce.Returns
{
	///
	/// Use the Return Shipments subresource to manage shipments for a return replacement.
	///
	public partial class ShipmentResource  	{
		///
		/// <see cref="Mozu.Api.ApiContext"/>
		///
		private readonly IApiContext _apiContext;

		public ShipmentResource(IApiContext apiContext)
		{
			_apiContext = apiContext;
		}

		public ShipmentResource CloneWithApiContext(Action<IApiContext> contextModification)
		{
			return new ShipmentResource(_apiContext.CloneWith(contextModification));
		}

		///
		/// Retrieves the details of the specified return replacement shipment.
		///
		/// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="shipmentId">Unique identifier of the shipment to retrieve.</param>
		/// <returns>
		/// <see cref="Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment"/>
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   var shipment = shipment.GetShipment( returnId,  shipmentId,  responseFields);
		///
		/// </example>
		[Obsolete("This method is obsolete; use the async method instead")]
		public virtual Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment GetShipment(string returnId, string shipmentId, string responseFields =  null)
		{
			MozuClient<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment> response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.GetShipmentClient( returnId,  shipmentId,  responseFields);
			client.WithContext(_apiContext);
			response = client.Execute();
			return response.Result();

		}

		///
		/// Retrieves the details of the specified return replacement shipment.
		///
		/// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="shipmentId">Unique identifier of the shipment to retrieve.</param>
		/// <returns>
		/// <see cref="Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment"/>
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   var shipment = await shipment.GetShipmentAsync( returnId,  shipmentId,  responseFields);
		///
		/// </example>
		public virtual async Task<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment> GetShipmentAsync(string returnId, string shipmentId, string responseFields =  null)
		{
			MozuClient<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment> response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.GetShipmentClient( returnId,  shipmentId,  responseFields);
			client.WithContext(_apiContext);
			response = await client.ExecuteAsync();
			return await response.ResultAsync();

		}

		///
		/// Creates a shipment from one or more packages associated with a return replacement.
		///
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="packageIds">List of unique identifiers for each package associated with this shipment. Not all packages must belong to the same shipment.</param>
		/// <returns>
		/// List{<see cref="Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package"/>}
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   var package = shipment.CreatePackageShipments( packageIds,  returnId);
		///
		/// </example>
		[Obsolete("This method is obsolete; use the async method instead")]
		public virtual List<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package> CreatePackageShipments(List<string> packageIds, string returnId)
		{
			MozuClient<List<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package>> response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.CreatePackageShipmentsClient( packageIds,  returnId);
			client.WithContext(_apiContext);
			response = client.Execute();
			return response.Result();

		}

		///
		/// Creates a shipment from one or more packages associated with a return replacement.
		///
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="packageIds">List of unique identifiers for each package associated with this shipment. Not all packages must belong to the same shipment.</param>
		/// <returns>
		/// List{<see cref="Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package"/>}
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   var package = await shipment.CreatePackageShipmentsAsync( packageIds,  returnId);
		///
		/// </example>
		public virtual async Task<List<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package>> CreatePackageShipmentsAsync(List<string> packageIds, string returnId)
		{
			MozuClient<List<Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Package>> response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.CreatePackageShipmentsClient( packageIds,  returnId);
			client.WithContext(_apiContext);
			response = await client.ExecuteAsync();
			return await response.ResultAsync();

		}

		///
		/// Deletes a shipment for a return replacement.
		///
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="shipmentId">Unique identifier of the shipment to retrieve.</param>
		/// <returns>
		///
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   shipment.DeleteShipment( returnId,  shipmentId);
		///
		/// </example>
		[Obsolete("This method is obsolete; use the async method instead")]
		public virtual void DeleteShipment(string returnId, string shipmentId)
		{
			MozuClient response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.DeleteShipmentClient( returnId,  shipmentId);
			client.WithContext(_apiContext);
			response = client.Execute();

		}

		///
		/// Deletes a shipment for a return replacement.
		///
		/// <param name="returnId">Unique identifier of the return whose items you want to get.</param>
		/// <param name="shipmentId">Unique identifier of the shipment to retrieve.</param>
		/// <returns>
		///
		/// </returns>
		/// <example>
		///
		///   var shipment = new Shipment();
		///   await shipment.DeleteShipmentAsync( returnId,  shipmentId);
		///
		/// </example>
		public virtual async Task DeleteShipmentAsync(string returnId, string shipmentId)
		{
			MozuClient response;
			var client = Mozu.Api.Clients.Commerce.Returns.ShipmentClient.DeleteShipmentClient( returnId,  shipmentId);
			client.WithContext(_apiContext);
			response = await client.ExecuteAsync();

		}

	}

}


text:
package gitbucket.core.servlet

import javax.servlet._
import javax.servlet.http.HttpServletRequest

import org.scalatra.ScalatraFilter

import scala.collection.mutable.ListBuffer

class CompositeScalatraFilter extends Filter {

  private val filters = new ListBuffer[(ScalatraFilter, String)]()

  def mount(filter: ScalatraFilter, path: String): Unit = {
    filters += ((filter, path))
  }

  override def init(filterConfig: FilterConfig): Unit = {
    filters.foreach { case (filter, _) =>
      filter.init(filterConfig)
    }
  }

  override def destroy(): Unit = {
    filters.foreach { case (filter, _) =>
      filter.destroy()
    }
  }

  override def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain): Unit = {
    val contextPath = request.getServletContext.getContextPath
    val requestPath = request.asInstanceOf[HttpServletRequest].getRequestURI.substring(contextPath.length)
    val checkPath = if(requestPath.endsWith("/")){
      requestPath
    } else {
      requestPath + "/"
    }

    if(!checkPath.startsWith("/upload/") && !checkPath.startsWith("/git/") && !checkPath.startsWith("/git-lfs/") &&
       !checkPath.startsWith("/plugin-assets/") && !checkPath.startsWith("/console/")){
      filters
        .filter { case (_, path) =>
          val start = path.replaceFirst("/\\*$", "/")
          checkPath.startsWith(start)
        }
        .foreach { case (filter, _) =>
          val mockChain = new MockFilterChain()
          filter.doFilter(request, response, mockChain)
          if(mockChain.continue == false){
            return ()
          }
        }
    }

    chain.doFilter(request, response)
  }

}

class MockFilterChain extends FilterChain {
  var continue: Boolean = false

  override def doFilter(request: ServletRequest, response: ServletResponse): Unit = {
    continue = true
  }
}

//class FilterChainFilter(chain: FilterChain) extends Filter {
//  override def init(filterConfig: FilterConfig): Unit = ()
//  override def destroy(): Unit  = ()
//  override def doFilter(request: ServletRequest, response: ServletResponse, mockChain: FilterChain) = chain.doFilter(request, response)
//}


text:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Supergun
{
    public class StateController : MonoBehaviour
    {
        public Enemy enemy;
        public State currentState;
        public State remainState;

        [HideInInspector] public float stateTimeElapsed;
        [HideInInspector] public NPCMovement npc;
        [HideInInspector] public bool dead;

        private bool aiActive;

        private void OnEnable()
        {
            npc = GetComponent<NPCMovement>();
            dead = false;

            Messenger<Message>.AddListener(gameObject, OnDeath);
        }

        void OnDisable()
        {
            Messenger<Message>.RemoveListener(gameObject, OnDeath);
        }

        void FixedUpdate()
        {
            if (dead)
                return;
            currentState.UpdateState(this);
        }

        void OnDrawGizmos()
        {
            if (currentState != null)
            {
                Gizmos.color = currentState.sceneGizmoColor;
                Gizmos.DrawWireSphere(transform.position, enemy.gizmoRadius);
            }
        }

        public void TransitionToState(State nextState)
        {
            if (nextState != remainState)
            {
                currentState = nextState;
                OnExitState();
            }
        }

        public bool CheckIfCountDownElapsed(float duration)
        {
            stateTimeElapsed += Time.deltaTime;
            return (stateTimeElapsed >= duration);
        }

        private void OnExitState()
        {
            stateTimeElapsed = 0;
        }

        private void OnDeath(Message msg)
        {
            if (msg.Type == MessageType.DEATH)
            {
                dead = true;
            }
        }

    }
}


text:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Faq;
use App\Qa;
use App\Helpers\AppHelper;

class QaController extends Controller
{
    public function getJson(Request $request) {
        $qa = Qa::find($request->qa_id);
        return $qa;
    }

    public function update(Request $request)
    {
        $this->validate($request, [
            'question' => 'required',
            'answer' => 'required',
            'admin_code' => 'required',
        ]);

        $qa = Qa::find($request->qa_id);
        $faq = $qa->faq;
        AppHelper::checkAdminCode($request, $faq);

        $qa->question = $request->question;
        $qa->answer = $request->answer;
        $qa->save();

        return redirect($faq->path());
    }

    public function store(Request $request)
    {
        $this->validate($request, [
            'question' => 'required',
            'answer' => 'required',
            'admin_code' => 'required',
        ]);

        $faq = Faq::find($request->faq_id);
        AppHelper::checkAdminCode($request, $faq);

        $qa = new Qa;
        $qa->question = $request->question;
        $qa->answer = $request->answer;
        $qa->faq_id = $faq->id; // TODO do it in a better way
        $qa->order = $faq->qas()->count();
        $qa->save();

        return redirect($faq->path());
    }

    public function reorder(Request $request) {
        $this->validate($request, [
            'ids' => 'required',
            'admin_code' => 'required',
        ]);

        $faq = Faq::find($request->faq_id);
        AppHelper::checkAdminCode($request, $faq);

        $ids = $request->ids;
        $qasIds = $faq->qas()->orderBy('order', 'desc')->get()->pluck("id")->toArray();
        // check if both ids array match
        sort($ids);
        sort($qasIds);
        $zip = array_map(null, $qasIds, $ids);
        foreach ($zip as $id12) {
            if( $id12[0] != $id12[1] ) {
                return "nope ids dont match with qas";
            }
        }

        // keep the real order
        $ids = $request->ids;

        $countIds = count($ids);
        for($i = 0; $i < $countIds; $i++) {
            $qa = Qa::find($ids[$i]);
            $newOrder = $countIds - $i - 1;
            if($qa->order != $newOrder){
                $qa->order = $newOrder;
                $qa->save();
            }
        }

        return redirect($faq->path());
    }

    public function delete(Request $request) {
        $this->validate($request, [
            'admin_code' => 'required',
        ]);

        $qa = Qa::find($request->qa_id);
        $faq = $qa->faq;
        AppHelper::checkAdminCode($request, $faq);

        $qa->delete();

        $request->session()->flash('status', "Delete okay");
        return redirect($faq->path());
    }

    // TODO WARNING apparently there is still a bug
    public function up(Request $request)
    {
        $this->validate($request, [
            'admin_code' => 'required',
        ]);

        $qa = Qa::find($request->qa_id);
        $faq = $qa->faq;
        AppHelper::checkAdminCode($request, $faq);

        // If there is not enough question/answer, don't bother
        if($faq->qas()->count() <= 1) {
            $request->session()->flash("error", "There is not enough questions/answers!");
            return redirect($faq->path());
        }
        // If first element
        if($qa->order == $faq->qas()->count() - 1) {
            $request->session()->flash("error", "This is already the first element");
            return redirect($faq->path());
        }

        $qa_next = Qa::where("order", $qa->order + 1)->first();

        $qa->faq_id = $faq->id; // TODO do it in a better way
        $qa->order = $qa->order + 1;
        $qa_next->order = $qa_next->order - 1;
        $qa_next->update();
        $qa->update();

        return redirect($faq->path());
    }

    // TODO WARNING apparently there is still a bug
    public function down(Request $request)
    {
        $this->validate($request, [
            'admin_code' => 'required',
        ]);

        $qa = Qa::find($request->qa_id);
        $faq = $qa->faq;
        AppHelper::checkAdminCode($request, $faq);

        // If there is not enough question/answer, don't bother
        if($faq->qas()->count() <= 1) {
            $request->session()->flash("error", "There is not enough questions/answers!");
            return redirect($faq->path());
        }
        // If last element
        if($qa->order == 0) {
            $request->session()->flash("error", "This is already the last element");
            return redirect($faq->path());
        }

        $qa_next = Qa::where("order", $qa->order - 1)->first();

        $qa->faq_id = $faq->id; // TODO do it in a better way
        $qa->order = $qa->order - 1;
        $qa_next->order = $qa_next->order + 1;
        $qa_next->update();
        $qa->update();

        return redirect($faq->path());
    }
}


text:
<?php

namespace Supernova;

/**
 * Modulo de Formularios
 */
class Form extends \Supernova\Model
{
    public static $counter = 0;

    public static function setContentType($type = "application/x-www-form-urlencoded")
    {
        return $_SERVER['CONTENT_TYPE'] = $type;
    }

    public static function csrfToken()
    {
        return md5(time().uniqid());
    }

    public static function create($args)
    {
        // Carga un nuevo objeto formulario // Load new form object
        $modelForm = "\App\Model\\".$args['model']."Form";
        $form = new $modelForm();
        $form->modelName = $args['model'];
        $form->values = (isset($args['values']) && !empty($args['values'])) ? $args['values']->toArray() : array();
        $form->schema = \Supernova\Cache::load($args['model']);
        // Genera el formulario // Generate form
        $action = (isset($args['action'])) ? \Supernova\Route::generateUrl($args['action']) : "";
        $output = "<form class='form-horizontal' role='form' action='$action' method='POST' >";
        // Genera los inputs // Generate inputs
        $form->notShow = array( "created", "updated", "created_at", "updated_at", "modified" , "creado_en", "actualizado_en" );
        foreach ($form->schema as $field) {
            if (!in_array($field['Field'], $form->notShow)) {
                $output.= self::input($field, $form);
            }
        }
        // Agrega boton submit en el formulario // Add submit button in form
        if (!(isset($args['submit']) && $args['submit'] == false)) {
            $output.= self::submit();
        }
        self::$counter++;
        return $output;
    }

    public static function input($field, $form)
    {
        $fieldName = $field['Field'];
        $value = (isset($form->values[$fieldName]) ) ? $form->values[$fieldName] : null ;
        if (isset($form->settings[$fieldName]["widget"])) {
            extract($form->settings[$fieldName]["widget"]);
        }
        $inputId = (isset($id)) ? $id : $fieldName."_form";
        $label = (isset($label)) ? $label : $fieldName;
        $class = (isset($class)) ? $class : "form-control";
        $type = (isset($field['Type'])) ? ((isset($type)) ? $type : $field['Type'] ): "text";
        $extraOutput = "";
        $output = "";
        if (isset($extra)) {
            foreach ($extra as $k => $v) {
                $extraOutput.="$k='$v' ";
            }
        }

        if ($fieldName == $form->primaryKey) {
            $type="hidden";
            $labelRender = "";
        } else {
            $labelRender = "$label";
        }

        $model = explode("\\", get_parent_class($form));
        $model = end($model);
        $counter = self::$counter;
        $inputName = "data[$model][$fieldName]";
        $type = explode("(", $type);
        $type = current($type);
        $inputRender = "";
        switch ($type) {
            case 'varchar':
            default:
                $inputRender = "<input type='$type' name='$inputName' class='$class' id='$inputId' value='$value' $extraOutput>";
                break;
            case 'select':
            case 'int':
                $inputRender.="<select name='$inputName' class='$class' id='$inputId' $extraOutput >";
                if (isset($form->settings[$fieldName]["widget"]["empty"]) && $form->settings[$fieldName]["widget"]["empty"]) {
                    $inputRender.="<option value=''>-- ".__("None")." --</option>";
                }
                if (isset($form->settings[$fieldName]["widget"]["options"])) {
                    if ($options = $form->settings[$fieldName]["widget"]["options"]) {
                        if (is_string($options)) {
                            $fn = explode("::", $form->settings[$fieldName]["widget"]["options"]);
                            if (method_exists($fn[0], $fn[1])) {
                                $options = $fn[0]::$fn[1]();
                            } else {
                                $options = array();
                            }
                        }
                        foreach ($options as $k => $v) {
                            $selected = ($k == $value) ? "selected" : "";
                            $inputRender.="  <option value='$k' $selected>$v</option>";
                        }
                    }
                }
                $inputRender.="</select>";
                break;
            case 'text':
            case 'textarea':
                $inputRender.="<textarea name='$inputName' class='$class' id='$inputId' $extraOutput>$value</textarea>";
                break;
            case 'checkbox':
            case 'tinyint':
            case 'bool':
            case 'boolean':
                $inputRender = "<input type='checkbox' name='$inputName' class='$class' id='$inputId' value='$value' $extraOutput>";
                break;
            case 'radio':
                $inputRender = "<input type='radio' name='$inputName' class='$class' id='$inputId' value='$value' $extraOutput>";
                break;
            /*
            TODO:
            case 'time' : break;
            case 'date' : break;
            case 'datetime' : break;
            */
        }

        $output = <<<EOL

            $labelRender

                $inputRender

EOL;

        return $output;
    }

    public static function submit($submit = "Submit")
    {
        $submit = __($submit);
        $output=<<<EOL

                <button type="submit" class="btn btn-default">$submit</button>

EOL;

        return $output;
    }
}


text:
angular.module('MyApp')
  .controller('DownloadController', ["$scope", "$interval", "$http", function($scope, $interval, $http){
    $scope.start_time = "";
    $scope.end_date = "";
    $scope.serial_numbers = "";
    $scope.durationDays = "";
    $scope.durationHours = "";
    $scope.durationMinutes = "";
    $scope.zipfilename = "";
    $scope.use_instant_values = false;
    $scope.use_uncompensated_values = false;
    $scope.showHelp = false;

    //$interval(function(){
    //  console.log($scope.start_date);
    //}, 1000);

    $scope.toggleHelp = function(){
      if($scope.showHelp){
        $scope.showHelp = false;
      }
      else{
        $scope.showHelp = true;
      }
    };

    $scope.onDownloadClick = function(){
      // compose a valid JSON object

      // Serial Numbers
      var serialNumbers = [].concat($scope.serial_numbers.split("\n"));
      var validSerialNumbers = serialNumbers.map(function (serialNumber) {
        return serialNumber.trim();
      });

      if (validSerialNumbers.length == 0 || $scope.serial_numbers.trim() == "") {
        alert("Please enter at least one Serial Nubmer");
        return;
      }

      var postObj = {
        "serial-numbers": validSerialNumbers
      };

      // Start Date
      var startDateStr = $scope.start_date;
      var startDate = null;
      if(startDateStr) {
        startDate = moment(startDateStr);
      }
      if ($scope.start_date && startDateStr && startDate && !startDate.isValid()) {
        alert("Start date is not complete / valid.");
        return;
      }

      // End Date
      var endDateStr = $scope.end_date;
      var endDate = null;
      if(endDateStr) {
        endDate = moment(endDateStr);
      }
      if ($scope.end_date && endDateStr && endDate && !endDate.isValid()) {
        alert("End date is not complete / valid.");
      }

      if(startDateStr != "" && startDate && startDate.isValid() && endDateStr != "" && endDate && endDate.isValid()){
        if(!endDate.isAfter(startDate)){
          alert("End date must be *after* start date.");
          return;
        }
      }

      // Duration
      var duration = "";
      //if($("#durationYears").val() != ""){
      //    duration += $("#durationYears").val() + "Y";
      //}
      //if($("#durationMonths").val() != ""){
      //    duration += $("#durationMonths").val() + "M";
      //}

      if($scope.durationDays){
        duration += $scope.durationDays + "D";
      }

      if($scope.durationHours || $scope.durationMinutes){
        duration += "T";
        if($scope.durationHours){
          duration += $scope.durationHours + "H";
        }
        if($scope.durationMinutes){
          duration += $scope.durationMinutes + "M";
        }
      }
      if(duration != ""){
        duration = "P" + duration;
        postObj["duration"] = duration;
      }

      if(postObj["duration"] && postObj["end-date"] && postObj["start-date"]){
        alert("Duration cannot be used with *both* start date *and* end date");
        return;
      }

      function validStartDate(){
        return startDateStr != "" && startDate && startDate.isValid();
      }

      function validEndDate(){
        return endDateStr != "" && endDate && endDate.isValid();
      }

      function validDuration(){
        return duration != "";
      }

      // WORKAROUND: OpenSensors API supports a duration param
      //             but there is a bug that makes it not work
      //             if the query requires iteration
      //             ... so make duration become an end-date instead
      // Case #1: start date and duration provided, but not end date
      if(validDuration() && validStartDate() && !validEndDate()){
        var dur = moment.duration(duration);
        postObj["start-date"] = startDate.format();
        postObj["end-date"] = startDate.add(dur).format();
        delete postObj.duration;
      }
      // Case #2: end date and duration provided, but not start date
      else if(validDuration() && !validStartDate() && validEndDate()){
        var dur = moment.duration(duration);
        postObj["end-date"] = endDate.format();
        postObj["start-date"] = endDate.subtract(dur).format();
        delete postObj.duration;
      }
      // Case #3: duration provided, with neither start date nor end date
      else if(validDuration() && !validStartDate() && !validEndDate()){
        var dur = moment.duration(duration);
        endDate = moment();
        postObj["end-date"] = endDate.format();
        postObj["start-date"] = endDate.subtract(dur).format();
        delete postObj.duration;
      }
      // Case #4: neither duration, nor start date, nor end date were provided
      else if(!validDuration() && !validStartDate() && !validEndDate()){
        alert("Not providing any of duration, start date, or end date is invalid.");
        return;
      }
      // Case #5: all of duration, start date, and end date were provided
      else if(validDuration() && validStartDate() && validEndDate()){
        alert("Providing duration, start date, *and* end date is invalid.");
        return;
      }
      // Case #6: end date was provided, but neither duration, nor start date
      else if(!validDuration() && !validStartDate() && validEndDate()){
        alert("Providing a end date, but neither duration nor start date is invalid.");
        return;
      }
      // Case #7:
      else if(!validDuration() && validStartDate() && validEndDate()){
        // this is fine, nothing to do here
        // duration is not in play / implied
        postObj["start-date"] = startDate.format();
        postObj["end-date"] = endDate.format();
      }
      // Case #8: start date provided with neither end date nor duration
      else if(!validDuration() && validStartDate() && !validEndDate()){
        postObj["start-date"] = startDate.format();
        postObj["end-date"] = moment().format();
      }

      // restrict requests to 24 hours
      var requested_duration_in_hours = moment(postObj["end-date"]).diff(moment(postObj["start-date"]), 'seconds') / 60 / 60;
      if(requested_duration_in_hours > 168){
        alert("Please request no more than 168 hours of data at a time. You asked for " + Math.ceil(requested_duration_in_hours) + " hours." );
        return;
      }

      // zip filename, handle the user providing the zip extension, or not
      if($scope.zipfilename){
        var fname = $scope.zipfilename.trim();
        if(/\.zip$/.test(fname)){
          fname = fname.substr(0, fname.length - 4);
        }
        postObj.zipfilename = fname;
      }

      if($scope.use_instant_values){
        postObj.use_instant_values = true;
      }

      if($scope.use_uncompensated_values){
        postObj.use_uncompensated_values = true;
      }

      var uri = null;
      var guid = null;
      var statusIntervalId = null;
      $('body').addClass("loading");
      $http.post("", postObj).success(function (resp) {
        uri = resp.uri;
        guid = resp.guid;
        $("#download-file-links").html("");
        var status_list = $("#status").html("");
        statusIntervalId = $interval(function(){
          $http.get('/download/status?guid='+guid).success(function(data, textStatus, jqXHR){
            if(data){
              $("#status").html("

");
              var status_list = $("#status ul")
              var keys = Object.keys(data);
              var allDone = true;
              var atLeastOneWithNoError = false;

              for(var ii = 0; ii < keys.length; ii++){
                if(keys[ii] == "complete"){
                  continue;
                }

                if(!data[keys[ii]].complete){
                  allDone = false;
                }

                var m = moment(data[keys[ii]].timestamp);
                // convert m to local time
                m.utcOffset(moment().utcOffset());
                var numResults = data[keys[ii]].numResults || 0;

                if(!data[keys[ii]].error){
                  atLeastOneWithNoError = true;
                }

                status_list.append("
"
                  +keys[ii] + ': '
                  + (data[keys[ii]].complete ? 'done' : (numResults > 0 ? 'in progress' : 'pending'))
                  + ' / ' + numResults
                  + ' / ' + (data[keys[ii]].timestamp ? m.format("MM/DD/YYYY, hh:mm:ss A") : '---')
                  + ((data[keys[ii]].error) ? " [Error: " + data[keys[ii]].errorMessage + "]" : "" )
                  + '
');

              }
              if(allDone && data.complete){
                $interval.cancel(statusIntervalId);
                statusIntervalId = undefined;
                $('body').removeClass("loading");
                if(atLeastOneWithNoError) {
                  $("#download-file-links").html('Download File
');
                }
              }
            }
          });
        }, 5000);
      });
    };
  }]);


text:
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/**
 * @private
 * @fileoverview WebSocket client implementation
 */

var isBrowser = require('is-browser');
var WebSocket = require('ws');

var Deferred = require('./../lib/deferred');
var TaskSequence = require('./../lib/task-sequence');
var Proxy = require('./index');
var vlog = require('./../lib/vlog');

/**
 * A client for the vanadium service using websockets. Connects to the vanadium
 * wspr and performs RPCs.
 * @constructor
 * @private
 * @param {string} url of wspr that connects to the vanadium network
 * identity
 */
function ProxyConnection(url) {
  this.url = url.replace(/^(http|https)/, 'ws') + '/ws';
  this.currentWebSocketPromise = null;
  // Since we haven't finished constructing the Proxy object,
  // we can't call this.getWebsocket() to return the sender promise.
  // Instead, we create a new promise that will eventually call
  // getWebsocket and only resolve the promise after Proxy.call
  // has completed.
  var def = new Deferred();
  Proxy.call(this, def.promise);
  var proxy = this;
  this.getWebSocket().then(function success() {
    def.resolve(proxy);
  }, def.reject);
  this._tasks = new TaskSequence();
}

ProxyConnection.prototype = Object.create(Proxy.prototype);

ProxyConnection.prototype.constructor = ProxyConnection;

/**
 * Connects to the server and returns an open web socket connection
 * @private
 * @return {promise} a promise that will be fulfilled with a websocket object
 * when the connection is established.
 */
ProxyConnection.prototype.getWebSocket = function() {
  // We are either connecting or already connected, return the same promise
  if (this.currentWebSocketPromise) {
    return this.currentWebSocketPromise;
  }

  // TODO(bjornick): Implement a timeout mechanism.
  var websocket = new WebSocket(this.url);
  var self = this;
  var deferred = new Deferred();
  this.currentWebSocketPromise = deferred.promise;
  websocket.onopen = function() {
    vlog.logger.info('Connected to wspr at', self.url);
    deferred.resolve(websocket);
  };
  websocket.onerror = function(e) {
    var isEvent = isBrowser && !!window.Event && e instanceof window.Event;
    var isErrorEvent = isEvent && e.type === 'error';

    // It's possible to get a DOM WebSocket error event here, which is not an
    // actual Error object, so we must turn it into one.
    if (isErrorEvent) {
      e = new Error('WebSocket error.');
    }

    // Add a more descriptive message to the error.
    // TODO(jasoncampbell): there can be more errors than just failed
    // connection, additionally there can be more than one error emitted. We
    // should take care to cover these cases.
    e.message = 'Failed to connect to wspr at url ' + self.url +
        ': ' + e.message;

    vlog.logger.error(e);
    deferred.reject(e);
  };

  websocket.onmessage = function(frame) {
    self.process(frame.data);
  };

  return deferred.promise;
};

ProxyConnection.prototype.send = function(msg) {
  this.getWebSocket().then(function(ws) {
    ws.send(JSON.stringify(msg));
  }).catch(function(err) {
    throw err;
  });
};

ProxyConnection.prototype.close = function(cb) {
  var deferred = new Deferred(cb);
  this.cleanup();

  this.getWebSocket().then(close, function(err) {
    // TODO(jasoncampbell): Better error handling around websocket connection
    // It's possible that the initial connection failed with
    // "Error: getaddrinfo ENOTFOUND" Since there was not a
    // connection to begin with in this case it can be considered
    // successfully closed.
    deferred.resolve();
  });

  return deferred.promise;

  function close(websocket) {
    websocket.onclose = deferred.resolve;
    websocket.close();
  }
};

/**
 * Export the module
 */
module.exports = ProxyConnection;


text:
<?php
declare(strict_types=1);

use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
use PhpSchool\CliMenu\Style\SelectableStyle;

require_once(__DIR__ . '/../vendor/autoload.php');

$itemCallable = function (CliMenu $menu) {
    echo $menu->getSelectedItem()->getText();
};

$menu = (new CliMenuBuilder)
    ->setTitle('Basic CLI Menu Styling')
    ->addItem('First Item', $itemCallable)
    ->addItem('Second Item', $itemCallable)
    ->addItem('Third Item', $itemCallable)
    ->setWidth(70)
    ->setBackgroundColour('yellow')
    ->setForegroundColour('black')
    ->setPadding(4)
    ->setMargin(4)
    ->setBorder(1, 2, 'red')
    ->setTitleSeparator('- ')
    ->modifySelectableStyle(function (SelectableStyle $style) {
        $style->setUnselectedMarker(' ')
            ->setSelectedMarker('>');
    })
    ->build();

$menu->open();


text:
/* global ngDescribe, it */
angular.module('moduleA', []);

// aliases
// module -> modules
// test -> tests
ngDescribe({
  name: 'aliases',
  module: 'moduleA',
  only: false,
  verbose: false,
  test: function (deps) {
    it('it working', function () {
      la(check.object(deps));
    });
  }
});


text:
package com.codebroker.redis.collections.builder;

import com.codebroker.redis.collections.Ranking;
import com.codebroker.redis.collections.ScoresPoint;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Objects;

public abstract class AbstractScoresPoint<T extends Number> implements ScoresPoint<T> {

    protected String keyWithNameSpace;

    protected Jedis jedis;

    public AbstractScoresPoint(Jedis jedis, String keyWithNameSpace) {
        this.keyWithNameSpace = keyWithNameSpace;
        this.jedis = jedis;
    }

    @Override
    public void remove(String name) {
        jedis.zrem(keyWithNameSpace, name);
    }

    @Override
    public int size() {
        return jedis.zcard(keyWithNameSpace).intValue();
    }

    @Override
    public List<Ranking<T>> top(int top) {
        return range(0, top - 1);
    }

    @Override
    public List<Ranking<T>> last(int top) {
        long start = size() - top;
        long end = size() - 1;
        return range(start, end);
    }

    @Override
    public List<Ranking<T>> getRanking() {
        return range(0, size() - 1);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(keyWithNameSpace);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (AbstractScoresPoint.class.isInstance(obj)) {
            AbstractScoresPoint otherRedis = AbstractScoresPoint.class.cast(obj);
            return Objects.equals(otherRedis.keyWithNameSpace, keyWithNameSpace);
        }
        return false;
    }

}


text:
<!DOCTYPE mapper
	PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="BbPerspective">

	<resultMap type="com.netsteadfast.greenstep.po.hbm.BbPerspective" id="baseResultMap">
		<id column="OID" property="oid"/>
		<result column="PER_ID" property="perId"/>
		<result column="VIS_ID" property="visId"/>
		<result column="NAME" property="name"/>
		<result column="WEIGHT" property="weight"/>
		<result column="TARGET" property="target"/>
		<result column="MIN" property="min"/>
		<result column="DESCRIPTION" property="description"/>
		<result column="CUSERID" property="cuserid"/>
		<result column="CDATE" property="cdate"/>
		<result column="UUSERID" property="uuserid"/>
		<result column="UDATE" property="udate"/>
	</resultMap>

	<select id="selectByParams" resultMap="baseResultMap" >
		select * from bb_perspective where 1=1
		<if test="oid != null">
			AND OID = #{oid}
		</if>
		<if test="perId != null">
			AND PER_ID = #{perId}
		</if>
		<if test="visId != null">
			AND VIS_ID = #{visId}
		</if>
		<if test="name != null">
			AND NAME = #{name}
		</if>
	</select>

	<select id="selectByValue" resultMap="baseResultMap" >
		select * from bb_perspective where 1=1
		<if test="oid != null">
			AND OID = #{oid}
		</if>
		<if test="perId != null">
			AND PER_ID = #{perId}
		</if>
		<if test="visId != null">
			AND VIS_ID = #{visId}
		</if>
		<if test="name != null">
			AND NAME = #{name}
		</if>
	</select>

</mapper>


text:
package com.hazelcast.spring.hibernate;

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.Member;
import com.hazelcast.hibernate.HazelcastCacheRegionFactory;
import com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory;
import com.hazelcast.spring.CustomSpringJUnit4ClassRunner;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;

import javax.annotation.Resource;
import java.net.InetSocketAddress;
import java.util.Set;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(CustomSpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"hibernate-applicationContext-hazelcast.xml"})
@Category(QuickTest.class)
public class TestHibernateApplicationContext {

    @Resource(name = "instance")
    private HazelcastInstance instance;

    @Resource(name = "regionFactory")
    private HazelcastCacheRegionFactory regionFactory;

    @Resource(name = "localRegionFactory")
    private HazelcastLocalCacheRegionFactory localRegionFactory;

    @Resource(name = "localRegionFactory2")
    private HazelcastLocalCacheRegionFactory localRegionFactory2;

    @BeforeClass
    @AfterClass
    public static void start() {
        Hazelcast.shutdownAll();
    }

    @Test
    public void testInstance() {
        assertNotNull(instance);
        Set<Member> members = instance.getCluster().getMembers();
        assertEquals(1, members.size());
        Member member = members.iterator().next();
        InetSocketAddress inetSocketAddress = member.getSocketAddress();
        assertEquals(5700, inetSocketAddress.getPort());
    }

    @Test
    public void testRegionFactory() {
        assertNotNull(regionFactory);
        assertEquals(regionFactory.getHazelcastInstance(), instance);

        assertNotNull(localRegionFactory);
        assertEquals(localRegionFactory.getHazelcastInstance(), instance);

        assertNotNull(localRegionFactory2);
        assertEquals(localRegionFactory2.getHazelcastInstance(), instance);
    }
}


text:
namespace ui {

class HardwareDisplayController;

class DisplayChangeObserver {
 public:
  virtual ~DisplayChangeObserver() {}

  // Called when |controller| was changed/added.
  virtual void OnDisplayChanged(HardwareDisplayController* controller) = 0;

  // Called just before |controller| is removed. Observers that cached
  // |controller| must invalidate it at this point.
  virtual void OnDisplayRemoved(HardwareDisplayController* controller) = 0;
};

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_DRI_DISPLAY_CHANGE_OBSERVER_H_