Creates a new resource with a self link to the given id.

@param entity must not be {@literal null}.
@param id must not be {@literal null}.
@return
195367
protected D createModelWithId(Object id, T entity) {
		return createModelWithId(id, entity, new Object[0]);
	}
670671
public User withId(final long id) {
      return new User(id, username, displayName, slug, email, createTimestamp, url, metadata);
   }
12625
public static JsonLongDocument create(String id, Long content) {
        return new JsonLongDocument(id, 0, content, 0, null);
    }
908716
public void setId(String id)
	{
		if (id == null || id.length() == 0)
			throw new IllegalArgumentException(
			"id required in setId");

		this.setId(Integer.valueOf(id));
	}
710928
public <T extends MPBase> T getById(String id) throws MPException {
        T resource = null;
        for (int i = 0; i < _resourceArray.size(); i++) {
            resource = getByIndex(i);
            try {
                Field field = resource.getClass().getDeclaredField("id");
                field.setAccessible(true);
                String resourceId = field.get(resource).toString();
                if (resourceId.equals(id)) {
                    break;
                }
            } catch (Exception exception) {
                throw new MPException(exception);
            }
        }
        return resource;
    }
1359621
public static <S extends RepresentationModel<?>> HeaderLinksResponseEntity<S> wrap(HttpEntity<S> entity) {

		Assert.notNull(entity, "Given HttpEntity must not be null!");

		if (entity instanceof ResponseEntity) {
			return new HeaderLinksResponseEntity<>((ResponseEntity<S>) entity);
		} else {
			return new HeaderLinksResponseEntity<>(entity);
		}
	}
690668
public E findById(ID id) {
        LOG.trace("Finding " + entityClass.getSimpleName() + " with ID " + id);
        return (E) getSession().get(entityClass, id);
    }
666177
@PostMapping(
      value = "/{entityTypeId}/{id}",
      params = "_method=GET",
      produces = APPLICATION_JSON_VALUE)
  @ResponseBody
  public Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @Valid @RequestBody EntityTypeRequest request) {
    Set<String> attributesSet = toAttributeSet(request != null ? request.getAttributes() : null);
    Map<String, Set<String>> attributeExpandSet =
        toExpandMap(request != null ? request.getExpand() : null);

    EntityType meta = dataService.getEntityType(entityTypeId);
    Object id = getTypedValue(untypedId, meta.getIdAttribute());
    Entity entity = dataService.findOneById(entityTypeId, id);

    if (entity == null) {
      throw new UnknownEntityException(meta, untypedId);
    }

    return getEntityAsMap(entity, meta, attributesSet, attributeExpandSet);
  }
445446
public Permalink get(String id) {
        for (Permalink p : this)
            if(p.getId().equals(id))
                return p;
        return null;
    }
367210
public Object newInstanceWithId(final Object id)
	{
		try
		{
			final Object o = clazz.newInstance();

			idProperty.set(o, id);

			return o;
		}
		catch (Throwable e)
		{
			throw new RuntimeException("Cannot create new instance of " +
			                           clazz +
			                           " with ID " +
			                           id +
			                           " (of type " +
			                           id.getClass() +
			                           ") populated!", e);
		}
	}
714275
public Map<String, Object> loadById(String id) {
        final String sid = sessionPrefix + ":" + id;
        try {
            return this.executor.execute(new RedisCallback<Map<String, Object>>() {
                public Map<String, Object> execute(Jedis jedis) {
                    String session = jedis.get(sid);
                    if (!Strings.isNullOrEmpty(session)) {
                        return serializer.deserialize(session);
                    }
                    return Collections.emptyMap();
                }
            });
        } catch (Exception e) {
            log.error("failed to load session(key={}), cause:{}", sid, Throwables.getStackTraceAsString(e));
            throw new SessionException("load session failed", e);
        }
    }
147983
public Resource getZanataResource(final String id) throws NotModifiedException {
        ClientResponse<Resource> response = null;
        try {
            final ISourceDocResource client = proxyFactory.getSourceDocResource(details.getProject(), details.getVersion());
            response = client.getResource(id, null);

            final Status status = Response.Status.fromStatusCode(response.getStatus());

            if (status == Response.Status.OK) {
                final Resource entity = response.getEntity();
                return entity;
            } else if (status == Status.NOT_MODIFIED) {
                throw new NotModifiedException();
            }
        } catch (final Exception ex) {
            if (ex instanceof NotModifiedException) {
                throw (NotModifiedException) ex;
            } else {
                log.error("Failed to retrieve the Zanata Source Document", ex);
            }
        } finally {
            /*
             * If you are using RESTEasy client framework, and returning a Response from your service method, you will
             * explicitly need to release the connection.
             */
            if (response != null) response.releaseConnection();
            
            /* Perform a small wait to ensure zanata isn't overloaded */
            performZanataRESTCallWaiting();
        }

        return null;
    }
540238
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
        BasicHttpEntity entity = new BasicHttpEntity();
        InputStream inputStream;
        try {
            inputStream = connection.getInputStream();
        } catch (IOException ioe) {
            inputStream = connection.getErrorStream();
        }
        entity.setContent(inputStream);
        entity.setContentLength(connection.getContentLength());
        entity.setContentEncoding(connection.getContentEncoding());
        entity.setContentType(connection.getContentType());
        return entity;
    }
956466
def request_entity_create(self, lid, epId=None):
        
        lid = Validation.lid_check_convert(lid)
        if epId is None:
            epId = self.__epId
        elif epId is False:
            epId = None
        else:
            epId = Validation.guid_check_convert(epId)
        logger.debug("request_entity_create lid='%s'", lid)
        return self._request(R_ENTITY, C_CREATE, None, {'epId': epId, 'lid': lid}, is_crud=True)
1122199
private function createEntityID(string $id): EntityID
    {
        return new EntityID($this->entityManager, $this->className, $id);
    }
588026
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ResponseEntity<E> findById(@PathVariable Integer id) {

        try {
            E entity = this.service.findById(id);
            LOG.trace("Found " + entity.getClass().getSimpleName()
                + " with ID " + entity.getId());
            return new ResponseEntity<E>(entity, HttpStatus.OK);
        } catch (Exception e) {
            LOG.error("Error finding entity with id " + id + ": "
                + e.getMessage());
            return new ResponseEntity<E>(HttpStatus.NOT_FOUND);
        }
    }
419500
@NonNull
  public RequestCreator load(@DrawableRes int resourceId) {
    if (resourceId == 0) {
      throw new IllegalArgumentException("Resource ID must not be zero.");
    }
    return new RequestCreator(this, null, resourceId);
  }