text:
package models

import (
	"encoding/json"
	"errors"
	"fmt"
)

type DeviceComponent struct {
	DomainResource          `bson:",inline"`
	Type                    *CodeableConcept                                  `bson:"type,omitempty" json:"type,omitempty"`
	Identifier              *Identifier                                       `bson:"identifier,omitempty" json:"identifier,omitempty"`
	LastSystemChange        *FHIRDateTime                                     `bson:"lastSystemChange,omitempty" json:"lastSystemChange,omitempty"`
	Source                  *Reference                                        `bson:"source,omitempty" json:"source,omitempty"`
	Parent                  *Reference                                        `bson:"parent,omitempty" json:"parent,omitempty"`
	OperationalStatus       []CodeableConcept                                 `bson:"operationalStatus,omitempty" json:"operationalStatus,omitempty"`
	ParameterGroup          *CodeableConcept                                  `bson:"parameterGroup,omitempty" json:"parameterGroup,omitempty"`
	MeasurementPrinciple    string                                            `bson:"measurementPrinciple,omitempty" json:"measurementPrinciple,omitempty"`
	ProductionSpecification []DeviceComponentProductionSpecificationComponent `bson:"productionSpecification,omitempty" json:"productionSpecification,omitempty"`
	LanguageCode            *CodeableConcept                                  `bson:"languageCode,omitempty" json:"languageCode,omitempty"`
}

// Custom marshaller to add the resourceType property, as required by the specification
func (resource *DeviceComponent) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "DeviceComponent"
	// Dereferencing the pointer to avoid infinite recursion.
	// Passing in plain old x (a pointer to DeviceComponent), would cause this same
	// MarshallJSON function to be called again
	return json.Marshal(*resource)
}

func (x *DeviceComponent) GetBSON() (interface{}, error) {
	x.ResourceType = "DeviceComponent"
	// See comment in MarshallJSON to see why we dereference
	return *x, nil
}

// The "deviceComponent" sub-type is needed to avoid infinite recursion in UnmarshalJSON
type deviceComponent DeviceComponent

// Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
func (x *DeviceComponent) UnmarshalJSON(data []byte) (err error) {
	x2 := deviceComponent{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = DeviceComponent(x2)
		return x.checkResourceType()
	}
	return
}

func (x *DeviceComponent) checkResourceType() error {
	if x.ResourceType == "" {
		x.ResourceType = "DeviceComponent"
	} else if x.ResourceType != "DeviceComponent" {
		return errors.New(fmt.Sprintf("Expected resourceType to be DeviceComponent, instead received %s", x.ResourceType))
	}
	return nil
}

type DeviceComponentProductionSpecificationComponent struct {
	BackboneElement `bson:",inline"`
	SpecType        *CodeableConcept `bson:"specType,omitempty" json:"specType,omitempty"`
	ComponentId     *Identifier      `bson:"componentId,omitempty" json:"componentId,omitempty"`
	ProductionSpec  string           `bson:"productionSpec,omitempty" json:"productionSpec,omitempty"`
}

type DeviceComponentPlus struct {
	DeviceComponent                     `bson:",inline"`
	DeviceComponentPlusRelatedResources `bson:",inline"`
}

type DeviceComponentPlusRelatedResources struct {
	IncludedDeviceComponentResourcesReferencedByParent             *[]DeviceComponent       `bson:"_includedDeviceComponentResourcesReferencedByParent,omitempty"`
	IncludedDeviceResourcesReferencedBySource                      *[]Device                `bson:"_includedDeviceResourcesReferencedBySource,omitempty"`
	RevIncludedDocumentManifestResourcesReferencingContentref      *[]DocumentManifest      `bson:"_revIncludedDocumentManifestResourcesReferencingContentref,omitempty"`
	RevIncludedDocumentManifestResourcesReferencingRelatedref      *[]DocumentManifest      `bson:"_revIncludedDocumentManifestResourcesReferencingRelatedref,omitempty"`
	RevIncludedConsentResourcesReferencingData                     *[]Consent               `bson:"_revIncludedConsentResourcesReferencingData,omitempty"`
	RevIncludedDocumentReferenceResourcesReferencingRelatedref     *[]DocumentReference     `bson:"_revIncludedDocumentReferenceResourcesReferencingRelatedref,omitempty"`
	RevIncludedContractResourcesReferencingTtopic                  *[]Contract              `bson:"_revIncludedContractResourcesReferencingTtopic,omitempty"`
	RevIncludedContractResourcesReferencingSubject                 *[]Contract              `bson:"_revIncludedContractResourcesReferencingSubject,omitempty"`
	RevIncludedContractResourcesReferencingTopic                   *[]Contract              `bson:"_revIncludedContractResourcesReferencingTopic,omitempty"`
	RevIncludedPaymentNoticeResourcesReferencingRequestreference   *[]PaymentNotice         `bson:"_revIncludedPaymentNoticeResourcesReferencingRequestreference,omitempty"`
	RevIncludedPaymentNoticeResourcesReferencingResponsereference  *[]PaymentNotice         `bson:"_revIncludedPaymentNoticeResourcesReferencingResponsereference,omitempty"`
	RevIncludedImplementationGuideResourcesReferencingResource     *[]ImplementationGuide   `bson:"_revIncludedImplementationGuideResourcesReferencingResource,omitempty"`
	RevIncludedDeviceComponentResourcesReferencingParent           *[]DeviceComponent       `bson:"_revIncludedDeviceComponentResourcesReferencingParent,omitempty"`
	RevIncludedCommunicationResourcesReferencingBasedon            *[]Communication         `bson:"_revIncludedCommunicationResourcesReferencingBasedon,omitempty"`
	RevIncludedMessageHeaderResourcesReferencingData               *[]MessageHeader         `bson:"_revIncludedMessageHeaderResourcesReferencingData,omitempty"`
	RevIncludedProvenanceResourcesReferencingTarget                *[]Provenance            `bson:"_revIncludedProvenanceResourcesReferencingTarget,omitempty"`
	RevIncludedTaskResourcesReferencingFocus                       *[]Task                  `bson:"_revIncludedTaskResourcesReferencingFocus,omitempty"`
	RevIncludedListResourcesReferencingItem                        *[]List                  `bson:"_revIncludedListResourcesReferencingItem,omitempty"`
	RevIncludedDiagnosticRequestResourcesReferencingReplaces       *[]DiagnosticRequest     `bson:"_revIncludedDiagnosticRequestResourcesReferencingReplaces,omitempty"`
	RevIncludedDiagnosticRequestResourcesReferencingBasedon        *[]DiagnosticRequest     `bson:"_revIncludedDiagnosticRequestResourcesReferencingBasedon,omitempty"`
	RevIncludedDiagnosticRequestResourcesReferencingDefinition     *[]DiagnosticRequest     `bson:"_revIncludedDiagnosticRequestResourcesReferencingDefinition,omitempty"`
	RevIncludedDeviceUseRequestResourcesReferencingReplaces        *[]DeviceUseRequest      `bson:"_revIncludedDeviceUseRequestResourcesReferencingReplaces,omitempty"`
	RevIncludedDeviceUseRequestResourcesReferencingBasedon         *[]DeviceUseRequest      `bson:"_revIncludedDeviceUseRequestResourcesReferencingBasedon,omitempty"`
	RevIncludedDeviceUseRequestResourcesReferencingDefinition      *[]DeviceUseRequest      `bson:"_revIncludedDeviceUseRequestResourcesReferencingDefinition,omitempty"`
	RevIncludedDeviceMetricResourcesReferencingParent              *[]DeviceMetric          `bson:"_revIncludedDeviceMetricResourcesReferencingParent,omitempty"`
	RevIncludedBasicResourcesReferencingSubject                    *[]Basic                 `bson:"_revIncludedBasicResourcesReferencingSubject,omitempty"`
	RevIncludedAuditEventResourcesReferencingEntity                *[]AuditEvent            `bson:"_revIncludedAuditEventResourcesReferencingEntity,omitempty"`
	RevIncludedCompositionResourcesReferencingSubject              *[]Composition           `bson:"_revIncludedCompositionResourcesReferencingSubject,omitempty"`
	RevIncludedCompositionResourcesReferencingEntry                *[]Composition           `bson:"_revIncludedCompositionResourcesReferencingEntry,omitempty"`
	RevIncludedDetectedIssueResourcesReferencingImplicated         *[]DetectedIssue         `bson:"_revIncludedDetectedIssueResourcesReferencingImplicated,omitempty"`
	RevIncludedQuestionnaireResponseResourcesReferencingSubject    *[]QuestionnaireResponse `bson:"_revIncludedQuestionnaireResponseResourcesReferencingSubject,omitempty"`
	RevIncludedProcessResponseResourcesReferencingRequestreference *[]ProcessResponse       `bson:"_revIncludedProcessResponseResourcesReferencingRequestreference,omitempty"`
}

func (d *DeviceComponentPlusRelatedResources) GetIncludedDeviceComponentResourceReferencedByParent() (deviceComponent *DeviceComponent, err error) {
	if d.IncludedDeviceComponentResourcesReferencedByParent == nil {
		err = errors.New("Included devicecomponents not requested")
	} else if len(*d.IncludedDeviceComponentResourcesReferencedByParent) > 1 {
		err = fmt.Errorf("Expected 0 or 1 deviceComponent, but found %d", len(*d.IncludedDeviceComponentResourcesReferencedByParent))
	} else if len(*d.IncludedDeviceComponentResourcesReferencedByParent) == 1 {
		deviceComponent = &(*d.IncludedDeviceComponentResourcesReferencedByParent)[0]
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetIncludedDeviceResourceReferencedBySource() (device *Device, err error) {
	if d.IncludedDeviceResourcesReferencedBySource == nil {
		err = errors.New("Included devices not requested")
	} else if len(*d.IncludedDeviceResourcesReferencedBySource) > 1 {
		err = fmt.Errorf("Expected 0 or 1 device, but found %d", len(*d.IncludedDeviceResourcesReferencedBySource))
	} else if len(*d.IncludedDeviceResourcesReferencedBySource) == 1 {
		device = &(*d.IncludedDeviceResourcesReferencedBySource)[0]
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDocumentManifestResourcesReferencingContentref() (documentManifests []DocumentManifest, err error) {
	if d.RevIncludedDocumentManifestResourcesReferencingContentref == nil {
		err = errors.New("RevIncluded documentManifests not requested")
	} else {
		documentManifests = *d.RevIncludedDocumentManifestResourcesReferencingContentref
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDocumentManifestResourcesReferencingRelatedref() (documentManifests []DocumentManifest, err error) {
	if d.RevIncludedDocumentManifestResourcesReferencingRelatedref == nil {
		err = errors.New("RevIncluded documentManifests not requested")
	} else {
		documentManifests = *d.RevIncludedDocumentManifestResourcesReferencingRelatedref
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedConsentResourcesReferencingData() (consents []Consent, err error) {
	if d.RevIncludedConsentResourcesReferencingData == nil {
		err = errors.New("RevIncluded consents not requested")
	} else {
		consents = *d.RevIncludedConsentResourcesReferencingData
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDocumentReferenceResourcesReferencingRelatedref() (documentReferences []DocumentReference, err error) {
	if d.RevIncludedDocumentReferenceResourcesReferencingRelatedref == nil {
		err = errors.New("RevIncluded documentReferences not requested")
	} else {
		documentReferences = *d.RevIncludedDocumentReferenceResourcesReferencingRelatedref
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedContractResourcesReferencingTtopic() (contracts []Contract, err error) {
	if d.RevIncludedContractResourcesReferencingTtopic == nil {
		err = errors.New("RevIncluded contracts not requested")
	} else {
		contracts = *d.RevIncludedContractResourcesReferencingTtopic
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedContractResourcesReferencingSubject() (contracts []Contract, err error) {
	if d.RevIncludedContractResourcesReferencingSubject == nil {
		err = errors.New("RevIncluded contracts not requested")
	} else {
		contracts = *d.RevIncludedContractResourcesReferencingSubject
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedContractResourcesReferencingTopic() (contracts []Contract, err error) {
	if d.RevIncludedContractResourcesReferencingTopic == nil {
		err = errors.New("RevIncluded contracts not requested")
	} else {
		contracts = *d.RevIncludedContractResourcesReferencingTopic
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedPaymentNoticeResourcesReferencingRequestreference() (paymentNotices []PaymentNotice, err error) {
	if d.RevIncludedPaymentNoticeResourcesReferencingRequestreference == nil {
		err = errors.New("RevIncluded paymentNotices not requested")
	} else {
		paymentNotices = *d.RevIncludedPaymentNoticeResourcesReferencingRequestreference
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedPaymentNoticeResourcesReferencingResponsereference() (paymentNotices []PaymentNotice, err error) {
	if d.RevIncludedPaymentNoticeResourcesReferencingResponsereference == nil {
		err = errors.New("RevIncluded paymentNotices not requested")
	} else {
		paymentNotices = *d.RevIncludedPaymentNoticeResourcesReferencingResponsereference
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedImplementationGuideResourcesReferencingResource() (implementationGuides []ImplementationGuide, err error) {
	if d.RevIncludedImplementationGuideResourcesReferencingResource == nil {
		err = errors.New("RevIncluded implementationGuides not requested")
	} else {
		implementationGuides = *d.RevIncludedImplementationGuideResourcesReferencingResource
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDeviceComponentResourcesReferencingParent() (deviceComponents []DeviceComponent, err error) {
	if d.RevIncludedDeviceComponentResourcesReferencingParent == nil {
		err = errors.New("RevIncluded deviceComponents not requested")
	} else {
		deviceComponents = *d.RevIncludedDeviceComponentResourcesReferencingParent
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedCommunicationResourcesReferencingBasedon() (communications []Communication, err error) {
	if d.RevIncludedCommunicationResourcesReferencingBasedon == nil {
		err = errors.New("RevIncluded communications not requested")
	} else {
		communications = *d.RevIncludedCommunicationResourcesReferencingBasedon
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedMessageHeaderResourcesReferencingData() (messageHeaders []MessageHeader, err error) {
	if d.RevIncludedMessageHeaderResourcesReferencingData == nil {
		err = errors.New("RevIncluded messageHeaders not requested")
	} else {
		messageHeaders = *d.RevIncludedMessageHeaderResourcesReferencingData
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedProvenanceResourcesReferencingTarget() (provenances []Provenance, err error) {
	if d.RevIncludedProvenanceResourcesReferencingTarget == nil {
		err = errors.New("RevIncluded provenances not requested")
	} else {
		provenances = *d.RevIncludedProvenanceResourcesReferencingTarget
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedTaskResourcesReferencingFocus() (tasks []Task, err error) {
	if d.RevIncludedTaskResourcesReferencingFocus == nil {
		err = errors.New("RevIncluded tasks not requested")
	} else {
		tasks = *d.RevIncludedTaskResourcesReferencingFocus
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedListResourcesReferencingItem() (lists []List, err error) {
	if d.RevIncludedListResourcesReferencingItem == nil {
		err = errors.New("RevIncluded lists not requested")
	} else {
		lists = *d.RevIncludedListResourcesReferencingItem
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDiagnosticRequestResourcesReferencingReplaces() (diagnosticRequests []DiagnosticRequest, err error) {
	if d.RevIncludedDiagnosticRequestResourcesReferencingReplaces == nil {
		err = errors.New("RevIncluded diagnosticRequests not requested")
	} else {
		diagnosticRequests = *d.RevIncludedDiagnosticRequestResourcesReferencingReplaces
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDiagnosticRequestResourcesReferencingBasedon() (diagnosticRequests []DiagnosticRequest, err error) {
	if d.RevIncludedDiagnosticRequestResourcesReferencingBasedon == nil {
		err = errors.New("RevIncluded diagnosticRequests not requested")
	} else {
		diagnosticRequests = *d.RevIncludedDiagnosticRequestResourcesReferencingBasedon
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDiagnosticRequestResourcesReferencingDefinition() (diagnosticRequests []DiagnosticRequest, err error) {
	if d.RevIncludedDiagnosticRequestResourcesReferencingDefinition == nil {
		err = errors.New("RevIncluded diagnosticRequests not requested")
	} else {
		diagnosticRequests = *d.RevIncludedDiagnosticRequestResourcesReferencingDefinition
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDeviceUseRequestResourcesReferencingReplaces() (deviceUseRequests []DeviceUseRequest, err error) {
	if d.RevIncludedDeviceUseRequestResourcesReferencingReplaces == nil {
		err = errors.New("RevIncluded deviceUseRequests not requested")
	} else {
		deviceUseRequests = *d.RevIncludedDeviceUseRequestResourcesReferencingReplaces
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDeviceUseRequestResourcesReferencingBasedon() (deviceUseRequests []DeviceUseRequest, err error) {
	if d.RevIncludedDeviceUseRequestResourcesReferencingBasedon == nil {
		err = errors.New("RevIncluded deviceUseRequests not requested")
	} else {
		deviceUseRequests = *d.RevIncludedDeviceUseRequestResourcesReferencingBasedon
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDeviceUseRequestResourcesReferencingDefinition() (deviceUseRequests []DeviceUseRequest, err error) {
	if d.RevIncludedDeviceUseRequestResourcesReferencingDefinition == nil {
		err = errors.New("RevIncluded deviceUseRequests not requested")
	} else {
		deviceUseRequests = *d.RevIncludedDeviceUseRequestResourcesReferencingDefinition
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDeviceMetricResourcesReferencingParent() (deviceMetrics []DeviceMetric, err error) {
	if d.RevIncludedDeviceMetricResourcesReferencingParent == nil {
		err = errors.New("RevIncluded deviceMetrics not requested")
	} else {
		deviceMetrics = *d.RevIncludedDeviceMetricResourcesReferencingParent
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedBasicResourcesReferencingSubject() (basics []Basic, err error) {
	if d.RevIncludedBasicResourcesReferencingSubject == nil {
		err = errors.New("RevIncluded basics not requested")
	} else {
		basics = *d.RevIncludedBasicResourcesReferencingSubject
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedAuditEventResourcesReferencingEntity() (auditEvents []AuditEvent, err error) {
	if d.RevIncludedAuditEventResourcesReferencingEntity == nil {
		err = errors.New("RevIncluded auditEvents not requested")
	} else {
		auditEvents = *d.RevIncludedAuditEventResourcesReferencingEntity
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedCompositionResourcesReferencingSubject() (compositions []Composition, err error) {
	if d.RevIncludedCompositionResourcesReferencingSubject == nil {
		err = errors.New("RevIncluded compositions not requested")
	} else {
		compositions = *d.RevIncludedCompositionResourcesReferencingSubject
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedCompositionResourcesReferencingEntry() (compositions []Composition, err error) {
	if d.RevIncludedCompositionResourcesReferencingEntry == nil {
		err = errors.New("RevIncluded compositions not requested")
	} else {
		compositions = *d.RevIncludedCompositionResourcesReferencingEntry
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedDetectedIssueResourcesReferencingImplicated() (detectedIssues []DetectedIssue, err error) {
	if d.RevIncludedDetectedIssueResourcesReferencingImplicated == nil {
		err = errors.New("RevIncluded detectedIssues not requested")
	} else {
		detectedIssues = *d.RevIncludedDetectedIssueResourcesReferencingImplicated
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedQuestionnaireResponseResourcesReferencingSubject() (questionnaireResponses []QuestionnaireResponse, err error) {
	if d.RevIncludedQuestionnaireResponseResourcesReferencingSubject == nil {
		err = errors.New("RevIncluded questionnaireResponses not requested")
	} else {
		questionnaireResponses = *d.RevIncludedQuestionnaireResponseResourcesReferencingSubject
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedProcessResponseResourcesReferencingRequestreference() (processResponses []ProcessResponse, err error) {
	if d.RevIncludedProcessResponseResourcesReferencingRequestreference == nil {
		err = errors.New("RevIncluded processResponses not requested")
	} else {
		processResponses = *d.RevIncludedProcessResponseResourcesReferencingRequestreference
	}
	return
}

func (d *DeviceComponentPlusRelatedResources) GetIncludedResources() map[string]interface{} {
	resourceMap := make(map[string]interface{})
	if d.IncludedDeviceComponentResourcesReferencedByParent != nil {
		for idx := range *d.IncludedDeviceComponentResourcesReferencedByParent {
			rsc := (*d.IncludedDeviceComponentResourcesReferencedByParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.IncludedDeviceResourcesReferencedBySource != nil {
		for idx := range *d.IncludedDeviceResourcesReferencedBySource {
			rsc := (*d.IncludedDeviceResourcesReferencedBySource)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	return resourceMap
}

func (d *DeviceComponentPlusRelatedResources) GetRevIncludedResources() map[string]interface{} {
	resourceMap := make(map[string]interface{})
	if d.RevIncludedDocumentManifestResourcesReferencingContentref != nil {
		for idx := range *d.RevIncludedDocumentManifestResourcesReferencingContentref {
			rsc := (*d.RevIncludedDocumentManifestResourcesReferencingContentref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDocumentManifestResourcesReferencingRelatedref != nil {
		for idx := range *d.RevIncludedDocumentManifestResourcesReferencingRelatedref {
			rsc := (*d.RevIncludedDocumentManifestResourcesReferencingRelatedref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedConsentResourcesReferencingData != nil {
		for idx := range *d.RevIncludedConsentResourcesReferencingData {
			rsc := (*d.RevIncludedConsentResourcesReferencingData)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDocumentReferenceResourcesReferencingRelatedref != nil {
		for idx := range *d.RevIncludedDocumentReferenceResourcesReferencingRelatedref {
			rsc := (*d.RevIncludedDocumentReferenceResourcesReferencingRelatedref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingTtopic != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingTtopic {
			rsc := (*d.RevIncludedContractResourcesReferencingTtopic)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingSubject {
			rsc := (*d.RevIncludedContractResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingTopic != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingTopic {
			rsc := (*d.RevIncludedContractResourcesReferencingTopic)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedPaymentNoticeResourcesReferencingRequestreference != nil {
		for idx := range *d.RevIncludedPaymentNoticeResourcesReferencingRequestreference {
			rsc := (*d.RevIncludedPaymentNoticeResourcesReferencingRequestreference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedPaymentNoticeResourcesReferencingResponsereference != nil {
		for idx := range *d.RevIncludedPaymentNoticeResourcesReferencingResponsereference {
			rsc := (*d.RevIncludedPaymentNoticeResourcesReferencingResponsereference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedImplementationGuideResourcesReferencingResource != nil {
		for idx := range *d.RevIncludedImplementationGuideResourcesReferencingResource {
			rsc := (*d.RevIncludedImplementationGuideResourcesReferencingResource)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceComponentResourcesReferencingParent != nil {
		for idx := range *d.RevIncludedDeviceComponentResourcesReferencingParent {
			rsc := (*d.RevIncludedDeviceComponentResourcesReferencingParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCommunicationResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedCommunicationResourcesReferencingBasedon {
			rsc := (*d.RevIncludedCommunicationResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedMessageHeaderResourcesReferencingData != nil {
		for idx := range *d.RevIncludedMessageHeaderResourcesReferencingData {
			rsc := (*d.RevIncludedMessageHeaderResourcesReferencingData)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedProvenanceResourcesReferencingTarget != nil {
		for idx := range *d.RevIncludedProvenanceResourcesReferencingTarget {
			rsc := (*d.RevIncludedProvenanceResourcesReferencingTarget)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedTaskResourcesReferencingFocus != nil {
		for idx := range *d.RevIncludedTaskResourcesReferencingFocus {
			rsc := (*d.RevIncludedTaskResourcesReferencingFocus)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedListResourcesReferencingItem != nil {
		for idx := range *d.RevIncludedListResourcesReferencingItem {
			rsc := (*d.RevIncludedListResourcesReferencingItem)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingReplaces != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingReplaces {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingReplaces)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingBasedon {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingDefinition != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingDefinition {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingDefinition)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingReplaces != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingReplaces {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingReplaces)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingBasedon {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingDefinition != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingDefinition {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingDefinition)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceMetricResourcesReferencingParent != nil {
		for idx := range *d.RevIncludedDeviceMetricResourcesReferencingParent {
			rsc := (*d.RevIncludedDeviceMetricResourcesReferencingParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedBasicResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedBasicResourcesReferencingSubject {
			rsc := (*d.RevIncludedBasicResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedAuditEventResourcesReferencingEntity != nil {
		for idx := range *d.RevIncludedAuditEventResourcesReferencingEntity {
			rsc := (*d.RevIncludedAuditEventResourcesReferencingEntity)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCompositionResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedCompositionResourcesReferencingSubject {
			rsc := (*d.RevIncludedCompositionResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCompositionResourcesReferencingEntry != nil {
		for idx := range *d.RevIncludedCompositionResourcesReferencingEntry {
			rsc := (*d.RevIncludedCompositionResourcesReferencingEntry)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDetectedIssueResourcesReferencingImplicated != nil {
		for idx := range *d.RevIncludedDetectedIssueResourcesReferencingImplicated {
			rsc := (*d.RevIncludedDetectedIssueResourcesReferencingImplicated)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedQuestionnaireResponseResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedQuestionnaireResponseResourcesReferencingSubject {
			rsc := (*d.RevIncludedQuestionnaireResponseResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedProcessResponseResourcesReferencingRequestreference != nil {
		for idx := range *d.RevIncludedProcessResponseResourcesReferencingRequestreference {
			rsc := (*d.RevIncludedProcessResponseResourcesReferencingRequestreference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	return resourceMap
}

func (d *DeviceComponentPlusRelatedResources) GetIncludedAndRevIncludedResources() map[string]interface{} {
	resourceMap := make(map[string]interface{})
	if d.IncludedDeviceComponentResourcesReferencedByParent != nil {
		for idx := range *d.IncludedDeviceComponentResourcesReferencedByParent {
			rsc := (*d.IncludedDeviceComponentResourcesReferencedByParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.IncludedDeviceResourcesReferencedBySource != nil {
		for idx := range *d.IncludedDeviceResourcesReferencedBySource {
			rsc := (*d.IncludedDeviceResourcesReferencedBySource)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDocumentManifestResourcesReferencingContentref != nil {
		for idx := range *d.RevIncludedDocumentManifestResourcesReferencingContentref {
			rsc := (*d.RevIncludedDocumentManifestResourcesReferencingContentref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDocumentManifestResourcesReferencingRelatedref != nil {
		for idx := range *d.RevIncludedDocumentManifestResourcesReferencingRelatedref {
			rsc := (*d.RevIncludedDocumentManifestResourcesReferencingRelatedref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedConsentResourcesReferencingData != nil {
		for idx := range *d.RevIncludedConsentResourcesReferencingData {
			rsc := (*d.RevIncludedConsentResourcesReferencingData)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDocumentReferenceResourcesReferencingRelatedref != nil {
		for idx := range *d.RevIncludedDocumentReferenceResourcesReferencingRelatedref {
			rsc := (*d.RevIncludedDocumentReferenceResourcesReferencingRelatedref)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingTtopic != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingTtopic {
			rsc := (*d.RevIncludedContractResourcesReferencingTtopic)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingSubject {
			rsc := (*d.RevIncludedContractResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedContractResourcesReferencingTopic != nil {
		for idx := range *d.RevIncludedContractResourcesReferencingTopic {
			rsc := (*d.RevIncludedContractResourcesReferencingTopic)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedPaymentNoticeResourcesReferencingRequestreference != nil {
		for idx := range *d.RevIncludedPaymentNoticeResourcesReferencingRequestreference {
			rsc := (*d.RevIncludedPaymentNoticeResourcesReferencingRequestreference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedPaymentNoticeResourcesReferencingResponsereference != nil {
		for idx := range *d.RevIncludedPaymentNoticeResourcesReferencingResponsereference {
			rsc := (*d.RevIncludedPaymentNoticeResourcesReferencingResponsereference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedImplementationGuideResourcesReferencingResource != nil {
		for idx := range *d.RevIncludedImplementationGuideResourcesReferencingResource {
			rsc := (*d.RevIncludedImplementationGuideResourcesReferencingResource)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceComponentResourcesReferencingParent != nil {
		for idx := range *d.RevIncludedDeviceComponentResourcesReferencingParent {
			rsc := (*d.RevIncludedDeviceComponentResourcesReferencingParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCommunicationResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedCommunicationResourcesReferencingBasedon {
			rsc := (*d.RevIncludedCommunicationResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedMessageHeaderResourcesReferencingData != nil {
		for idx := range *d.RevIncludedMessageHeaderResourcesReferencingData {
			rsc := (*d.RevIncludedMessageHeaderResourcesReferencingData)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedProvenanceResourcesReferencingTarget != nil {
		for idx := range *d.RevIncludedProvenanceResourcesReferencingTarget {
			rsc := (*d.RevIncludedProvenanceResourcesReferencingTarget)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedTaskResourcesReferencingFocus != nil {
		for idx := range *d.RevIncludedTaskResourcesReferencingFocus {
			rsc := (*d.RevIncludedTaskResourcesReferencingFocus)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedListResourcesReferencingItem != nil {
		for idx := range *d.RevIncludedListResourcesReferencingItem {
			rsc := (*d.RevIncludedListResourcesReferencingItem)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingReplaces != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingReplaces {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingReplaces)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingBasedon {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDiagnosticRequestResourcesReferencingDefinition != nil {
		for idx := range *d.RevIncludedDiagnosticRequestResourcesReferencingDefinition {
			rsc := (*d.RevIncludedDiagnosticRequestResourcesReferencingDefinition)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingReplaces != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingReplaces {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingReplaces)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingBasedon != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingBasedon {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingBasedon)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceUseRequestResourcesReferencingDefinition != nil {
		for idx := range *d.RevIncludedDeviceUseRequestResourcesReferencingDefinition {
			rsc := (*d.RevIncludedDeviceUseRequestResourcesReferencingDefinition)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDeviceMetricResourcesReferencingParent != nil {
		for idx := range *d.RevIncludedDeviceMetricResourcesReferencingParent {
			rsc := (*d.RevIncludedDeviceMetricResourcesReferencingParent)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedBasicResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedBasicResourcesReferencingSubject {
			rsc := (*d.RevIncludedBasicResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedAuditEventResourcesReferencingEntity != nil {
		for idx := range *d.RevIncludedAuditEventResourcesReferencingEntity {
			rsc := (*d.RevIncludedAuditEventResourcesReferencingEntity)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCompositionResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedCompositionResourcesReferencingSubject {
			rsc := (*d.RevIncludedCompositionResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedCompositionResourcesReferencingEntry != nil {
		for idx := range *d.RevIncludedCompositionResourcesReferencingEntry {
			rsc := (*d.RevIncludedCompositionResourcesReferencingEntry)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedDetectedIssueResourcesReferencingImplicated != nil {
		for idx := range *d.RevIncludedDetectedIssueResourcesReferencingImplicated {
			rsc := (*d.RevIncludedDetectedIssueResourcesReferencingImplicated)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedQuestionnaireResponseResourcesReferencingSubject != nil {
		for idx := range *d.RevIncludedQuestionnaireResponseResourcesReferencingSubject {
			rsc := (*d.RevIncludedQuestionnaireResponseResourcesReferencingSubject)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	if d.RevIncludedProcessResponseResourcesReferencingRequestreference != nil {
		for idx := range *d.RevIncludedProcessResponseResourcesReferencingRequestreference {
			rsc := (*d.RevIncludedProcessResponseResourcesReferencingRequestreference)[idx]
			resourceMap[rsc.Id] = &rsc
		}
	}
	return resourceMap
}


text:
FROM phusion/baseimage

ENV HOME /root

# set locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Install Java 1.7
RUN \
	echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
	echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections && \
	sudo apt-get update -qq && \
	sudo apt-get install -y software-properties-common -qq && \
	sudo add-apt-repository ppa:webupd8team/java && \
	sudo apt-get update -qq && \
	sudo apt-get install -y oracle-java7-installer libjansi-java -qq

# for run
CMD ["/sbin/my_init"]

redpajama_set_name: RedPajamaGithub


text:
goto="Streamlink.Init" /*
::     url input + stream choice dialogs and hidecmd launcher v9
:: Save as Streamlink.bat in Streamlink folder, can be called using [Win+R] Run-menu after first launch
:: streamlink                             = with no arguments shows url input-dialog
:: streamlink dreamleague                 = with just the url or twitch channel name shows stream choice-dialog
:: streamlink twitch.tv/dreamleague 720p  = with both url and stream choice launches video player directly
:: streamlink dreamleague+chat            = with +chat added to the url also opens twitch chat in browser tab
:: streamlink --twitch-oauth-authenticate = with any python options shows cmd window and keeps it open
:"Streamlink.Batch"
rem set "TWITCH_OAUTH_TOKEN=--twitch-oauth-token your~optional~twitch-oauth-token~got~from~above~input"
set "CONFIG=--config streamlinkrc %TWITCH_OAUTH_TOKEN%"
set "DEFAULT=--default-stream "720p,480p,best""
set "FFMPEG=--ffmpeg-ffmpeg ffmpeg\ffmpeg.exe"
set "RTMPDUMP=--rtmp-rtmpdump rtmpdump\rtmpdump.exe"
set "PYTHONIOENCODING=cp65001" & chcp 65001 >NUL
set "STREAMLINK=Python\python.exe streamlink-script.py %FFMPEG% %RTMPDUMP% %CONFIG%"
set "URL=%~1"
set "STREAM=%~2"
if not defined URL echo  Input empty, insert url & call :input "STREAMLINK: Insert url" "OK" URL
if not defined URL echo  [X] Input empty & timeout /t 4 & exit/b
if /i "%URL:~0,2%"=="--" echo  Input contains options & call :showcmd cmd /k %STREAMLINK% %DEFAULT% %URL% & exit/b
if "%URL: --=%"=="%URL%" ( echo  %URL% loading, wait.. ) else call :showcmd cmd /k %STREAMLINK% %DEFAULT% %URL% & exit/b
for /f "tokens=1,2,3* delims= " %%U in ("%URL%") do set "INPUT.URL=%%~U" & set "INPUT.STREAM=%%~V" & set "INPUT.NONE=%%~W"
if not defined STREAM if not defined INPUT.NONE if defined INPUT.STREAM set "URL=%INPUT.URL%" & set "STREAM=%INPUT.STREAM%"
if "%URL:/=%"=="%URL%" echo  Input non-url, assume twitch.tv/%URL% & set "URL=http://twitch.tv/%URL%"
if /i "%URL:~-5%"=="+chat" ( set "URL=%URL:~0,-5%" & set "OPEN_CHAT=1" ) else set "OPEN_CHAT="
if defined OPEN_CHAT start %URL%/chat
set "--QUERYONLY--=--player QUERYONLY ^| find.exe /i "Available streams" 2^>nul" & set "LIST="
if not defined STREAM for /f "usebackq tokens=2* delims=:" %%Q in (`%STREAMLINK% "%URL%" %--QUERYONLY--%`) do set "LIST=%%Q"
if defined LIST call set "LIST=%%LIST:(=,%%" &call set "LIST=%%LIST:)=%%" &call set "LIST=%%LIST: =%%"
if defined LIST echo  Available streams: %LIST% & call :choice "%URL%" "%LIST%" STREAM
if defined LIST if not defined STREAM set "STREAMLINK=echo  [X] No choice selected & rem"
%STREAMLINK% --default-stream "%STREAM%,720p,480p,best" "%URL%"
call set "TSTPATH=%%path:%~dp0=%%" & rem add Streamlink directory to current user environment without duplicating entries
if "%TSTPATH%"=="%path%" ( reg add HKEY_CURRENT_USER\Environment /v PATH /t REG_SZ /f /d "%path%;%~dp0;" >nul 2>nul &setx OS %OS% )
exit/b
::----------------------------------------------------------------------------------------------------------------------------------
:"Streamlink.Utils"
:input %1:title %2:button %3:output_variable                                      ||:example: call :input "Enter stream" "OK" result
setlocal & call :_header "%~1" input
set "input=%input%
<input class='button edit' name='in' type='text'><button id='ok' class='button ok'>%~2</button>
"
for /f "usebackq tokens=* delims=" %%# in (`mshta "%input%"`) do set "input_var=%%#"
endlocal & call set "%~3=%input_var%" & exit /b
:choice %1:title %2:options %3:output_variable                                  ||:example: call :choice Choose "op1,op2,op3" result
setlocal & call :_header "%~1" choice
set "choice=%choice%
<input type='hidden' name='options' value='%~2'>"
for /f "usebackq tokens=* delims=" %%# in (`mshta "%choice%"`) do set "choice_var=%%#"
endlocal & call set "%~3=%choice_var%" & exit /b
:_header %1:title %2:type["input" or "choice"]                                    ||:i used internally by input and choice functions
setlocal & set "h=about:<title>%~1</title><hta:application innerborder='no' sysmenu='yes' scroll='no'>"
set "h=%h% "
endlocal & set "%~2=%h%" & exit /b
:hidecmd %*:arguments
setlocal & set "--arguments--=%*" & wscript //nologo /E:JScript "%~f0" RunCMD --arguments-- 0 & endlocal & exit/b
:showcmd %*:arguments
setlocal & set "--arguments--=%*" & wscript //nologo /E:JScript "%~f0" RunCMD --arguments-- 1 & endlocal & exit/b
::----------------------------------------------------------------------------------------------------------------------------------
:"Streamlink.Init" Hybrid initialization with HideCmd and arguments pass-trough after self-restart
@echo off & pushd "%~dp0" & if "%1"=="--self--restart--" call :"Streamlink.Batch" "%--init--%" & exit/b
set "--init--=%*" & call :hidecmd "%~f0" --self--restart-- & exit/b
::----------------------------------------------------------------------------------------------------------------------------------
:"Streamlink.JScript" */
function input(){
  window.onerror = function(){ close(); }; var input = document.getElementById('in'), ok = document.getElementById('ok');
  window.moveTo(parseInt(window.parent.screen.availWidth/3),parseInt(window.parent.screen.availHeight/6));window.resizeTo(512,128);
  ok.onclick = function() { close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(input.value)); };
}
function choice(){
  window.onerror = function(){ close(); }; var opt=document.getElementById('options').value.split(','), wh=(opt.length+1)*64;
  window.moveTo(parseInt(window.parent.screen.availWidth/3),parseInt(window.parent.screen.availHeight/6));window.resizeTo(512,512);
	var buttons = document.getElementById('buttons'); for (o in opt) {
    var i = document.createElement('button'); i.setAttribute('className', 'button'); i.className='button';
    i.onclick = function() { close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(this.value)); };
    i.appendChild(document.createTextNode(opt[o])); buttons.appendChild(i); buttons.appendChild(document.createElement('br'));
  }
}
function RunCMD(arguments, show) { WScript.CreateObject('WScript.Shell').Run('%'+ arguments +'%', show, 'False'); }
if (typeof window != 'object' && WScript.Arguments(0)=='RunCMD') RunCMD(WScript.Arguments(1), WScript.Arguments(2));
// end of hybrid batch script by AveYo


text:
using Cofoundry.Core.Data;

namespace Cofoundry.Domain.Extendable;

public interface IExtendableDomainRepositoryTransactionManager : IDomainRepositoryTransactionManager
{
    /// <summary>
    /// TransactionScopeManager instance only to be used for
    /// extending the transaction manager with extension methods
    /// </summary>
    ITransactionScopeManager TransactionScopeManager { get; }

    /// <summary>
    /// DbContext that can be used to apply TransactionScopeManager
    /// method to. This is only to be used for extending the transaction
    /// manager with extension methods
    /// </summary>
    DbContext DbContext { get; }
}


text:
package mil.nga.giat.geowave.types.gpx;

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

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import mil.nga.giat.geowave.accumulo.util.AccumuloUtils;
import mil.nga.giat.geowave.index.ByteArrayId;
import mil.nga.giat.geowave.index.StringUtils;
import mil.nga.giat.geowave.ingest.GeoWaveData;
import mil.nga.giat.geowave.store.CloseableIterator;
import mil.nga.giat.geowave.types.HelperClass;
import mil.nga.giat.geowave.types.ValidateObject;

import org.junit.Before;
import org.junit.Test;
import org.opengis.feature.simple.SimpleFeature;

public class GPXIngestPluginTest
{

	Map<String, ValidateObject<SimpleFeature>> expectedResults = new HashMap<String, ValidateObject<SimpleFeature>>();

	@Before
	public void setup() {

		expectedResults.put(
				"12345_1_Example_gpx",
				new ValidateObject<SimpleFeature>() {
					@Override
					public boolean validate(
							SimpleFeature feature ) {
						return feature.getAttribute(
								"Tags").toString().equals(
								"tag1 ||| tag2") && feature.getAttribute(
								"User").toString().equals(
								"Foo") && feature.getAttribute(
								"UserId").toString().equals(
								"12345") && feature.getAttribute(
								"TrackId").toString().equals(
								"12345") && feature.getAttribute(
								"NumberPoints").toString().equals(
								"7") && feature.getAttribute(
								"Duration").toString().equals(
								"251000") && feature.getAttribute("EndTimeStamp") != null && feature.getAttribute("StartTimeStamp") != null;
					}
				});
	}

	@Test
	public void test()
			throws IOException {
		Set<String> expectedSet = HelperClass.buildSet(expectedResults);

		GpxIngestPlugin pluggin = new GpxIngestPlugin();
		pluggin.init(new File(
				this.getClass().getClassLoader().getResource(
						"metadata.xml").getPath()).getParentFile());

		CloseableIterator<GeoWaveData<SimpleFeature>> consumer = pluggin.toGeoWaveData(
				new File(
						this.getClass().getClassLoader().getResource(
								"12345.xml").getPath()),
				new ByteArrayId(
						"123".getBytes(StringUtils.UTF8_CHAR_SET)),
				"");

		int totalCount = 0;
		while (consumer.hasNext()) {
			GeoWaveData<SimpleFeature> data = consumer.next();
			expectedSet.remove(data.getValue().getID());
			ValidateObject<SimpleFeature> tester = expectedResults.get(data.getValue().getID());
			if (tester != null) {
				assertTrue(
						data.getValue().toString(),
						tester.validate(data.getValue()));
			}
			totalCount++;
		}
		consumer.close();
		assertEquals(
				9,
				totalCount);
		// did everything get validated?
		if (expectedSet.size() > 0) {
			System.out.println("Failed matches:");
			System.out.println(expectedSet);
		}
		assertEquals(
				"All expected data set should be matched; zero unmatched data expected",
				0,
				expectedSet.size());
	}

}


text:
Partial Class _404
    Inherits System.Web.UI.Page

End Class


text:
/*
 Theme Name:   Zerif Lite Child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:
 Author:       John Doe
 Author URI:   http://example.com
 Template:     zerif-lite
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  zerif-lite-child
*/

/*basic color: #800080
hover color: #9A029A
Call To action:#51AD53
C2A Hover: 60D463
*/

/*Global Styles*/

a{
	color:#800080;
}

a:visited{
	color:#800080;
}

a:hover{
	color:#9A029A;
}

.social li a:hover{
	color:#9A029A;
}

.company-details a:hover{
	color:#9A029A;

}

.container{
	font-family: 'Raleway', sans-serif;
}

.intro-text {
	font-family: 'Corben', cursive;
}

button{
	background:#51AD53;
	border-color:#51AD53;
}

/*Homepage*/
.dark-text {
    color: #000;
    font-family: 'Corben', cursive;
}

.white-text{
   font-family: 'Corben', cursive;
}

.testimonial{
	background:#800080;
}

.navbar-toggle.active{
	background-color:#9A029A!important;
}

.navbar-toggle.collapsed{
	background-color:#800080!important;
}

.btn-primary {
	background:#800080;
	border-color:#4E4E4E;
}

.btn-primary:hover {
	background:#9A029A;
	border-color:#4E4E4E;
}

.btn-primary:active {
	background:#800080;
	border-color:#4E4E4E;
}

.btn-primary:focus {
	background:#800080;
	border-color:#4E4E4E;
}

.focus-box:nth-child(4n+1) .red-border-bottom:before,
.focus-box:nth-child(4n+2) .red-border-bottom:before,
.focus-box:nth-child(4n+3) .red-border-bottom:before,
.focus-box:nth-child(4n+4) .red-border-bottom:before {
    background: #800080;
}

.focus-box:nth-child(4n+1) .service-icon:hover,
.focus-box:nth-child(4n+2) .service-icon:hover,
.focus-box:nth-child(4n+3) .service-icon:hover,
.focus-box:nth-child(4n+4) .service-icon:hover {
	border: 10px solid #800080;
}

.navbar-inverse{
	background:#FFF;
}

.navbar-inverse .navbar-nav>li>a{
	color:#800080;
}

.navbar-inverse .navbar-nav>li>a:hover, .navbar-inverse .navbar-nav>li>a:focus{
	color:#9A029A;
}

#carousel-homepage-latestnews .item .latestnews-box:nth-child(4n+1) .latestnews-title a:before,
#carousel-homepage-latestnews .item .latestnews-box:nth-child(4n+2) .latestnews-title a:before,
#carousel-homepage-latestnews .item .latestnews-box:nth-child(4n+3) .latestnews-title a:before,
#carousel-homepage-latestnews .item .latestnews-box:nth-child(4n+4) .latestnews-title a:before{
    background: #800080;
}

.company-details .zerif-footer-address a:visited{
	color:#939393;
}

.navbar-brand > img{
	max-height:200%;
}

.navbar-brand{
	padding:none;
}

/*Pirate Forms*/
.pirate_forms .pirate-forms-submit-button:hover{
	background-color:#60D463;
}

/*Pages*/
.entry-title:before{
	background:#800080;
}

.entry-title:after{
	background:#800080;
}

.btn-primary a{
	color:#FFF;
}

.btn-primary a:hover{
	color:#FFF;
	text-decoration:none;
}

/*WooCommerce*/
.woocommerce-page .products a.button{
	background:#60D463;
}

.woocommerce-page .products a.button:hover{
	background:#51AD53;
}

ul.nav > li.current_page_item > a:before, ul.nav > li.current-menu-item > a:before{
	background:#800080;
}

.woocommerce-page .page-title:before{
	background:#800080;
}

.woocommerce-page .products .added_to_cart{
	color:#9A029A;
}

.woocommerce-page .products .added_to_cart:hover{
	text-decoration: underline;
}

.woocommerce-page .woocommerce a.remove{
	color:#800080!important;
}

.woocommerce-page .woocommerce a.remove:hover{
	background:#9A029A;
}

.woocommerce-page .woocommerce input[type="submit"], .woocommerce-page #content input.button, .woocommerce input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce-page input.button.alt{
	background:#800080;
}

.woocommerce-page .woocommerce input[type="submit"]:hover, .woocommerce-page #content input.button:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page input.button.alt:hover{
	background:#9A029A;
}

.woocommerce a.button.alt{
	background:#51AD53;
}

.woocommerce a.button.alt:hover{
	background:#60D463;
}

.woocommerce-page .woocommerce .woocommerce-message,
.woocommerce-page .woocommerce .woocommerce-error,
.woocommerce-page .woocommerce .woocommerce-info{
	background:#9A029A;
}

.woocommerce-page .woocommerce-message a{
	background:#9A029A;
	text-decoration:underline;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li.active{
	border-color:#800080;
}

.woocommerce-page .woocommerce .add_to_cart_button, .woocommerce .checkout-button, .woocommerce .single_add_to_cart_button, .woocommerce #place_order, .woocommerce div.product form.cart .button{
	background:#51AD53;
}

.woocommerce-page .woocommerce .add_to_cart_button:hover, .woocommerce .checkout-button:hover, .woocommerce .single_add_to_cart_button :hover, .woocommerce #place_order:hover, .woocommerce div.product form.cart .button:hover{
	background:#60D463;
}

.woocommerce #review_form #respond .form-submit input{
	background:#800080;

}

.woocommerce #review_form #respond .form-submit input:hover{
	background:#9A029A;
}

.woocommerce-page .woocommerce-message{
	background:#51AD53;
}

.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button{
	background:#60D463;
}

.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover{
	background:#51AD53;
}

.woocommerce-page .woocommerce-info a{
	background-color:#9A029A;
}

.myaccount_user a{
	text-decoration:underline;
}

.woocommerce #payment #place_order, .woocommerce-page #payment #place_order{
	background:#60D463;
}


text:
/**
 * wp.media.controller.SiteIconCropper
 *
 * A state for cropping a Site Icon.
 *
 * @class
 * @augments wp.media.controller.Cropper
 * @augments wp.media.controller.State
 * @augments Backbone.Model
 */
var Controller = wp.media.controller,
	SiteIconCropper;

SiteIconCropper = Controller.Cropper.extend({
	activate: function() {
		this.frame.on( 'content:create:crop', this.createCropContent, this );
		this.frame.on( 'close', this.removeCropper, this );
		this.set('selection', new Backbone.Collection(this.frame._selection.single));
	},

	createCropContent: function() {
		this.cropperView = new wp.media.view.SiteIconCropper({
			controller: this,
			attachment: this.get('selection').first()
		});
		this.cropperView.on('image-loaded', this.createCropToolbar, this);
		this.frame.content.set(this.cropperView);

	},

	doCrop: function( attachment ) {
		var cropDetails = attachment.get( 'cropDetails' ),
			control = this.get( 'control' );

		cropDetails.dst_width  = control.params.width;
		cropDetails.dst_height = control.params.height;

		return wp.ajax.post( 'crop-image', {
			nonce: attachment.get( 'nonces' ).edit,
			id: attachment.get( 'id' ),
			context: 'site-icon',
			cropDetails: cropDetails
		} );
	}
});

module.exports = SiteIconCropper;


text:
package serde

type Serializer interface {
	SerializeStr(value string) error

	SerializeBytes(value []byte) error

	SerializeBool(value bool) error

	SerializeUnit(value struct{}) error

	SerializeChar(value rune) error

	SerializeF32(value float32) error

	SerializeF64(value float64) error

	SerializeU8(value uint8) error

	SerializeU16(value uint16) error

	SerializeU32(value uint32) error

	SerializeU64(value uint64) error

	SerializeU128(value Uint128) error

	SerializeI8(value int8) error

	SerializeI16(value int16) error

	SerializeI32(value int32) error

	SerializeI64(value int64) error

	SerializeI128(value Int128) error

	SerializeLen(value uint64) error

	SerializeVariantIndex(value uint32) error

	SerializeOptionTag(value bool) error

	GetBufferOffset() uint64

	SortMapEntries(offsets []uint64)

	GetBytes() []byte

	IncreaseContainerDepth() error

	DecreaseContainerDepth()
}

type Deserializer interface {
	DeserializeStr() (string, error)

	DeserializeBytes() ([]byte, error)

	DeserializeBool() (bool, error)

	DeserializeUnit() (struct{}, error)

	DeserializeChar() (rune, error)

	DeserializeF32() (float32, error)

	DeserializeF64() (float64, error)

	DeserializeU8() (uint8, error)

	DeserializeU16() (uint16, error)

	DeserializeU32() (uint32, error)

	DeserializeU64() (uint64, error)

	DeserializeU128() (Uint128, error)

	DeserializeI8() (int8, error)

	DeserializeI16() (int16, error)

	DeserializeI32() (int32, error)

	DeserializeI64() (int64, error)

	DeserializeI128() (Int128, error)

	DeserializeLen() (uint64, error)

	DeserializeVariantIndex() (uint32, error)

	DeserializeOptionTag() (bool, error)

	GetBufferOffset() uint64

	CheckThatKeySlicesAreIncreasing(key1, key2 Slice) error

	IncreaseContainerDepth() error

	DecreaseContainerDepth()
}

type Slice struct {
	Start uint64
	End   uint64
}


text:
from battlenet.community import Community

class Auctions(Community):

    ENDPOINT = '/wow/auction/data/%s'

    def __init__(self, *args, **kwargs):
        super(Auctions, self).__init__(*args, **kwargs)
        self.realm = kwargs.get('realm', None)

    def get(self, realm=None):
        if realm:
            self.realm = realm
        else:
            if not self.realm:
                raise ValueError('Realm name required.')

        return self.make_request(self.ENDPOINT % self.realm)


text:
describe "PM::Table module" do

  def cell_factory(args={})
    { title: "Basic", action: :basic_cell_tapped, arguments: { id: 1 } }.merge!(args)
  end

  def custom_cell
    @image = UIImage.imageNamed("list")
    cell_factory({
      title: "Crazy Full Featured Cell",
      subtitle: "This is way too huge..see note",
      arguments: { data: [ "lots", "of", "data" ] },
      action: :tapped_cell_1,
      height: 50, # manually changes the cell's height
      cell_style: UITableViewCellStyleSubtitle,
      cell_identifier: "Cell",
      cell_class: PM::TableViewCell,
      masks_to_bounds: true,
      background_color: UIColor.colorWithPatternImage(@image),
      selection_style: UITableViewCellSelectionStyleGray,
      accessory: {
        view: :switch, # currently only :switch is supported
        type: UITableViewCellAccessoryCheckmark,
        checked: true # whether it's "checked" or not
      },
      image: { image: @image, radius: 15 },
      remote_image: {  # remote image, requires JMImageCache CocoaPod
        url: "http://placekitten.com/200/300", placeholder: "some-local-image",
        size: 50, radius: 15
      },
      subviews: [ @some_view, @some_other_view ] # arbitrary views added to the cell
    })
  end

  before do
    @subject = TestTableScreen.new
    @subject.mock! :table_data do
      [{
        title: "Table cell group 1", cells: [ ]
      },{
        title: "Table cell group 2", cells: [ cell_factory ]
      },{
        title: "Table cell group 3", cells: [ cell_factory(title: "3-1"), cell_factory(title: "3-2", background_color: UIColor.blueColor) ]
      },{
        title: "Table cell group 4", cells: [ custom_cell, cell_factory(title: "4-2"), cell_factory(title: "4-3"), cell_factory(title: "4-4") ]
      },{
        title: "Custom section title 1", title_view: CustomTitleView, cells: [ ]
      },{
        title: "Custom section title 2", title_view: CustomTitleView.new, title_view_height: 50, cells: [ ]
      }]
    end

    @subject.on_load

    @ip = NSIndexPath.indexPathForRow(1, inSection: 2) # Cell 3-2
    @custom_ip = NSIndexPath.indexPathForRow(0, inSection: 3) # Cell "Crazy Full Featured Cell"

    @subject.update_table_data
  end

  it "should have the right number of sections" do
    @subject.numberOfSectionsInTableView(@subject.table_view).should == 6
  end

  it "should set the section titles" do
    @subject.tableView(@subject.table_view, titleForHeaderInSection:0).should == "Table cell group 1"
    @subject.tableView(@subject.table_view, titleForHeaderInSection:1).should == "Table cell group 2"
    @subject.tableView(@subject.table_view, titleForHeaderInSection:2).should == "Table cell group 3"
    @subject.tableView(@subject.table_view, titleForHeaderInSection:3).should == "Table cell group 4"
    @subject.tableView(@subject.table_view, titleForHeaderInSection:4).should == "Custom section title 1"
    @subject.tableView(@subject.table_view, titleForHeaderInSection:5).should == "Custom section title 2"
  end

  it "should create the right number of cells" do
    @subject.tableView(@subject.table_view, numberOfRowsInSection:0).should == 0
    @subject.tableView(@subject.table_view, numberOfRowsInSection:1).should == 1
    @subject.tableView(@subject.table_view, numberOfRowsInSection:2).should == 2
    @subject.tableView(@subject.table_view, numberOfRowsInSection:3).should == 4
    @subject.tableView(@subject.table_view, numberOfRowsInSection:4).should == 0
    @subject.tableView(@subject.table_view, numberOfRowsInSection:5).should == 0
  end

  it "should create the jumplist" do
    @subject.mock! :table_data_index, do
      Array("A".."Z")
    end

    @subject.sectionIndexTitlesForTableView(@subject.table_view).should == Array("A".."Z")
  end

  it "should return the proper cell" do
    cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: @ip)
    cell.should.be.kind_of(UITableViewCell)
    cell.textLabel.text.should == "3-2"
  end

  it "should return the table's cell height if none is given" do
    @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@ip).should == 44.0 # Built-in default
  end

  it "should allow setting a custom cell height" do
    @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@custom_ip).should.be > 0.0
    @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@custom_ip).should == custom_cell[:height].to_f
  end

  it "should trigger the right action on select and pass in the right arguments" do
    @subject.mock! :tapped_cell_1 do |args|
      args[:data].should == [ "lots", "of", "data" ]
    end

    @subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
  end

  it "should set a custom cell background image" do
    @image.should.not.be.nil
    ip = NSIndexPath.indexPathForRow(0, inSection: 3) # Cell 2-1
    cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: ip)
    cell.should.be.kind_of(UITableViewCell)
    cell.backgroundColor.should.be.kind_of(UIColor)
    cell.backgroundColor.should == UIColor.colorWithPatternImage(@image)
  end

  it "should set a custom cell background color" do
    cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: @ip)
    cell.should.be.kind_of(UITableViewCell)
    cell.backgroundColor.should.be.kind_of(UIColor)
    cell.backgroundColor.should == UIColor.blueColor
  end

  describe("section with custom title_view") do

    it "should use the correct class for section view" do
      cell = @subject.tableView(@subject.table_view, viewForHeaderInSection: 4)
      cell.should.be.kind_of(CustomTitleView)
    end

    it "should use the default section height if none is specified" do
      header_height = (UIDevice.currentDevice.systemVersion.to_f >= 7.0) ? 23.0 : 22.0
      @subject.tableView(@subject.table_view, heightForHeaderInSection:4).should == header_height # Built-in default
    end

    it "should use the set title_view_height if one is specified" do
      @subject.tableView(@subject.table_view, heightForHeaderInSection:5).should == 50.0
    end

  end

end


text:
from modules.setup.app import app
from modules import helpers
from flask import render_template, session as login_session

@app.route('/login/')
def login():
    state = helpers.generateState()
    login_session['state'] = state
    return render_template('login.html', STATE=state)


text:
<?php
/**
 * Created by PhpStorm.
 * User: morontt
 * Date: 04.06.16
 * Time: 13:02
 */

namespace MttProjecteuler\Database;

use MttProjecteuler\Model\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;

class UserProvider implements UserProviderInterface
{
    protected $repository;

    public function __construct(Repository $repository)
    {
        $this->repository = $repository;
    }

    /**
     * {@inheritdoc}
     */
    public function loadUserByUsername($username)
    {
        $user = $this->repository->findUserByUsername($username);

        if (!$user) {
            throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
        }

        return $user;
    }

    /**
     * {@inheritdoc}
     */
    public function refreshUser(UserInterface $user)
    {
        if (!$user instanceof User) {
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
        }

        return $this->loadUserByUsername($user->getUsername());
    }

    /**
     * {@inheritdoc}
     */
    public function supportsClass($class)
    {
        return $class === 'MttProjecteuler\Model\User';
    }
}


text:
// Source : https://leetcode.com/problems/binary-tree-tilt
// Author : Dean Shi
// Date   : 2017-04-27

/***************************************************************************************
 *
 * Given a binary tree, return the tilt of the whole tree.
 *
 * The tilt of a tree node is defined as the absolute difference between the sum of all
 * left subtree node values and the sum of all right subtree node values. Null node has
 * tilt 0.
 *
 * The tilt of the whole tree is defined as the sum of all nodes' tilt.
 *
 * Example:
 *
 * Input:
 *          1
 *        /   \
 *       2     3
 * Output: 1
 * Explanation:
 * Tilt of node 2 : 0
 * Tilt of node 3 : 0
 * Tilt of node 1 : |2-3| = 1
 * Tilt of binary tree : 0 + 0 + 1 = 1
 *
 * Note:
 *
 * The sum of node values in any subtree won't exceed the range of 32-bit integer.
 * All the tilt values won't exceed the range of 32-bit integer.
 *
 *
 ***************************************************************************************/

/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var findTilt = function(root) {
    return postorder(root)[1]
};

function postorder(root, tilt = 0) {
    if (!root) return [0, tilt]
    let left, right
    [left, tilt] = postorder(root.left, tilt);
    [right, tilt] = postorder(root.right, tilt);

    tilt += Math.abs(left - right)
    return [left + right + root.val, tilt]
}


text:
import difference from '../difference'
import keys from '../keys'
import get from './get'
import set from './set'

export default function omit (ks, o) {
  return difference(keys(o), ks).reduce((p, k) => set(k, get(k, o), p), {})
}


text:
package stack

import (
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/api/types/filters"
	"github.com/docker/docker/api/types/swarm"
	"github.com/docker/docker/client"
	"golang.org/x/net/context"
)

const (
	labelNamespace = "com.docker.stack.namespace"
)

func GetStackLabels(namespace string, labels map[string]string) map[string]string {
	if labels == nil {
		labels = make(map[string]string)
	}
	labels[labelNamespace] = namespace
	return labels
}

func GetStackFilter(namespace string) filters.Args {
	filter := filters.NewArgs()
	filter.Add("label", labelNamespace+"="+namespace)
	return filter
}

func GetServices(
	ctx context.Context,
	apiclient client.APIClient,
	namespace string,
) ([]swarm.Service, error) {
	return apiclient.ServiceList(
		ctx,
		types.ServiceListOptions{Filters: GetStackFilter(namespace)})
}

func GetNetworks(
	ctx context.Context,
	apiclient client.APIClient,
	namespace string,
) ([]types.NetworkResource, error) {
	return apiclient.NetworkList(
		ctx,
		types.NetworkListOptions{Filters: GetStackFilter(namespace)})
}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.logic.implementation;

import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.logic.fluent.WorkflowRunActionScopeRepetitionsClient;
import com.azure.resourcemanager.logic.fluent.models.WorkflowRunActionRepetitionDefinitionInner;
import com.azure.resourcemanager.logic.models.WorkflowRunActionRepetitionDefinitionCollection;
import reactor.core.publisher.Mono;

/**
 * An instance of this class provides access to all the operations defined in WorkflowRunActionScopeRepetitionsClient.
 */
public final class WorkflowRunActionScopeRepetitionsClientImpl implements WorkflowRunActionScopeRepetitionsClient {
    private final ClientLogger logger = new ClientLogger(WorkflowRunActionScopeRepetitionsClientImpl.class);

    /** The proxy service used to perform REST calls. */
    private final WorkflowRunActionScopeRepetitionsService service;

    /** The service client containing this operation class. */
    private final LogicManagementClientImpl client;

    /**
     * Initializes an instance of WorkflowRunActionScopeRepetitionsClientImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    WorkflowRunActionScopeRepetitionsClientImpl(LogicManagementClientImpl client) {
        this.service =
            RestProxy
                .create(
                    WorkflowRunActionScopeRepetitionsService.class,
                    client.getHttpPipeline(),
                    client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for LogicManagementClientWorkflowRunActionScopeRepetitions to be used by
     * the proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "LogicManagementClien")
    private interface WorkflowRunActionScopeRepetitionsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows"
                + "/{workflowName}/runs/{runName}/actions/{actionName}/scopeRepetitions")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<WorkflowRunActionRepetitionDefinitionCollection>> list(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("workflowName") String workflowName,
            @PathParam("runName") String runName,
            @PathParam("actionName") String actionName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows"
                + "/{workflowName}/runs/{runName}/actions/{actionName}/scopeRepetitions/{repetitionName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<WorkflowRunActionRepetitionDefinitionInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("workflowName") String workflowName,
            @PathParam("runName") String runName,
            @PathParam("actionName") String actionName,
            @PathParam("repetitionName") String repetitionName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<WorkflowRunActionRepetitionDefinitionInner>> listSinglePageAsync(
        String resourceGroupName, String workflowName, String runName, String actionName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (workflowName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workflowName is required and cannot be null."));
        }
        if (runName == null) {
            return Mono.error(new IllegalArgumentException("Parameter runName is required and cannot be null."));
        }
        if (actionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter actionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            workflowName,
                            runName,
                            actionName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<WorkflowRunActionRepetitionDefinitionInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<WorkflowRunActionRepetitionDefinitionInner>> listSinglePageAsync(
        String resourceGroupName, String workflowName, String runName, String actionName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (workflowName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workflowName is required and cannot be null."));
        }
        if (runName == null) {
            return Mono.error(new IllegalArgumentException("Parameter runName is required and cannot be null."));
        }
        if (actionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter actionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                workflowName,
                runName,
                actionName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null));
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<WorkflowRunActionRepetitionDefinitionInner> listAsync(
        String resourceGroupName, String workflowName, String runName, String actionName) {
        return new PagedFlux<>(() -> listSinglePageAsync(resourceGroupName, workflowName, runName, actionName));
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<WorkflowRunActionRepetitionDefinitionInner> listAsync(
        String resourceGroupName, String workflowName, String runName, String actionName, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroupName, workflowName, runName, actionName, context));
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<WorkflowRunActionRepetitionDefinitionInner> list(
        String resourceGroupName, String workflowName, String runName, String actionName) {
        return new PagedIterable<>(listAsync(resourceGroupName, workflowName, runName, actionName));
    }

    /**
     * List the workflow run action scoped repetitions.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a collection of workflow run action repetitions.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<WorkflowRunActionRepetitionDefinitionInner> list(
        String resourceGroupName, String workflowName, String runName, String actionName, Context context) {
        return new PagedIterable<>(listAsync(resourceGroupName, workflowName, runName, actionName, context));
    }

    /**
     * Get a workflow run action scoped repetition.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param repetitionName The workflow repetition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a workflow run action scoped repetition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<WorkflowRunActionRepetitionDefinitionInner>> getWithResponseAsync(
        String resourceGroupName, String workflowName, String runName, String actionName, String repetitionName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (workflowName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workflowName is required and cannot be null."));
        }
        if (runName == null) {
            return Mono.error(new IllegalArgumentException("Parameter runName is required and cannot be null."));
        }
        if (actionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter actionName is required and cannot be null."));
        }
        if (repetitionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter repetitionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            workflowName,
                            runName,
                            actionName,
                            repetitionName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a workflow run action scoped repetition.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param repetitionName The workflow repetition.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a workflow run action scoped repetition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<WorkflowRunActionRepetitionDefinitionInner>> getWithResponseAsync(
        String resourceGroupName,
        String workflowName,
        String runName,
        String actionName,
        String repetitionName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (workflowName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workflowName is required and cannot be null."));
        }
        if (runName == null) {
            return Mono.error(new IllegalArgumentException("Parameter runName is required and cannot be null."));
        }
        if (actionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter actionName is required and cannot be null."));
        }
        if (repetitionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter repetitionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                workflowName,
                runName,
                actionName,
                repetitionName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Get a workflow run action scoped repetition.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param repetitionName The workflow repetition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a workflow run action scoped repetition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<WorkflowRunActionRepetitionDefinitionInner> getAsync(
        String resourceGroupName, String workflowName, String runName, String actionName, String repetitionName) {
        return getWithResponseAsync(resourceGroupName, workflowName, runName, actionName, repetitionName)
            .flatMap(
                (Response<WorkflowRunActionRepetitionDefinitionInner> res) -> {
                    if (res.getValue() != null) {
                        return Mono.just(res.getValue());
                    } else {
                        return Mono.empty();
                    }
                });
    }

    /**
     * Get a workflow run action scoped repetition.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param repetitionName The workflow repetition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a workflow run action scoped repetition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public WorkflowRunActionRepetitionDefinitionInner get(
        String resourceGroupName, String workflowName, String runName, String actionName, String repetitionName) {
        return getAsync(resourceGroupName, workflowName, runName, actionName, repetitionName).block();
    }

    /**
     * Get a workflow run action scoped repetition.
     *
     * @param resourceGroupName The resource group name.
     * @param workflowName The workflow name.
     * @param runName The workflow run name.
     * @param actionName The workflow action name.
     * @param repetitionName The workflow repetition.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a workflow run action scoped repetition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<WorkflowRunActionRepetitionDefinitionInner> getWithResponse(
        String resourceGroupName,
        String workflowName,
        String runName,
        String actionName,
        String repetitionName,
        Context context) {
        return getWithResponseAsync(resourceGroupName, workflowName, runName, actionName, repetitionName, context)
            .block();
    }
}


text:
namespace java.util.concurrent
{
    public partial interface Delayed : global::java.lang.Comparable<Delayed>
    {
        long getDelay(TimeUnit prm1);
    }
}