code: public void encode(AsnOutputStream aos) throws EncodeException {
          if (this.userType == null && this.providerType == null)
              throw new EncodeException("Error encoding ResultSourceDiagnostic: Value not set");
  
          try {
              aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG);
              int pos = aos.StartContentDefiniteLength();
  
              if (this.userType != null) {
                  aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_U);
                  int pos2 = aos.StartContentDefiniteLength();
                  aos.writeInteger(this.userType.getType());
                  aos.FinalizeContent(pos2);
              } else {
                  aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_P);
                  int pos2 = aos.StartContentDefiniteLength();
                  aos.writeInteger(this.providerType.getType());
                  aos.FinalizeContent(pos2);
              }
  
              aos.FinalizeContent(pos);
  
          } catch (IOException e) {
              throw new EncodeException("IOException while encoding ResultSourceDiagnostic: " + e.getMessage(), e);
          } catch (AsnException e) {
              throw new EncodeException("AsnException while encoding ResultSourceDiagnostic: " + e.getMessage(), e);
          }
  
      }
docs: /*
  (non-Javadoc)
  
  @see org.restcomm.protocols.ss7.tcap.asn.Encodable#encode(org.mobicents.protocols .asn.AsnOutputStream)