/**
 * TEL.java
 * <p>
 * File generated from the datatypes::TEL uml Class
 * Generated by IHE - europe, gazelle team
 */
package net.ihe.gazelle.hl7v3.datatypes;

import java.io.Serial;
import java.util.ArrayList;
import java.util.List;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import net.ihe.gazelle.gen.common.ConstraintValidatorModule;

import org.w3c.dom.Document;
import org.w3c.dom.Node;


/**
 * Description of the class TEL.
 *
 * 
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TEL", propOrder = {
	"useablePeriod",
	"use"
})
@XmlRootElement(name = "TEL")
public class TEL extends net.ihe.gazelle.hl7v3.datatypes.URL implements java.io.Serializable {
	
	/**
	 * 
	 */
	@Serial
    private static final long serialVersionUID = 1L;

	
	/**
	 * 
	                     Specifies the periods of time during which the
	                     telecommunication address can be used.  For a
	                     telephone number, this can indicate the time of day
	                     in which the party can be reached on that telephone.
	                     For a web address, it may specify a time range in
	                     which the web content is promised to be available
	                     under the given address.
	                  .
	 */
	@XmlElement(name = "useablePeriod", namespace = "urn:hl7-org:v3")
	public List<net.ihe.gazelle.hl7v3.datatypes.SXCMTS> useablePeriod;
	/**
	 * 
	                     One or more codes advising a system or user which
	                     telecommunication address in a set of like addresses
	                     to select for a given telecommunication need.
	                  .
	 */
	@XmlAttribute(name = "use")
	public java.lang.String use;
	
	/**
	 * An attribute containing marshalled element node
	 */
	@XmlTransient
	private org.w3c.dom.Node _xmlNodePresentation;
	
	
	/**
	 * Return useablePeriod.
	 * @return useablePeriod : 
	                     Specifies the periods of time during which the
	                     telecommunication address can be used.  For a
	                     telephone number, this can indicate the time of day
	                     in which the party can be reached on that telephone.
	                     For a web address, it may specify a time range in
	                     which the web content is promised to be available
	                     under the given address.
	 */
	public List<net.ihe.gazelle.hl7v3.datatypes.SXCMTS> getUseablePeriod() {
		if (useablePeriod == null) {
	        useablePeriod = new ArrayList<>();
	    }
	    return useablePeriod;
	}
	
	/**
	 * Set a value to attribute useablePeriod.
	 * @param useablePeriod : 
	                     Specifies the periods of time during which the
	                     telecommunication address can be used.  For a
	                     telephone number, this can indicate the time of day
	                     in which the party can be reached on that telephone.
	                     For a web address, it may specify a time range in
	                     which the web content is promised to be available
	                     under the given address.
	 */
	public void setUseablePeriod(List<net.ihe.gazelle.hl7v3.datatypes.SXCMTS> useablePeriod) {
	    this.useablePeriod = useablePeriod;
	}
	
	
	
	/**
	 * Add a useablePeriod to the useablePeriod collection.
	 * @param useablePeriod_elt Element to add.
	 */
	public void addUseablePeriod(net.ihe.gazelle.hl7v3.datatypes.SXCMTS useablePeriod_elt) {
	    this.useablePeriod.add(useablePeriod_elt);
	}
	
	/**
	 * Remove a useablePeriod to the useablePeriod collection.
	 * @param useablePeriod_elt Element to remove
	 */
	public void removeUseablePeriod(net.ihe.gazelle.hl7v3.datatypes.SXCMTS useablePeriod_elt) {
	    this.useablePeriod.remove(useablePeriod_elt);
	}
	
	/**
	 * Return use.
	 * @return use : 
	                     One or more codes advising a system or user which
	                     telecommunication address in a set of like addresses
	                     to select for a given telecommunication need.
	 */
	public java.lang.String getUse() {
	    return use;
	}
	
	/**
	 * Set a value to attribute use.
	 * @param use : 
	                     One or more codes advising a system or user which
	                     telecommunication address in a set of like addresses
	                     to select for a given telecommunication need.

	 */
	public void setUse(java.lang.String use) {
	    this.use = use;
	}
	
	
	
	
	
	public Node get_xmlNodePresentation() {
		if (_xmlNodePresentation == null){
				JAXBContext jc;
				DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
				dbf.setNamespaceAware(true);
				DocumentBuilder db = null;
				Document doc = null;
				try {
					db = dbf.newDocumentBuilder();
					doc = db.newDocument();
				} catch (ParserConfigurationException ignored) {}
				try {
					jc = JAXBContext.newInstance("net.ihe.gazelle.hl7v3.datatypes");
					Marshaller m = jc.createMarshaller();
					m.marshal(this, doc);
					_xmlNodePresentation = doc.getElementsByTagNameNS("urn:hl7-org:v3", "TEL").item(0);
				} catch (JAXBException e) {
					try{
						db = dbf.newDocumentBuilder();
						_xmlNodePresentation = db.newDocument();
					}
					catch(Exception ignored){}
				}
			}
			return _xmlNodePresentation;
	}
	
	public void set_xmlNodePresentation(Node _xmlNodePresentation) {
		this._xmlNodePresentation = _xmlNodePresentation;
	}
	
	
	

	
	/**
     * validate by a module of validation
     * 
     */
   public static void validateByModule(TEL tEL, String _location, ConstraintValidatorModule cvm, List<net.ihe.gazelle.validation.Notification> diagnostic){
   		if (tEL != null){
   			net.ihe.gazelle.hl7v3.datatypes.URL.validateByModule(tEL, _location, cvm, diagnostic);
			{
				int i = 0;
				for (net.ihe.gazelle.hl7v3.datatypes.SXCMTS useablePeriod: tEL.getUseablePeriod()){
					net.ihe.gazelle.hl7v3.datatypes.SXCMTS.validateByModule(useablePeriod, _location + "/useablePeriod[" + i + "]", cvm, diagnostic);
					i++;
				}
			}
			
    	}
    }

}