text:
<?php

defined('_JEXEC') or die;

/**
 * Function to build a Users URL route.
 *
 * @param	array	The array of query string values for which to build a route.
 * @return	array	The URL route with segments represented as an array.
 * @since	1.5
 */
function UsersBuildRoute(&$query)
{
	// Declare static variables.
	static $items;
	static $default;
	static $registration;
	static $profile;
	static $login;
	static $remind;
	static $resend;
	static $reset;

	// Initialise variables.
	$segments = array();

	// Get the relevant menu items if not loaded.
	if (empty($items)) {
		// Get all relevant menu items.
		$app	= JFactory::getApplication();
		$menu	= $app->getMenu();
		$items	= $menu->getItems('component', 'com_users');

		// Build an array of serialized query strings to menu item id mappings.
		for ($i = 0, $n = count($items); $i < $n; $i++) {
			// Check to see if we have found the resend menu item.
			if (empty($resend) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'resend')) {
				$resend = $items[$i]->id;
			}

			// Check to see if we have found the reset menu item.
			if (empty($reset) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'reset')) {
				$reset = $items[$i]->id;
			}

			// Check to see if we have found the remind menu item.
			if (empty($remind) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'remind')) {
				$remind = $items[$i]->id;
			}

			// Check to see if we have found the login menu item.
			if (empty($login) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'login')) {
				$login = $items[$i]->id;
			}

			// Check to see if we have found the registration menu item.
			if (empty($registration) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'registration')) {
				$registration = $items[$i]->id;
			}

			// Check to see if we have found the profile menu item.
			if (empty($profile) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'profile')) {
			$profile = $items[$i]->id;
			}
		}

		// Set the default menu item to use for com_users if possible.
		if ($profile) {
			$default = $profile;
		} elseif ($registration) {
			$default = $registration;
		} elseif ($login) {
			$default = $login;
		}
	}

	if (!empty($query['view'])) {
		switch ($query['view']) {
			case 'reset':
				if ($query['Itemid'] = $reset) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}
				break;

			case 'resend':
				if ($query['Itemid'] = $resend) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}
				break;

			case 'remind':
				if ($query['Itemid'] = $remind) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}
				break;

			case 'login':
				if ($query['Itemid'] = $login) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}
				break;

			case 'registration':
				if ($query['Itemid'] = $registration) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}
				break;

			default:
			case 'profile':
				if (!empty($query['view'])) {
					$segments[] = $query['view'];
				}
				unset ($query['view']);
				if ($query['Itemid'] = $profile) {
					unset ($query['view']);
				} else {
					$query['Itemid'] = $default;
				}

				// Only append the user id if not "me".
				$user = JFactory::getUser();
				if (!empty($query['user_id']) && ($query['user_id'] != $user->id)) {
					$segments[] = $query['user_id'];
				}
				unset ($query['user_id']);

				break;
		}
	}

	return $segments;
}

/**
 * Function to parse a Users URL route.
 *
 * @param	array	The URL route with segments represented as an array.
 * @return	array	The array of variables to set in the request.
 * @since	1.5
 */
function UsersParseRoute($segments)
{
	// Initialise variables.
	$vars = array();

	// Only run routine if there are segments to parse.
	if (count($segments) < 1) {
		return;
	}

	// Get the package from the route segments.
	$userId = array_pop($segments);

	if (!is_numeric($userId)) {
		$vars['view'] = 'profile';
		return $vars;
	}

	if (is_numeric($userId)) {
		// Get the package id from the packages table by alias.
		$db = JFactory::getDbo();
		$db->setQuery(
			'SELECT '.$db->quoteName('id') .
			' FROM '.$db->quoteName('#__users') .
			' WHERE '.$db->quoteName('id').' = '.(int) $userId
		);
		$userId = $db->loadResult();
	}

	// Set the package id if present.
	if ($userId) {
		// Set the package id.
		$vars['user_id'] = (int)$userId;

		// Set the view to package if not already set.
		if (empty($vars['view'])) {
			$vars['view'] = 'profile';
		}
	} else {
		JError::raiseError(404, JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
	}

	return $vars;
}

redpajama_set_name: RedPajamaGithub


text:
create table llx_compta_account
(
  rowid             integer AUTO_INCREMENT PRIMARY KEY,
  datec             datetime,
  number            varchar(12),
  label             varchar(255),
  fk_user_author    integer,
  note              text

)type=innodb;


text:
<!DOCTYPE html>

  <title>canvas example</title>

Interactive image (canvas) with text alternative:

  <canvas id="example" width="260" height="200" role="img">

Shapes

A rectangle with a black border. In the background is a pink circle. Partially overlaying the circle is a green
      square and a purple triangle, both of which are semi-opaque,
      so the full circle can be seen underneath.

  </canvas>

Hello!

    <svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml" version="1.1" html:tabindex="0" focusable="true">
      <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"></circle>
      <circle cx="100" cy="150" r="40" stroke="black" stroke-width="2" fill="blue"></circle>
    </svg>

code

  <xmp>
    <canvas id="example" width="260" height="200">

Shapes

A rectangle with a black border. In the background is a pink circle. Partially overlaying the
        circle.
        Partially overlaying the circle is a green
        square
        and a purple triangle,
        both of which are semi-opaque, so the full circle can be seen underneath.

    </canvas>
  </xmp>


text:
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

namespace osu.Game.Rulesets.Mania.Mods
{
    public class ManiaModKey6 : ManiaKeyMod
    {
        public override int KeyCount => 6;
        public override string Name => "Six Keys";
        public override string ShortenedName => "6K";
        public override string Description => @"Play with six keys.";
    }
}


text:
package com.alsash.reciper.logic.event;

import com.alsash.reciper.logic.action.RecipeAction;

public class RecipeEvent {

    public final RecipeAction action;
    public final String uuid;

    public RecipeEvent(RecipeAction action, String uuid) {
        this.action = action;
        this.uuid = uuid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof RecipeEvent)) return false;
        RecipeEvent event = (RecipeEvent) o;
        if (action != event.action) return false;
        return uuid != null ? uuid.equals(event.uuid) : event.uuid == null;
    }

    @Override
    public int hashCode() {
        int result = action != null ? action.hashCode() : 0;
        result = 31 * result + (uuid != null ? uuid.hashCode() : 0);
        return result;
    }
}


text:
#ifndef MBED_PINNAMESTYPES_H
#define MBED_PINNAMESTYPES_H

#include "cmsis.h"

#ifdef __cplusplus
extern "C" {
#endif

/*  STM PIN data as used in pin_function is coded on 32 bits as below
 *   [2:0]  Function (like in MODER reg) : Input / Output / Alt / Analog
 *     [3]  Output Push-Pull / Open Drain (as in OTYPER reg)
 *   [5:4]  as in PUPDR reg: No Pull, Pull-up, Pull-Donc
 *   [7:6]  Reserved for speed config (as in OSPEEDR), but not used yet
 *  [11:8]  Alternate Num (as in AFRL/AFRG reg)
 * [16:12]  Channel (Analog/Timer specific)
 *    [17]  Inverted (Analog/Timer specific)
 *    [18]  Analog ADC control - Only valid for specific families
 * [32:19]  Reserved
 */

#define STM_PIN_FUNCTION_MASK 0x07
#define STM_PIN_FUNCTION_SHIFT 0
#define STM_PIN_FUNCTION_BITS (STM_PIN_FUNCTION_MASK << STM_PIN_FUNCTION_SHIFT)

#define STM_PIN_OD_MASK 0x01
#define STM_PIN_OD_SHIFT 3
#define STM_PIN_OD_BITS (STM_PIN_OD_MASK << STM_PIN_OD_SHIFT)

#define STM_PIN_PUPD_MASK 0x03
#define STM_PIN_PUPD_SHIFT 4
#define STM_PIN_PUPD_BITS (STM_PIN_PUPD_MASK << STM_PIN_PUPD_SHIFT)

#define STM_PIN_SPEED_MASK 0x03
#define STM_PIN_SPEED_SHIFT 6
#define STM_PIN_SPEED_BITS (STM_PIN_SPEED_MASK << STM_PIN_SPEED_SHIFT)

#define STM_PIN_AFNUM_MASK 0x0F
#define STM_PIN_AFNUM_SHIFT 8
#define STM_PIN_AFNUM_BITS (STM_PIN_AFNUM_MASK << STM_PIN_AFNUM_SHIFT)

#define STM_PIN_CHAN_MASK 0x1F
#define STM_PIN_CHAN_SHIFT 12
#define STM_PIN_CHANNEL_BIT (STM_PIN_CHAN_MASK << STM_PIN_CHAN_SHIFT)

#define STM_PIN_INV_MASK 0x01
#define STM_PIN_INV_SHIFT 17
#define STM_PIN_INV_BIT (STM_PIN_INV_MASK << STM_PIN_INV_SHIFT)

#define STM_PIN_AN_CTRL_MASK 0x01
#define STM_PIN_AN_CTRL_SHIFT 18
#define STM_PIN_ANALOG_CONTROL_BIT (STM_PIN_AN_CTRL_MASK << STM_PIN_AN_CTRL_SHIFT)

#define STM_PIN_FUNCTION(X)         (((X) >> STM_PIN_FUNCTION_SHIFT) & STM_PIN_FUNCTION_MASK)
#define STM_PIN_OD(X)               (((X) >> STM_PIN_OD_SHIFT) & STM_PIN_OD_MASK)
#define STM_PIN_PUPD(X)             (((X) >> STM_PIN_PUPD_SHIFT) & STM_PIN_PUPD_MASK)
#define STM_PIN_SPEED(X)            (((X) >> STM_PIN_SPEED_SHIFT) & STM_PIN_SPEED_MASK)
#define STM_PIN_AFNUM(X)            (((X) >> STM_PIN_AFNUM_SHIFT) & STM_PIN_AFNUM_MASK)
#define STM_PIN_CHANNEL(X)          (((X) >> STM_PIN_CHAN_SHIFT) & STM_PIN_CHAN_MASK)
#define STM_PIN_INVERTED(X)         (((X) >> STM_PIN_INV_SHIFT) & STM_PIN_INV_MASK)
#define STM_PIN_ANALOG_CONTROL(X)   (((X) >> STM_PIN_AN_CTRL_SHIFT) & STM_PIN_AN_CTRL_MASK)

#define STM_PIN_DEFINE(FUNC_OD, PUPD, AFNUM)  ((int)(FUNC_OD) |\
                          ((PUPD  & STM_PIN_PUPD_MASK) << STM_PIN_PUPD_SHIFT) |\
                          ((AFNUM & STM_PIN_AFNUM_MASK) << STM_PIN_AFNUM_SHIFT))

#define STM_PIN_DEFINE_EXT(FUNC_OD, PUPD, AFNUM, CHAN, INV) \
                                            ((int)(FUNC_OD) |\
                       ((PUPD   & STM_PIN_PUPD_MASK) << STM_PIN_PUPD_SHIFT) |\
                       ((AFNUM  & STM_PIN_AFNUM_MASK) << STM_PIN_AFNUM_SHIFT) |\
                       ((CHAN   & STM_PIN_CHAN_MASK) << STM_PIN_CHAN_SHIFT) |\
                       ((INV    & STM_PIN_INV_MASK) << STM_PIN_INV_SHIFT))

/*
 * MACROS to support the legacy definition of PIN formats
 * The STM_MODE_ defines contain the function and the Push-pull/OpenDrain
 * configuration (legacy inheritance).
 */
#define STM_PIN_DATA(FUNC_OD, PUPD, AFNUM) \
            STM_PIN_DEFINE(FUNC_OD, PUPD, AFNUM)
#define STM_PIN_DATA_EXT(FUNC_OD, PUPD, AFNUM, CHANNEL, INVERTED) \
            STM_PIN_DEFINE_EXT(FUNC_OD, PUPD, AFNUM, CHANNEL, INVERTED)

typedef enum {
    STM_PIN_INPUT = 0,
    STM_PIN_OUTPUT = 1,
    STM_PIN_ALTERNATE = 2,
    STM_PIN_ANALOG = 3,
} StmPinFunction;

#define STM_MODE_INPUT               (STM_PIN_INPUT)
#define STM_MODE_OUTPUT_PP           (STM_PIN_OUTPUT)
#define STM_MODE_OUTPUT_OD           (STM_PIN_OUTPUT | STM_PIN_OD_BITS)
#define STM_MODE_AF_PP               (STM_PIN_ALTERNATE)
#define STM_MODE_AF_OD               (STM_PIN_ALTERNATE | STM_PIN_OD_BITS)
#define STM_MODE_ANALOG              (STM_PIN_ANALOG)
#define STM_MODE_ANALOG_ADC_CONTROL  (STM_PIN_ANALOG | STM_PIN_ANALOG_CONTROL_BIT)

// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
// Low nibble  = pin number
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
#define STM_PIN(X)  ((uint32_t)(X) & 0xF)

/*  Defines to be used by application */
typedef enum {
    PIN_INPUT = 0,
    PIN_OUTPUT
} PinDirection;

typedef enum {
    PullNone          = 0,
    PullUp            = 1,
    PullDown          = 2,
    OpenDrainPullUp   = 3,
    OpenDrainNoPull   = 4,
    OpenDrainPullDown = 5,
    PushPullNoPull    = PullNone,
    PushPullPullUp    = PullUp,
    PushPullPullDown  = PullDown,
    OpenDrain         = OpenDrainPullUp,
    PullDefault       = PullNone
} PinMode;

#ifdef __cplusplus
}
#endif

#endif


text:
'use strict';

(function() {

	var angularBasicAuth = angular.module(
		'angularBasicAuth',
		[
			'LocalStorageModule',
			'base64'
		]);

	// Constants
	var MS_PER_MINUTE = 1000 * 60;

	/**
	* Difference between two dates in hours
	*
	* @param {Date} a First date
	* @param {Date} b Second date
	*/
	function dateDiffInMinutes(earlier, later) {
		return (later.getTime() - earlier.getTime()) / MS_PER_MINUTE;
	}

	/**
	 * Constants
	 */
	angularBasicAuth.constant('MODULE_VERSION', '0.0.0');

	/**
	 * Defaults
	 */
	angularBasicAuth.value('authDefaults', {
		authenticateUrl: '/api/authenticate',
		sessionMinutes: 180
	});

	/**
	* HTTP Interceptor to add Authorization headers to all requests if the
	* auth local storage property has been set
	*/
	angularBasicAuth.factory('authInterceptor',
		[
			'$q',
			'authService',
			function ($q, authService) {

				var isEndpoint = authService.isEndpoint;

				var authInterceptor = {

					/**
					* Request Interceptor
					*
					* Adds an authorization header, if and only if there
					* is one found in the local storage
					*/
					request: function(config) {
						if (isEndpoint(config.url)) {
							var auth = authService.getAuth();
							var headers = authService.headers;
							if (auth) {
								config.headers.Authorization = auth;
								for (var key in headers) {
									if (headers.hasOwnProperty(key)) {
										config.headers[key] = headers[key];
									}
								}
							}
						}
						return config;
					},

					/**
					* Error Interceptor
					*
					* Used to trap an authentication error
					*/
					responseError: function(rejection) {
						// this is a failure to authenticate
						// so inform the authenticaton service
						if (rejection.status === 401) {
							authService.handleAuthFailure();
						}

						return $q.reject(rejection);
					}
				};

				return authInterceptor;
			}
		]);

	/**
	* Service to handle user authentication
	*
	* This is a singleton service, so we will instantiate this once in an iife
	*/
	(function() {
		angularBasicAuth.factory('authService',
			[
				'$log',
				'localStorageService',
				'$base64',
				'$q',
				'$rootScope',
				'$interval',
				'authDefaults',
				function ($log, localStorage, $base64, $q, $rootScope, $interval, authDefaults) {

					$log.debug('authService constructed');

					var LS_USERNAME = 'username';
					var LS_AUTHENTICATION = 'auth';
					var LS_LASTACTIVITY = 'last-activity';

					// array to store protected endpoints
					var endpoints = [];
					// use an anchor element to parse urls
					var urlParser = document.createElement('a');

					/**
					 * Whether a hostname is in the endpoint collection
					 * @param {String} hostname  The hostname of a URL, e.g. www.google.com
					 */
					function inEndpoints(hostname) {
						for (var index = 0, len = endpoints.length; index < len; index++) {
							if (hostname === endpoints[index]) {
								return true;
							}
						}
						return false;
					}

					/**
					* Logout and wipe the local storage
					*/
					function logout() {
						$log.debug('logout event');
						localStorage.remove(LS_AUTHENTICATION);
						localStorage.remove(LS_LASTACTIVITY);
						localStorage.remove(LS_USERNAME);
						$rootScope.$emit('logout');
					}

					/**
					* Set the user credentials
					*
					* @param {String} username Username
					* @param {String} password Unencryped password
					*/
					function setCredentials(username, password) {
						$log.debug('Setting credentials for user: ' + username);

						localStorage.set(LS_USERNAME, username);

						// set the value of the auth-header
						localStorage.set(LS_AUTHENTICATION,
							'Basic ' + $base64.encode(username + ':' + password));

						recordActivity();
					}

					/**
					* Record account activity
					*/
					function recordActivity() {
						localStorage.set(LS_LASTACTIVITY, (new Date()).toString());
					}

					/**
					* Is the login current
					*/
					function isCurrent() {
						// retrieve the last activity of the account
						var lastActivity = localStorage.get(LS_LASTACTIVITY) || '';

						if (lastActivity === '') {
							return false;
						}

						return (dateDiffInMinutes(new Date(lastActivity), new Date()) < authDefaults.sessionMinutes);
					}

					/**
					* Confirm the account is current
					*/
					function confirmCurrent() {
						if (!isCurrent()) {
							$log.debug('Authentication credentials missing or out of date');
							logout();
						}
					}

					/**
					* Returns the current authentication header
					*/
					function getAuth() {
						return localStorage.get(LS_AUTHENTICATION);
					}

					// we should work out whether we are current or not
					confirmCurrent();

					// set an inteval to do this regularly
					$interval(confirmCurrent, 60000);

					return {
						/**
						* Get any current authentication header
						*/
						getAuth: getAuth,

						/**
						* Handles logout
						*/
						logout: logout,

						/**
						* Record activity
						*/
						activity: recordActivity,

						/**
						 * Add an endpoint
						 *
						 * @param {String} endpoint  The URL of an endpoint, or undefined if current location
						 */
						addEndpoint: function(endpoint) {
							endpoint = endpoint || window.location;
							urlParser.href = endpoint;
							var hostname = urlParser.hostname;
							if (inEndpoints(hostname)) {
								return;
							}
							endpoints.push(hostname);
						},

						/**
						 * Additional headers to add to authenticated
						 * requests.
						 */
						headers: {},

						/**
						 * Is an URL a defined endpoint requiring authentication
						 *
						 * @param {String} url The URL of a potential endpoint
						 */
						isEndpoint: function(url) {
							urlParser.href = url;
							var hostname = urlParser.hostname;
							return inEndpoints(hostname);
						},

						/**
						* The current username
						*
						* @return {String} The current username
						*/
						username: function() {
							confirmCurrent();
							return localStorage.get(LS_USERNAME);
						},

						/**
						* Handle an authentication failure
						*/
						handleAuthFailure: function() {
							logout();
							$rootScope.$emit('authentication-failure');
						},

						/**
						* Handles login to the application
						*
						* @param  {String} username The username
						* @param  {String} password The password
						* @return {Object}          Promise for the transaction
						*/
						login: function(username, password, headers) {
							$log.debug('login event');

							// record the credentials
							setCredentials(username, password);

							var deferred = $q.defer();

							/**
							* Process the response, and if there are any issues
							* the reject the promise
							*/
							function processResponse() {
								/* jshint validthis: true */
								if (this.status !== 200) {
									deferred.reject();
								} else {
									deferred.resolve();
								}
							}

							// don't use $http to avoid circular reference, so
							// directly use XMLHttpRequest and $q
							var promise = deferred.promise;
							var request = new XMLHttpRequest();
							request.timeout = 15000;
							request.onload = processResponse;
							request.onerror = request.ontimeout = function () {
								deferred.reject();
							};
							request.open('GET', authDefaults.authenticateUrl);
							request.setRequestHeader('Accept', 'application/json');
							request.setRequestHeader('Authorization', getAuth());
							for (var key in this.headers) {
							  if (this.headers.hasOwnProperty(key)) {
									request.setRequestHeader(key, this.headers[key]);
							  }
							}
							request.send(null);

							/**
							* Allow subscribers to the promise to add a
							* success function to the login event
							*/
							promise.success = function(fn) {
								promise.then(function() {
									fn();
								});
								return promise;
							};

							/**
							* Allow subscribers to the promise to add
							* an error function to the login event
							*/
							promise.error = function(fn) {
								promise.then(null, function() {
									fn();
								});
								return promise;
							};

							/**
							* Handle the promise being rejected or resolved
							*/
							promise.then(function () {
								// we've confirmed credentials match a user
								$log.debug('Successfully authenticated');
								$rootScope.$broadcast('login', username);
							}, function () {
								// some error in credential check
								$log.debug('Test authentication failed');
								logout();
								$rootScope.$broadcast('authentication-failed', username);
							});

							return promise;
						}
					};
				}
			]
		);
	})();

	// add the interceptor to the http service
	angularBasicAuth.config(['$httpProvider', function($httpProvider) {
		$httpProvider.interceptors.push('authInterceptor');
	}]);

})();


text:
package org.apache.hadoop.hive.metastore.events;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hive.metastore.IHMSHandler;
import org.apache.hadoop.hive.metastore.api.Table;

@InterfaceAudience.Public
@InterfaceStability.Stable
public class PreAlterTableEvent extends PreEventContext {

  private final Table newTable;
  private final Table oldTable;

  public PreAlterTableEvent (Table oldTable, Table newTable, IHMSHandler handler) {
    super (PreEventType.ALTER_TABLE, handler);
    this.oldTable = oldTable;
    this.newTable = newTable;
  }

  /**
   * @return the old table
   */
  public Table getOldTable() {
    return oldTable;
  }

  /**
   * @return the new table
   */
  public Table getNewTable() {
    return newTable;
  }
}


text:
module.exports = function () {
  return function json(file, done) {
    if (file.extension !== 'json') return done();
    file.read(function (err, string) {
      if (err) return done(err);
      try {
        JSON.parse(string);
      } catch (err) {
        done(new Error('"' + file.filename + '" is invalid JSON'));
        return;
      }
      file.string = string;
      file.define = true;
      done();
    })
  }
}


text:
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax --opt

/* Test deopt behaviors when the prototype has elements */

// findIndex

(function () {
  var array = [,];

  function findIndex() {
    return array.findIndex(v => v > 0);
  }

  findIndex(); findIndex();

  %OptimizeFunctionOnNextCall(findIndex);
  assertEquals(findIndex(), -1);

  array.__proto__.push(6);
  // deopt
  assertEquals(findIndex(), 0);
})();


text:
namespace CGAL {

template <class Kernel>
class Surface_mesh_triangulation_generator_3
{
  typedef CGAL::Surface_mesh_vertex_base_3<Kernel> Vb;
  typedef CGAL::Surface_mesh_cell_base_3<Kernel> Cb;
  typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
public:
  typedef CGAL::Delaunay_triangulation_3<Kernel, Tds> Type;
  typedef Type type; // Boost meta-programming compatibility
};

} // end namespace CGAL

#endif // CGAL_SURFACE_MESH_TRIANGULATION_GENERATOR_3_H


text:
package org.apache.abdera.test.core;

import org.apache.abdera.test.core.CoreTest;

public class TestSuite extends junit.framework.TestSuite {
  public static void main(String[] args) {
    junit.textui.TestRunner.run(new TestSuite());
  }

  public TestSuite() {
    addTestSuite(CoreTest.class);
  }
}


text:
package org.pentaho.di.trans.steps.csvinput;

public interface FieldsMapping {

  final int FIELD_DOES_NOT_EXIST = -1;

  int fieldMetaIndex( int index );

  int size();

}


text:
package io.agrest.runtime.cayenne.processor.update;

import io.agrest.AgException;
import io.agrest.EntityUpdate;
import io.agrest.ObjectMapper;
import io.agrest.runtime.meta.IMetadataService;
import io.agrest.runtime.processor.update.UpdateContext;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.map.EntityResolver;
import org.apache.cayenne.query.SelectQuery;

import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @since 2.7
 */
public class CayenneIdempotentFullSyncStage extends CayenneIdempotentCreateOrUpdateStage {

    public CayenneIdempotentFullSyncStage(@Inject IMetadataService metadataService) {
        super(metadataService);
    }

    @Override
    protected <T extends DataObject> void sync(UpdateContext<T> context) {

        ObjectMapper<T> mapper = createObjectMapper(context);
        Map<Object, Collection<EntityUpdate<T>>> keyMap = mutableKeyMap(context, mapper);

        List<T> allObjects = allItems(context);

        List<DataObject> deletedObjects = new ArrayList<>();

        for (T o : allObjects) {
            Object key = mapper.keyForObject(o);

            Collection<EntityUpdate<T>> updates = keyMap.remove(key);

            if (updates == null) {
                deletedObjects.add(o);
            } else {
                updateSingle(context, o, updates);
            }
        }

        if (!deletedObjects.isEmpty()) {
            CayenneUpdateStartStage.cayenneContext(context).deleteObjects(deletedObjects);
        }

        // check leftovers - those correspond to objects missing in the DB or
        // objects with no keys
        afterUpdatesMerge(context, keyMap);
    }

    <T extends DataObject> List<T> allItems(UpdateContext<T> context) {
        SelectQuery<T> query = SelectQuery.query(context.getType());

        // apply various request filters identifying the span of the collection

        if (context.getParent() != null) {
            EntityResolver resolver = CayenneUpdateStartStage.cayenneContext(context).getEntityResolver();
            query.andQualifier(context.getParent().qualifier(resolver));
        }

        if (context.getEntity().getQualifier() != null) {
            query.andQualifier(context.getEntity().getQualifier());
        }

        // TODO: use SelectBuilder to get Cayenne representation of the
        // resource, instead of duplicating this here...

        List<T> objects = CayenneUpdateStartStage.cayenneContext(context).select(query);
        if (context.isById() && objects.size() > 1) {
            throw new AgException(Response.Status.INTERNAL_SERVER_ERROR, String.format(
                    "Found more than one object for ID '%s' and entity '%s'",
                    context.getId(), context.getEntity().getAgEntity().getName()));
        }
        return objects;
    }

}


text:
//
//  UIViewController+SPUIAlertController.h
//  SPCategory
//
//  Created by shiping1 on 2017/11/21.
//  Copyright © 2017年 lishiping. All rights reserved.
//
//If you feel this open source library is of great help to you, please open the URL to the point of a great, great encouragement your recognition to the author, the author will release better open source library for you again
//如果您感觉本开源库对您很有帮助,请打开URL给作者点个赞,您的认可给作者极大的鼓励,作者还会再发布更好的开源库给大家

//github address//https://github.com/lishiping/SPWebView
//github address//https://github.com/lishiping/SPDebugBar
//github address//https://github.com/lishiping/SPFastPush
//github address//https://github.com/lishiping/SPMacro
//github address//https://github.com/lishiping/SafeData
//github address//https://github.com/lishiping/SPCategory
//github address//https://github.com/lishiping/SPBaseClass

#import <UIKit/UIKit.h>
#import "NSObject+SPAssociatedObject.h"

typedef void (^SPIdClickedBlock)(UIAlertAction * _Nullable action);

@interface UIViewController (SPUIAlertController)

//这个方法是为了解决当前VC已经消失了(主动控制警告框消失的方法),而由于其他原因Alert还未消失,可以在在viewdiddisappear里面加入移除alertview
-(void)sp_removespAlertVC;

/*本类别的特点:
1.旨在实现快捷的方法,一个方法代替了以往的创建初始化显示等过程,实现代码复用
2.使用ViewController的类别,使代码不要都集中在ViewController,如果VC代码很臃肿,不利于可读性可维护性
3.由于以往开发发现了有在网络层拦截弹出alert,后期维护艰难,旨在MVC模式下,不让view层被引入到网络层在底层拦截弹出警告框,这也是苹果开发文档的要求
4.方法顺序是使用频率顺序,不常用的方法作为其他常用方法的基础方法
5.缺点只扩展了一个和两个按钮的方法,两个以上按钮的没做处理,因为多个按钮的无法控制,而且使用频率不高,可以自行创建
 */

#pragma mark - AlertView

/**
 只有标题且只有一个按钮的alertView,只有一个选择方案的(例如强制更新等)

 @param title 标题
 @param ok_title 按钮名字
 @param ok_block 按钮回调
 */
-(UIAlertController *_Nullable)sp_showAlertView_title:(NSString*_Nullable)title
                     ok_title:(NSString*_Nullable)ok_title
                     ok_block:(SPIdClickedBlock _Nullable )ok_block;

/**
 有标题有详情信息,但只有一个按钮的alertView,只有一个选择方案的(例如强制更新等)

 @param title 标题
 @param message 信息
 @param ok_title 按钮名字
 @param ok_block 按钮回调
 */
-(UIAlertController *_Nullable)sp_showAlertView_title:(NSString*_Nullable)title
                      message:(NSString*_Nullable)message
                     ok_title:(NSString*_Nullable)ok_title
                     ok_block:(SPIdClickedBlock _Nullable )ok_block;

/**
 有标题有详情信息,但只有一个按钮的alertView,加入了动画控制,带完成回调,只有一个选择方案的(例如强制更新等)

 @param title 标题
 @param message 信息
 @param flag 动画
 @param ok_title 按钮名字
 @param ok_block 按钮回调
 @param completion 完成回调
 */
-(UIAlertController *_Nullable)sp_showAlertView_title:(NSString*_Nullable)title
                      message:(NSString*_Nullable)message
                     animated: (BOOL)flag
                     ok_title:(NSString*_Nullable)ok_title
                     ok_block:(SPIdClickedBlock _Nullable )ok_block
                   completion:(void (^ __nullable)(void))completion;

/**
 快捷警告框,两个按钮

 @param title 标题
 @param message 信息
 @param ok_title 确认或者自定义按钮名字
 @param cancel_title 取消或者自定义按钮名字
 @param ok_block 确认或者自定义按钮回调
 @param cancel_block 取消或者自定义按钮回调
 */
-(UIAlertController *_Nullable)sp_showAlertView_title:(NSString*_Nullable)title
                      message:(NSString*_Nullable)message
                     ok_title:(NSString*_Nullable)ok_title
                 cancel_title:(NSString*_Nullable)cancel_title
                     ok_block:(SPIdClickedBlock _Nullable)ok_block
                 cancel_block:(SPIdClickedBlock _Nullable )cancel_block;

/**
 快捷的弹出警告框的方法

 @param title 标题
 @param message 详情信息
 @param ok_title 确定按钮或者自定义名字
 @param cancel_title 取消按钮或者自定义名字
 @param animated 动画
 @param ok_block 确定按钮或者自定义按钮回调
 @param cancel_block 取消按钮或者自定义按钮回调
 @param completion UIAlertViewController完成弹出后的回调(不用可传nil)
 */
-(UIAlertController *_Nullable)sp_showAlertView_title:(NSString*_Nullable)title
                      message:(NSString*_Nullable)message
                     ok_title:(NSString*_Nullable)ok_title
                 cancel_title:(NSString*_Nullable)cancel_title
                     animated: (BOOL)animated
                     ok_block:(SPIdClickedBlock _Nullable)ok_block
                 cancel_block:(SPIdClickedBlock _Nullable)cancel_block
                   completion:(void (^ __nullable)(void))completion;

#pragma mark - ActionSheet

/**
 快捷弹出ActionSheet控件,默认使用UIAlertActionStyleDestructive风格

 @param title 标题
 @param message 信息
 @param ok_title 确认或者自定义名字
 @param cancel_title 取消或者自定义名字
 @param ok_block 确认或者自定义按钮的回调
 @param cancel_block 取消或者自定义按钮的回调
 */
-(UIAlertController *_Nullable)sp_showActionSheet_title:(NSString*_Nullable)title
                        message:(NSString*_Nullable)message
                       ok_title:(NSString*_Nullable)ok_title
                   cancel_title:(NSString*_Nullable)cancel_title
                       ok_block:(SPIdClickedBlock _Nullable)ok_block
                   cancel_block:(SPIdClickedBlock _Nullable)cancel_block;

/**
 快捷弹出ActionSheet控件,默认使用UIAlertActionStyleDestructive风格

 @param title 标题
 @param message 信息
 @param ok_title_destructive 确认或者自定义名字
 @param cancel_title 取消或者自定义名字
 @param ok_block 确认或者自定义按钮的回调
 @param cancel_block 取消或者自定义按钮的回调
 */
-(UIAlertController *_Nullable)sp_showActionSheet_title:(NSString*_Nullable)title
                        message:(NSString*_Nullable)message
           ok_title_destructive:(NSString*_Nullable)ok_title_destructive
                   cancel_title:(NSString*_Nullable)cancel_title
                       ok_block:(SPIdClickedBlock _Nullable)ok_block
                   cancel_block:(SPIdClickedBlock _Nullable)cancel_block;

/**
 快捷弹出ActionSheet控件,默认使用UIAlertActionStyleDefault风格

 @param title 标题
 @param message 信息
 @param ok_title_default 确认或者自定义名字
 @param cancel_title 取消或者自定义名字
 @param ok_block 确认或者自定义按钮的回调
 @param cancel_block 取消或者自定义按钮的回调
 */
-(UIAlertController *_Nullable)sp_showActionSheet_title:(NSString*_Nullable)title
                        message:(NSString*_Nullable)message
               ok_title_default:(NSString*_Nullable)ok_title_default
                   cancel_title:(NSString*_Nullable)cancel_title
                       ok_block:(SPIdClickedBlock _Nullable)ok_block
                   cancel_block:(SPIdClickedBlock _Nullable)cancel_block;

/**
 快捷弹出ActionSheet控件,带有动画控制,默认按钮风格,以及完成的回调

 @param title 标题
 @param message 信息
 @param ok_title 确认或者自定义名字
 @param cancel_title 取消或者自定义名字
 @param animated 动画
 @param ok_title_style 默认按钮的风格
 @param ok_block 确认或者自定义按钮的回调
 @param cancel_block 取消或者自定义按钮的回调
 */
-(UIAlertController *_Nullable)sp_showActionSheet_title:(NSString*_Nullable)title
                        message:(NSString*_Nullable)message
                       ok_title:(NSString*_Nullable)ok_title
                   cancel_title:(NSString*_Nullable)cancel_title
                       animated: (BOOL)animated
                 ok_title_style:(UIAlertActionStyle)ok_title_style
                       ok_block:(SPIdClickedBlock _Nullable)ok_block
                   cancel_block:(SPIdClickedBlock _Nullable)cancel_block
                     completion:(void (^ __nullable)(void))completion;

@end


text:
<?php

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

use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRAttachment;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger;
use DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString;
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRConstants;
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRTypeInterface;

/**
 * A SubstanceProtein is defined as a single unit of a linear amino acid sequence,
 * or a combination of subunits that are either covalently linked or have a defined
 * invariant stoichiometric relationship. This includes all synthetic, recombinant
 * and purified SubstanceProteins of defined sequence, whether the use is
 * therapeutic or prophylactic. This set of elements will be used to describe
 * albumins, coagulation factors, cytokines, growth factors,
 * peptide/SubstanceProtein hormones, enzymes, toxins, toxoids, recombinant
 * vaccines, and immunomodulators.
 *
 * Class FHIRSubstanceProteinSubunit
 * @package \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIRSubstanceProtein
 */
class FHIRSubstanceProteinSubunit extends FHIRBackboneElement
{
    // name of FHIR type this class describes
    const FHIR_TYPE_NAME = PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT;
    const FIELD_C_TERMINAL_MODIFICATION = 'cTerminalModification';
    const FIELD_C_TERMINAL_MODIFICATION_EXT = '_cTerminalModification';
    const FIELD_C_TERMINAL_MODIFICATION_ID = 'cTerminalModificationId';
    const FIELD_LENGTH = 'length';
    const FIELD_LENGTH_EXT = '_length';
    const FIELD_N_TERMINAL_MODIFICATION = 'nTerminalModification';
    const FIELD_N_TERMINAL_MODIFICATION_EXT = '_nTerminalModification';
    const FIELD_N_TERMINAL_MODIFICATION_ID = 'nTerminalModificationId';
    const FIELD_SEQUENCE = 'sequence';
    const FIELD_SEQUENCE_EXT = '_sequence';
    const FIELD_SEQUENCE_ATTACHMENT = 'sequenceAttachment';
    const FIELD_SUBUNIT = 'subunit';
    const FIELD_SUBUNIT_EXT = '_subunit';

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

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The modification at the C-terminal shall be specified.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    protected $cTerminalModification = null;

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

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Length of linear sequences of amino acids contained in the subunit.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger
     */
    protected $length = null;

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The name of the fragment modified at the N-terminal of the SubstanceProtein
     * shall be specified.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    protected $nTerminalModification = null;

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

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    protected $sequence = null;

    /**
     * For referring to data content defined in other formats.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRAttachment
     */
    protected $sequenceAttachment = null;

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Index of primary sequences of amino acids linked through peptide bonds in order
     * of decreasing length. Sequences of the same length will be ordered by molecular
     * weight. Subunits that have identical sequences will be repeated and have
     * sequential subscripts.
     *
     * @var null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger
     */
    protected $subunit = null;

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

    /**
     * FHIRSubstanceProteinSubunit Constructor
     * @param null|array $data
     */
    public function __construct($data = null)
    {
        if (null === $data || [] === $data) {
            return;
        }
        if (!is_array($data)) {
            throw new \InvalidArgumentException(sprintf(
                'FHIRSubstanceProteinSubunit::_construct - $data expected to be null or array, %s seen',
                gettype($data)
            ));
        }
        parent::__construct($data);
        if (isset($data[self::FIELD_C_TERMINAL_MODIFICATION]) || isset($data[self::FIELD_C_TERMINAL_MODIFICATION_EXT])) {
            if (isset($data[self::FIELD_C_TERMINAL_MODIFICATION])) {
                $value = $data[self::FIELD_C_TERMINAL_MODIFICATION];
            } else {
                $value = null;
            }
            if (isset($data[self::FIELD_C_TERMINAL_MODIFICATION_EXT]) && is_array($data[self::FIELD_C_TERMINAL_MODIFICATION_EXT])) {
                $ext = $data[self::FIELD_C_TERMINAL_MODIFICATION_EXT];
            } else {
                $ext = [];
            }
            if (null !== $value) {
                if ($value instanceof FHIRString) {
                    $this->setCTerminalModification($value);
                } else if (is_array($value)) {
                    $this->setCTerminalModification(new FHIRString(array_merge($ext, $value)));
                } else {
                    $this->setCTerminalModification(new FHIRString([FHIRString::FIELD_VALUE => $value] + $ext));
                }
            } else if ([] !== $ext) {
                $this->setCTerminalModification(new FHIRString($ext));
            }
        }
        if (isset($data[self::FIELD_C_TERMINAL_MODIFICATION_ID])) {
            if ($data[self::FIELD_C_TERMINAL_MODIFICATION_ID] instanceof FHIRIdentifier) {
                $this->setCTerminalModificationId($data[self::FIELD_C_TERMINAL_MODIFICATION_ID]);
            } else {
                $this->setCTerminalModificationId(new FHIRIdentifier($data[self::FIELD_C_TERMINAL_MODIFICATION_ID]));
            }
        }
        if (isset($data[self::FIELD_LENGTH]) || isset($data[self::FIELD_LENGTH_EXT])) {
            if (isset($data[self::FIELD_LENGTH])) {
                $value = $data[self::FIELD_LENGTH];
            } else {
                $value = null;
            }
            if (isset($data[self::FIELD_LENGTH_EXT]) && is_array($data[self::FIELD_LENGTH_EXT])) {
                $ext = $data[self::FIELD_LENGTH_EXT];
            } else {
                $ext = [];
            }
            if (null !== $value) {
                if ($value instanceof FHIRInteger) {
                    $this->setLength($value);
                } else if (is_array($value)) {
                    $this->setLength(new FHIRInteger(array_merge($ext, $value)));
                } else {
                    $this->setLength(new FHIRInteger([FHIRInteger::FIELD_VALUE => $value] + $ext));
                }
            } else if ([] !== $ext) {
                $this->setLength(new FHIRInteger($ext));
            }
        }
        if (isset($data[self::FIELD_N_TERMINAL_MODIFICATION]) || isset($data[self::FIELD_N_TERMINAL_MODIFICATION_EXT])) {
            if (isset($data[self::FIELD_N_TERMINAL_MODIFICATION])) {
                $value = $data[self::FIELD_N_TERMINAL_MODIFICATION];
            } else {
                $value = null;
            }
            if (isset($data[self::FIELD_N_TERMINAL_MODIFICATION_EXT]) && is_array($data[self::FIELD_N_TERMINAL_MODIFICATION_EXT])) {
                $ext = $data[self::FIELD_N_TERMINAL_MODIFICATION_EXT];
            } else {
                $ext = [];
            }
            if (null !== $value) {
                if ($value instanceof FHIRString) {
                    $this->setNTerminalModification($value);
                } else if (is_array($value)) {
                    $this->setNTerminalModification(new FHIRString(array_merge($ext, $value)));
                } else {
                    $this->setNTerminalModification(new FHIRString([FHIRString::FIELD_VALUE => $value] + $ext));
                }
            } else if ([] !== $ext) {
                $this->setNTerminalModification(new FHIRString($ext));
            }
        }
        if (isset($data[self::FIELD_N_TERMINAL_MODIFICATION_ID])) {
            if ($data[self::FIELD_N_TERMINAL_MODIFICATION_ID] instanceof FHIRIdentifier) {
                $this->setNTerminalModificationId($data[self::FIELD_N_TERMINAL_MODIFICATION_ID]);
            } else {
                $this->setNTerminalModificationId(new FHIRIdentifier($data[self::FIELD_N_TERMINAL_MODIFICATION_ID]));
            }
        }
        if (isset($data[self::FIELD_SEQUENCE]) || isset($data[self::FIELD_SEQUENCE_EXT])) {
            if (isset($data[self::FIELD_SEQUENCE])) {
                $value = $data[self::FIELD_SEQUENCE];
            } else {
                $value = null;
            }
            if (isset($data[self::FIELD_SEQUENCE_EXT]) && is_array($data[self::FIELD_SEQUENCE_EXT])) {
                $ext = $data[self::FIELD_SEQUENCE_EXT];
            } else {
                $ext = [];
            }
            if (null !== $value) {
                if ($value instanceof FHIRString) {
                    $this->setSequence($value);
                } else if (is_array($value)) {
                    $this->setSequence(new FHIRString(array_merge($ext, $value)));
                } else {
                    $this->setSequence(new FHIRString([FHIRString::FIELD_VALUE => $value] + $ext));
                }
            } else if ([] !== $ext) {
                $this->setSequence(new FHIRString($ext));
            }
        }
        if (isset($data[self::FIELD_SEQUENCE_ATTACHMENT])) {
            if ($data[self::FIELD_SEQUENCE_ATTACHMENT] instanceof FHIRAttachment) {
                $this->setSequenceAttachment($data[self::FIELD_SEQUENCE_ATTACHMENT]);
            } else {
                $this->setSequenceAttachment(new FHIRAttachment($data[self::FIELD_SEQUENCE_ATTACHMENT]));
            }
        }
        if (isset($data[self::FIELD_SUBUNIT]) || isset($data[self::FIELD_SUBUNIT_EXT])) {
            if (isset($data[self::FIELD_SUBUNIT])) {
                $value = $data[self::FIELD_SUBUNIT];
            } else {
                $value = null;
            }
            if (isset($data[self::FIELD_SUBUNIT_EXT]) && is_array($data[self::FIELD_SUBUNIT_EXT])) {
                $ext = $data[self::FIELD_SUBUNIT_EXT];
            } else {
                $ext = [];
            }
            if (null !== $value) {
                if ($value instanceof FHIRInteger) {
                    $this->setSubunit($value);
                } else if (is_array($value)) {
                    $this->setSubunit(new FHIRInteger(array_merge($ext, $value)));
                } else {
                    $this->setSubunit(new FHIRInteger([FHIRInteger::FIELD_VALUE => $value] + $ext));
                }
            } else if ([] !== $ext) {
                $this->setSubunit(new FHIRInteger($ext));
            }
        }
    }

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

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

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The modification at the C-terminal shall be specified.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    public function getCTerminalModification()
    {
        return $this->cTerminalModification;
    }

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The modification at the C-terminal shall be specified.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString $cTerminalModification
     * @return static
     */
    public function setCTerminalModification($cTerminalModification = null)
    {
        if (null === $cTerminalModification) {
            $this->cTerminalModification = null;
            return $this;
        }
        if ($cTerminalModification instanceof FHIRString) {
            $this->cTerminalModification = $cTerminalModification;
            return $this;
        }
        $this->cTerminalModification = new FHIRString($cTerminalModification);
        return $this;
    }

    /**
     * An identifier - identifies some entity uniquely and unambiguously. Typically
     * this is used for business identifiers.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Unique identifier for molecular fragment modification based on the ISO 11238
     * Substance ID.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier
     */
    public function getCTerminalModificationId()
    {
        return $this->cTerminalModificationId;
    }

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

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Length of linear sequences of amino acids contained in the subunit.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger
     */
    public function getLength()
    {
        return $this->length;
    }

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Length of linear sequences of amino acids contained in the subunit.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger $length
     * @return static
     */
    public function setLength($length = null)
    {
        if (null === $length) {
            $this->length = null;
            return $this;
        }
        if ($length instanceof FHIRInteger) {
            $this->length = $length;
            return $this;
        }
        $this->length = new FHIRInteger($length);
        return $this;
    }

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The name of the fragment modified at the N-terminal of the SubstanceProtein
     * shall be specified.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    public function getNTerminalModification()
    {
        return $this->nTerminalModification;
    }

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The name of the fragment modified at the N-terminal of the SubstanceProtein
     * shall be specified.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString $nTerminalModification
     * @return static
     */
    public function setNTerminalModification($nTerminalModification = null)
    {
        if (null === $nTerminalModification) {
            $this->nTerminalModification = null;
            return $this;
        }
        if ($nTerminalModification instanceof FHIRString) {
            $this->nTerminalModification = $nTerminalModification;
            return $this;
        }
        $this->nTerminalModification = new FHIRString($nTerminalModification);
        return $this;
    }

    /**
     * An identifier - identifies some entity uniquely and unambiguously. Typically
     * this is used for business identifiers.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * Unique identifier for molecular fragment modification based on the ISO 11238
     * Substance ID.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRIdentifier
     */
    public function getNTerminalModificationId()
    {
        return $this->nTerminalModificationId;
    }

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

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString
     */
    public function getSequence()
    {
        return $this->sequence;
    }

    /**
     * A sequence of Unicode characters
     * Note that FHIR strings SHALL NOT exceed 1MB in size
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRString $sequence
     * @return static
     */
    public function setSequence($sequence = null)
    {
        if (null === $sequence) {
            $this->sequence = null;
            return $this;
        }
        if ($sequence instanceof FHIRString) {
            $this->sequence = $sequence;
            return $this;
        }
        $this->sequence = new FHIRString($sequence);
        return $this;
    }

    /**
     * For referring to data content defined in other formats.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRAttachment
     */
    public function getSequenceAttachment()
    {
        return $this->sequenceAttachment;
    }

    /**
     * For referring to data content defined in other formats.
     * If the element is present, it must have a value for at least one of the defined
     * elements, an \@id referenced from the Narrative, or extensions
     *
     * The sequence information shall be provided enumerating the amino acids from N-
     * to C-terminal end using standard single-letter amino acid codes. Uppercase shall
     * be used for L-amino acids and lowercase for D-amino acids. Transcribed
     * SubstanceProteins will always be described using the translated sequence; for
     * synthetic peptide containing amino acids that are not represented with a single
     * letter code an X should be used within the sequence. The modified amino acids
     * will be distinguished by their position in the sequence.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRAttachment $sequenceAttachment
     * @return static
     */
    public function setSequenceAttachment(FHIRAttachment $sequenceAttachment = null)
    {
        $this->sequenceAttachment = $sequenceAttachment;
        return $this;
    }

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Index of primary sequences of amino acids linked through peptide bonds in order
     * of decreasing length. Sequences of the same length will be ordered by molecular
     * weight. Subunits that have identical sequences will be repeated and have
     * sequential subscripts.
     *
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger
     */
    public function getSubunit()
    {
        return $this->subunit;
    }

    /**
     * A whole number
     * 32 bit number; for values larger than this, use decimal
     * If the element is present, it must have either a \@value, an \@id, or extensions
     *
     * Index of primary sequences of amino acids linked through peptide bonds in order
     * of decreasing length. Sequences of the same length will be ordered by molecular
     * weight. Subunits that have identical sequences will be repeated and have
     * sequential subscripts.
     *
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRInteger $subunit
     * @return static
     */
    public function setSubunit($subunit = null)
    {
        if (null === $subunit) {
            $this->subunit = null;
            return $this;
        }
        if ($subunit instanceof FHIRInteger) {
            $this->subunit = $subunit;
            return $this;
        }
        $this->subunit = new FHIRInteger($subunit);
        return $this;
    }

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

    /**
     * Validates that this type conforms to the specifications set forth for it by FHIR.  An empty array must be seen as
     * passing.
     *
     * @return array
     */
    public function _getValidationErrors()
    {
        $errs = parent::_getValidationErrors();
        $validationRules = $this->_getValidationRules();
        if (null !== ($v = $this->getCTerminalModification())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_C_TERMINAL_MODIFICATION] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getCTerminalModificationId())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_C_TERMINAL_MODIFICATION_ID] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getLength())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_LENGTH] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getNTerminalModification())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_N_TERMINAL_MODIFICATION] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getNTerminalModificationId())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_N_TERMINAL_MODIFICATION_ID] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getSequence())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_SEQUENCE] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getSequenceAttachment())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_SEQUENCE_ATTACHMENT] = $fieldErrs;
            }
        }
        if (null !== ($v = $this->getSubunit())) {
            if ([] !== ($fieldErrs = $v->_getValidationErrors())) {
                $errs[self::FIELD_SUBUNIT] = $fieldErrs;
            }
        }
        if (isset($validationRules[self::FIELD_C_TERMINAL_MODIFICATION])) {
            $v = $this->getCTerminalModification();
            foreach($validationRules[self::FIELD_C_TERMINAL_MODIFICATION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_C_TERMINAL_MODIFICATION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_C_TERMINAL_MODIFICATION])) {
                        $errs[self::FIELD_C_TERMINAL_MODIFICATION] = [];
                    }
                    $errs[self::FIELD_C_TERMINAL_MODIFICATION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_C_TERMINAL_MODIFICATION_ID])) {
            $v = $this->getCTerminalModificationId();
            foreach($validationRules[self::FIELD_C_TERMINAL_MODIFICATION_ID] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_C_TERMINAL_MODIFICATION_ID, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_C_TERMINAL_MODIFICATION_ID])) {
                        $errs[self::FIELD_C_TERMINAL_MODIFICATION_ID] = [];
                    }
                    $errs[self::FIELD_C_TERMINAL_MODIFICATION_ID][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_LENGTH])) {
            $v = $this->getLength();
            foreach($validationRules[self::FIELD_LENGTH] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_LENGTH, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_LENGTH])) {
                        $errs[self::FIELD_LENGTH] = [];
                    }
                    $errs[self::FIELD_LENGTH][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_N_TERMINAL_MODIFICATION])) {
            $v = $this->getNTerminalModification();
            foreach($validationRules[self::FIELD_N_TERMINAL_MODIFICATION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_N_TERMINAL_MODIFICATION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_N_TERMINAL_MODIFICATION])) {
                        $errs[self::FIELD_N_TERMINAL_MODIFICATION] = [];
                    }
                    $errs[self::FIELD_N_TERMINAL_MODIFICATION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_N_TERMINAL_MODIFICATION_ID])) {
            $v = $this->getNTerminalModificationId();
            foreach($validationRules[self::FIELD_N_TERMINAL_MODIFICATION_ID] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_N_TERMINAL_MODIFICATION_ID, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_N_TERMINAL_MODIFICATION_ID])) {
                        $errs[self::FIELD_N_TERMINAL_MODIFICATION_ID] = [];
                    }
                    $errs[self::FIELD_N_TERMINAL_MODIFICATION_ID][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_SEQUENCE])) {
            $v = $this->getSequence();
            foreach($validationRules[self::FIELD_SEQUENCE] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_SEQUENCE, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_SEQUENCE])) {
                        $errs[self::FIELD_SEQUENCE] = [];
                    }
                    $errs[self::FIELD_SEQUENCE][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_SEQUENCE_ATTACHMENT])) {
            $v = $this->getSequenceAttachment();
            foreach($validationRules[self::FIELD_SEQUENCE_ATTACHMENT] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_SEQUENCE_ATTACHMENT, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_SEQUENCE_ATTACHMENT])) {
                        $errs[self::FIELD_SEQUENCE_ATTACHMENT] = [];
                    }
                    $errs[self::FIELD_SEQUENCE_ATTACHMENT][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_SUBUNIT])) {
            $v = $this->getSubunit();
            foreach($validationRules[self::FIELD_SUBUNIT] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_SUBSTANCE_PROTEIN_DOT_SUBUNIT, self::FIELD_SUBUNIT, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_SUBUNIT])) {
                        $errs[self::FIELD_SUBUNIT] = [];
                    }
                    $errs[self::FIELD_SUBUNIT][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_MODIFIER_EXTENSION])) {
            $v = $this->getModifierExtension();
            foreach($validationRules[self::FIELD_MODIFIER_EXTENSION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_BACKBONE_ELEMENT, self::FIELD_MODIFIER_EXTENSION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_MODIFIER_EXTENSION])) {
                        $errs[self::FIELD_MODIFIER_EXTENSION] = [];
                    }
                    $errs[self::FIELD_MODIFIER_EXTENSION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_EXTENSION])) {
            $v = $this->getExtension();
            foreach($validationRules[self::FIELD_EXTENSION] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ELEMENT, self::FIELD_EXTENSION, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_EXTENSION])) {
                        $errs[self::FIELD_EXTENSION] = [];
                    }
                    $errs[self::FIELD_EXTENSION][$rule] = $err;
                }
            }
        }
        if (isset($validationRules[self::FIELD_ID])) {
            $v = $this->getId();
            foreach($validationRules[self::FIELD_ID] as $rule => $constraint) {
                $err = $this->_performValidation(PHPFHIRConstants::TYPE_NAME_ELEMENT, self::FIELD_ID, $rule, $constraint, $v);
                if (null !== $err) {
                    if (!isset($errs[self::FIELD_ID])) {
                        $errs[self::FIELD_ID] = [];
                    }
                    $errs[self::FIELD_ID][$rule] = $err;
                }
            }
        }
        return $errs;
    }

    /**
     * @param \SimpleXMLElement|string|null $sxe
     * @param null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIRSubstanceProtein\FHIRSubstanceProteinSubunit $type
     * @param null|int $libxmlOpts
     * @return null|\DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIRSubstanceProtein\FHIRSubstanceProteinSubunit
     */
    public static function xmlUnserialize($sxe = null, PHPFHIRTypeInterface $type = null, $libxmlOpts = 591872)
    {
        if (null === $sxe) {
            return null;
        }
        if (is_string($sxe)) {
            libxml_use_internal_errors(true);
            $sxe = new \SimpleXMLElement($sxe, $libxmlOpts, false);
            if ($sxe === false) {
                throw new \DomainException(sprintf('FHIRSubstanceProteinSubunit::xmlUnserialize - String provided is not parseable as XML: %s', implode(', ', array_map(function(\libXMLError $err) { return $err->message; }, libxml_get_errors()))));
            }
            libxml_use_internal_errors(false);
        }
        if (!($sxe instanceof \SimpleXMLElement)) {
            throw new \InvalidArgumentException(sprintf('FHIRSubstanceProteinSubunit::xmlUnserialize - $sxe value must be null, \\SimpleXMLElement, or valid XML string, %s seen', gettype($sxe)));
        }
        if (null === $type) {
            $type = new FHIRSubstanceProteinSubunit;
        } elseif (!is_object($type) || !($type instanceof FHIRSubstanceProteinSubunit)) {
            throw new \RuntimeException(sprintf(
                'FHIRSubstanceProteinSubunit::xmlUnserialize - $type must be instance of \DCarbone\PHPFHIRGenerated\R4\FHIRElement\FHIRBackboneElement\FHIRSubstanceProtein\FHIRSubstanceProteinSubunit or null, %s seen.',
                is_object($type) ? get_class($type) : gettype($type)
            ));
        }
        FHIRBackboneElement::xmlUnserialize($sxe, $type);
        $xmlNamespaces = $sxe->getDocNamespaces(false, false);
        if ([] !== $xmlNamespaces) {
            $ns = reset($xmlNamespaces);
            if (false !== $ns && '' !== $ns) {
                $type->_xmlns = $ns;
            }
        }
        $attributes = $sxe->attributes();
        $children = $sxe->children();
        if (isset($children->cTerminalModification)) {
            $type->setCTerminalModification(FHIRString::xmlUnserialize($children->cTerminalModification));
        }
        if (isset($attributes->cTerminalModification)) {
            $pt = $type->getCTerminalModification();
            if (null !== $pt) {
                $pt->setValue((string)$attributes->cTerminalModification);
            } else {
                $type->setCTerminalModification((string)$attributes->cTerminalModification);
            }
        }
        if (isset($children->cTerminalModificationId)) {
            $type->setCTerminalModificationId(FHIRIdentifier::xmlUnserialize($children->cTerminalModificationId));
        }
        if (isset($children->length)) {
            $type->setLength(FHIRInteger::xmlUnserialize($children->length));
        }
        if (isset($attributes->length)) {
            $pt = $type->getLength();
            if (null !== $pt) {
                $pt->setValue((string)$attributes->length);
            } else {
                $type->setLength((string)$attributes->length);
            }
        }
        if (isset($children->nTerminalModification)) {
            $type->setNTerminalModification(FHIRString::xmlUnserialize($children->nTerminalModification));
        }
        if (isset($attributes->nTerminalModification)) {
            $pt = $type->getNTerminalModification();
            if (null !== $pt) {
                $pt->setValue((string)$attributes->nTerminalModification);
            } else {
                $type->setNTerminalModification((string)$attributes->nTerminalModification);
            }
        }
        if (isset($children->nTerminalModificationId)) {
            $type->setNTerminalModificationId(FHIRIdentifier::xmlUnserialize($children->nTerminalModificationId));
        }
        if (isset($children->sequence)) {
            $type->setSequence(FHIRString::xmlUnserialize($children->sequence));
        }
        if (isset($attributes->sequence)) {
            $pt = $type->getSequence();
            if (null !== $pt) {
                $pt->setValue((string)$attributes->sequence);
            } else {
                $type->setSequence((string)$attributes->sequence);
            }
        }
        if (isset($children->sequenceAttachment)) {
            $type->setSequenceAttachment(FHIRAttachment::xmlUnserialize($children->sequenceAttachment));
        }
        if (isset($children->subunit)) {
            $type->setSubunit(FHIRInteger::xmlUnserialize($children->subunit));
        }
        if (isset($attributes->subunit)) {
            $pt = $type->getSubunit();
            if (null !== $pt) {
                $pt->setValue((string)$attributes->subunit);
            } else {
                $type->setSubunit((string)$attributes->subunit);
            }
        }
        return $type;
    }

    /**
     * @param null|\SimpleXMLElement $sxe
     * @param null|int $libxmlOpts
     * @return \SimpleXMLElement
     */
    public function xmlSerialize(\SimpleXMLElement $sxe = null, $libxmlOpts = 591872)
    {
        if (null === $sxe) {
            $sxe = new \SimpleXMLElement($this->_getFHIRXMLElementDefinition(), $libxmlOpts, false);
        }
        parent::xmlSerialize($sxe);
        if (null !== ($v = $this->getCTerminalModification())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_C_TERMINAL_MODIFICATION, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getCTerminalModificationId())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_C_TERMINAL_MODIFICATION_ID, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getLength())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_LENGTH, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getNTerminalModification())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_N_TERMINAL_MODIFICATION, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getNTerminalModificationId())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_N_TERMINAL_MODIFICATION_ID, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getSequence())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_SEQUENCE, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getSequenceAttachment())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_SEQUENCE_ATTACHMENT, null, $v->_getFHIRXMLNamespace()));
        }
        if (null !== ($v = $this->getSubunit())) {
            $v->xmlSerialize($sxe->addChild(self::FIELD_SUBUNIT, null, $v->_getFHIRXMLNamespace()));
        }
        return $sxe;
    }

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        $a = parent::jsonSerialize();
        if (null !== ($v = $this->getCTerminalModification())) {
            $a[self::FIELD_C_TERMINAL_MODIFICATION] = $v->getValue();
            $enc = $v->jsonSerialize();
            $cnt = count($enc);
            if (0 < $cnt && (1 !== $cnt || (1 === $cnt && !array_key_exists(FHIRString::FIELD_VALUE, $enc)))) {
                unset($enc[FHIRString::FIELD_VALUE]);
                $a[self::FIELD_C_TERMINAL_MODIFICATION_EXT] = $enc;
            }
        }
        if (null !== ($v = $this->getCTerminalModificationId())) {
            $a[self::FIELD_C_TERMINAL_MODIFICATION_ID] = $v;
        }
        if (null !== ($v = $this->getLength())) {
            $a[self::FIELD_LENGTH] = $v->getValue();
            $enc = $v->jsonSerialize();
            $cnt = count($enc);
            if (0 < $cnt && (1 !== $cnt || (1 === $cnt && !array_key_exists(FHIRInteger::FIELD_VALUE, $enc)))) {
                unset($enc[FHIRInteger::FIELD_VALUE]);
                $a[self::FIELD_LENGTH_EXT] = $enc;
            }
        }
        if (null !== ($v = $this->getNTerminalModification())) {
            $a[self::FIELD_N_TERMINAL_MODIFICATION] = $v->getValue();
            $enc = $v->jsonSerialize();
            $cnt = count($enc);
            if (0 < $cnt && (1 !== $cnt || (1 === $cnt && !array_key_exists(FHIRString::FIELD_VALUE, $enc)))) {
                unset($enc[FHIRString::FIELD_VALUE]);
                $a[self::FIELD_N_TERMINAL_MODIFICATION_EXT] = $enc;
            }
        }
        if (null !== ($v = $this->getNTerminalModificationId())) {
            $a[self::FIELD_N_TERMINAL_MODIFICATION_ID] = $v;
        }
        if (null !== ($v = $this->getSequence())) {
            $a[self::FIELD_SEQUENCE] = $v->getValue();
            $enc = $v->jsonSerialize();
            $cnt = count($enc);
            if (0 < $cnt && (1 !== $cnt || (1 === $cnt && !array_key_exists(FHIRString::FIELD_VALUE, $enc)))) {
                unset($enc[FHIRString::FIELD_VALUE]);
                $a[self::FIELD_SEQUENCE_EXT] = $enc;
            }
        }
        if (null !== ($v = $this->getSequenceAttachment())) {
            $a[self::FIELD_SEQUENCE_ATTACHMENT] = $v;
        }
        if (null !== ($v = $this->getSubunit())) {
            $a[self::FIELD_SUBUNIT] = $v->getValue();
            $enc = $v->jsonSerialize();
            $cnt = count($enc);
            if (0 < $cnt && (1 !== $cnt || (1 === $cnt && !array_key_exists(FHIRInteger::FIELD_VALUE, $enc)))) {
                unset($enc[FHIRInteger::FIELD_VALUE]);
                $a[self::FIELD_SUBUNIT_EXT] = $enc;
            }
        }
        if ([] !== ($vs = $this->_getFHIRComments())) {
            $a[PHPFHIRConstants::JSON_FIELD_FHIR_COMMENTS] = $vs;
        }
        return $a;
    }

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