Entity Factory
@param {string} id - Entity id
@param {*} spec - Entity Specification
@return {RenderTemplate} RenderTemplate Instance
979279
function create (id, spec) {
  // create an entity instance
  const entity = new RenderTemplate()
  entity.spec = spec
  // set/create template from spec.template value
  entity.template = _.template(_.defaultTo(spec.template, ''))
  return entity
}
790195
function describe(id, callback) {
    if (id == undefined)
      return callback(new TypeError("'id' can't be null or undefined"))

    var mediaObject = objects[id];
    if (mediaObject) return callback(null, mediaObject);

    var params = {
      object: id
    };

    function callback2(error, result) {
      if (error) return callback(error);

      var mediaObject = mediaObjectCreator.createInmediate(result);

      return callback(null, registerObject(mediaObject, id));
    }

    encode('describe', params, callback2);
  }
662891
function create (id, spec) {
  validateModifiers(id, spec, ['schema', 'options'])

  const entity = {}
  entity.spec = spec
  entity.schema = deepFreeze(_.defaultTo(spec.schema, {}))
  entity.options = deepFreeze(_.defaultTo(spec.options, {}))

  validateSchema(entity.schema, entity.options)
  return entity
}
493228
@SuppressWarnings("unchecked")
    public <T extends AbstractJaxb> T getById(String id) {
        Object obj = GetByIdUtil.getById(id, this);
        return (T) obj;
    }
425166
@Override
	@Transactional
	public String getResource(String id)
	{
		final TemplateCall call = templater.template("resource_template");

		final ResourceTemplateEntity entity = resourceProvisionService.getOrCreateTemplate(id);

		if (entity == null)
			throw new RestException(404, "No such resource with id: " + id);

		call.set("entity", entity);
		call.set("nonce", nonceStore.getValue());

		return call.process();
	}
629922
private static SingleID specsToSpecialInverse(Specs specs) {
        if (!specs.source.equalsIgnoreCase(ANY)) {
            return null;
        }
        String inverseTarget = SPECIAL_INVERSES.get(new CaseInsensitiveString(specs.target));
        if (inverseTarget != null) {
            // If the original ID contained "Any-" then make the
            // special inverse "Any-Foo"; otherwise make it "Foo".
            // So "Any-NFC" => "Any-NFD" but "NFC" => "NFD".
            StringBuilder buf = new StringBuilder();
            if (specs.filter != null) {
                buf.append(specs.filter);
            }
            if (specs.sawSource) {
                buf.append(ANY).append(TARGET_SEP);
            }
            buf.append(inverseTarget);

            String basicID = ANY + TARGET_SEP + inverseTarget;

            if (specs.variant != null) {
                buf.append(VARIANT_SEP).append(specs.variant);
                basicID = basicID + VARIANT_SEP + specs.variant;
            }
            return new SingleID(buf.toString(), basicID);
        }
        return null;
    }
349067
public static function factory ($id)
    {
        // Which class to instantiate
        $entityClassName = get_called_class();

        // Get object cache registry
        $ObjectRegistry  = \Teon\ObjectRegistry\ObjectRegistry::getInstance();

        // If this object already in cache, use that
        if ($ObjectRegistry->exists($entityClassName, $id)) {
            return $ObjectRegistry->get($entityClassName, $id);
        }

        // If not, instantiate new, store in object registry and return it
        $Object = new $entityClassName($id);
        $ObjectRegistry->store($Object);
        return $Object;
    }
1371196
public Object loadById(Class entity, Serializable id) throws Exception  {
		return getHibernateTemplate().load(entity, id);
	}
199939
function Resource(spec, options) {
  if (!(this instanceof Resource)) {
    return new Resource(spec, options);
  }

  if (typeof spec !== 'object') {
    throw new Error('resource spec must be an object');
  }

  debug('create resource %s', spec.path, spec);

  this.spec = spec;
  this.list = [];
  this.options = options || {};

  this.middleware = {};
  this.operations = {};
}
393864
public <T extends Entity> T byID(Class<T> clazz, AssetID id) {
        return instance.getWrapperManager().create(clazz, id, true);
    }
591171
function create (id, spec) {
  validateModifiers(id, spec, ['select'])
  const entity = {}
  entity.spec = spec
  entity.select = parseSwitch(spec)
  return entity
}
1285938
function modTryInvokeFactory(id) {
        var mod = modModules[id];

        if (mod && mod.invokeFactory) {
            mod.invokeFactory();
        }
    }
868124
function modTryInvokeFactory( id ) {
        var module = modModules[ id ];

        if ( module && module.invokeFactory ) {
            module.invokeFactory();
        }
    }
605875
public Response getTemplate(String id) throws RequestException, LocalOperationException {
        Request request = new Request(this);
        return new Response(request.get("/templates/" + id));
    }
483522
function parameters(spec, paramType) {
  spec = lodash.cloneDeep(spec);

  var schema = {
    type: 'object',
    properties: {},
    required: [],
  };

  spec.parameters.forEach(function(parameter) {
    // only get rules for current paramType
    if (parameter.paramType !== paramType) return;

    // create current property
    var property = schema.properties[parameter.name] = {
      type: parameter.type,
    };

    switch (parameter.type) {
    case 'integer':
      property.type = parameter.type;

      ['minimum', 'maximum'].forEach(function(key) {
        if (parameter.hasOwnProperty(key)) {
          property[key] = parseInt(parameter[key], 10);
        }
      });

      break;
    case 'number':
      property.type = parameter.type;

      break;
    case 'string':
      property.type = parameter.type;

      if (parameter.hasOwnProperty('minimum')) {
        property.minLength = parseInt(parameter.minimum, 10);
      }

      if (parameter.hasOwnProperty('maximum')) {
        property.maxLength = parseInt(parameter.maximum, 10);
      }

      if (parameter.hasOwnProperty('format')) {
        property.format = parameter.format;
      }

      break;
    case 'boolean':
      property.type = parameter.type;

      break;
    case 'array':
      property.type = parameter.type;
      property.items = parameter.items;

      if (parameter.uniqueItems) property.uniqueItems = true;

      if (parameter.hasOwnProperty('minItems')) {
        property.minItems = parameter.minItems;
      }

      if (parameter.hasOwnProperty('maxItems')) {
        property.maxItems = parameter.maxItems;
      }

      break;
    default:
      if (paramType === 'body') {
        property.$ref = parameter.type;
        lodash.keys(property).forEach(function(key) {
          if (key !== '$ref') delete property[key];
        });
      } else {
        throw new Error('unknown type: ' + parameter.type);
      }
    }

    if (Array.isArray(parameter.enum)) {
      property.enum = parameter.enum;
    }

    var hasDefault = parameter.hasOwnProperty('defaultValue');

    if (hasDefault) {
      property.default = parameter.defaultValue;
    }

    // path rules are implicitly required
    if (!hasDefault && (parameter.required || paramType === 'path')) {
      schema.required.push(parameter.name);
    }

    // convert to items if allowMultiple
    if (parameter.allowMultiple &&
        constants.allowMultiple.indexOf(parameter.paramType) >= 0) {
      var schemaProperty = schema.properties[parameter.name] = {
        type: 'array',
        items: property,
      };

      if (parameter.uniqueItems) schemaProperty.uniqueItems = true;

      if (parameter.hasOwnProperty('minItems')) {
        schemaProperty.minItems = parameter.minItems;
      }

      if (parameter.hasOwnProperty('maxItems')) {
        schemaProperty.maxItems = parameter.maxItems;
      }
    }
  });

  if (!schema.required.length) delete schema.required;

  if (lodash.isEmpty(schema.properties)) return;

  return schema;
}
51253
function fixturizeEntityId (entityIdsMap, entityName, id) {
  if (!entityIdsMap[entityName]) {
    entityIdsMap[entityName] = {}
  }

  const map = entityIdsMap[entityName]

  // Do nothing if the passed id is already set
  if (map[id]) {
    return map[id]
  }

  // Do nothing if passed id is a normalized one
  const check = parseInt(id, 10)
  if (Object.values(map).includes(check)) {
    return check
  }

  // Otherwise calculate the new id and set it on the passed state map.
  // IDs start at 1000 to differentiate from issue/PR numbers
  const counter = Object.keys(map).length + 1000
  map[id] = counter

  // return the new id
  return map[id]
}
1012228
private Tag entityToTag(String id, Entity tagEntity) {
    Tag tag = tagFactory.create(id);
    tag.setObjectIri(tagEntity.getString(EMX_TAG_OBJECT_IRI));
    tag.setLabel(tagEntity.getString(EMX_TAG_LABEL));
    tag.setRelationLabel(tagEntity.getString(EMX_TAG_RELATION_LABEL));
    tag.setCodeSystem(tagEntity.getString(EMX_TAG_CODE_SYSTEM));
    tag.setRelationIri(tagEntity.getString(EMX_TAG_RELATION_IRI));

    return tag;
  }