repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Asana/java-asana | src/main/java/com/asana/resources/gen/WebhooksBase.java | WebhooksBase.getById | public ItemRequest<Webhook> getById(String webhook) {
String path = String.format("/webhooks/%s", webhook);
return new ItemRequest<Webhook>(this, Webhook.class, path, "GET");
} | java | public ItemRequest<Webhook> getById(String webhook) {
String path = String.format("/webhooks/%s", webhook);
return new ItemRequest<Webhook>(this, Webhook.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Webhook",
">",
"getById",
"(",
"String",
"webhook",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/webhooks/%s\"",
",",
"webhook",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Webhook",
">",
"(",
"this"... | Returns the full record for the given webhook.
@param webhook The webhook to get.
@return Request object | [
"Returns",
"the",
"full",
"record",
"for",
"the",
"given",
"webhook",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WebhooksBase.java#L104-L108 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/WebhooksBase.java | WebhooksBase.deleteById | public ItemRequest<Webhook> deleteById(String webhook) {
String path = String.format("/webhooks/%s", webhook);
return new ItemRequest<Webhook>(this, Webhook.class, path, "DELETE");
} | java | public ItemRequest<Webhook> deleteById(String webhook) {
String path = String.format("/webhooks/%s", webhook);
return new ItemRequest<Webhook>(this, Webhook.class, path, "DELETE");
} | [
"public",
"ItemRequest",
"<",
"Webhook",
">",
"deleteById",
"(",
"String",
"webhook",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/webhooks/%s\"",
",",
"webhook",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Webhook",
">",
"(",
"th... | This method permanently removes a webhook. Note that it may be possible
to receive a request that was already in flight after deleting the
webhook, but no further requests will be issued.
@param webhook The webhook to delete.
@return Request object | [
"This",
"method",
"permanently",
"removes",
"a",
"webhook",
".",
"Note",
"that",
"it",
"may",
"be",
"possible",
"to",
"receive",
"a",
"request",
"that",
"was",
"already",
"in",
"flight",
"after",
"deleting",
"the",
"webhook",
"but",
"no",
"further",
"request... | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WebhooksBase.java#L118-L122 | train |
Asana/java-asana | src/main/java/com/asana/resources/Events.java | Events.get | public EventsRequest<Event> get(String resource, String sync) {
return new EventsRequest<Event>(this, Event.class, "/events", "GET")
.query("resource", resource)
.query("sync", sync);
} | java | public EventsRequest<Event> get(String resource, String sync) {
return new EventsRequest<Event>(this, Event.class, "/events", "GET")
.query("resource", resource)
.query("sync", sync);
} | [
"public",
"EventsRequest",
"<",
"Event",
">",
"get",
"(",
"String",
"resource",
",",
"String",
"sync",
")",
"{",
"return",
"new",
"EventsRequest",
"<",
"Event",
">",
"(",
"this",
",",
"Event",
".",
"class",
",",
"\"/events\"",
",",
"\"GET\"",
")",
".",
... | Returns any events for the given resource ID since the last sync token
@param resource Globally unique identifier for the resource.
@param sync Sync token provided by a previous call to the events API
@return Request object | [
"Returns",
"any",
"events",
"for",
"the",
"given",
"resource",
"ID",
"since",
"the",
"last",
"sync",
"token"
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/Events.java#L20-L24 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java | ProjectMembershipsBase.findByProject | public CollectionRequest<ProjectMembership> findByProject(String project) {
String path = String.format("/projects/%s/project_memberships", project);
return new CollectionRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET");
} | java | public CollectionRequest<ProjectMembership> findByProject(String project) {
String path = String.format("/projects/%s/project_memberships", project);
return new CollectionRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"ProjectMembership",
">",
"findByProject",
"(",
"String",
"project",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/projects/%s/project_memberships\"",
",",
"project",
")",
";",
"return",
"new",
"CollectionRequ... | Returns the compact project membership records for the project.
@param project The project for which to fetch memberships.
@return Request object | [
"Returns",
"the",
"compact",
"project",
"membership",
"records",
"for",
"the",
"project",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java#L29-L33 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java | ProjectMembershipsBase.findById | public ItemRequest<ProjectMembership> findById(String projectMembership) {
String path = String.format("/project_memberships/%s", projectMembership);
return new ItemRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET");
} | java | public ItemRequest<ProjectMembership> findById(String projectMembership) {
String path = String.format("/project_memberships/%s", projectMembership);
return new ItemRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"ProjectMembership",
">",
"findById",
"(",
"String",
"projectMembership",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/project_memberships/%s\"",
",",
"projectMembership",
")",
";",
"return",
"new",
"ItemRequest",
... | Returns the project membership record.
@param projectMembership Globally unique identifier for the project membership.
@return Request object | [
"Returns",
"the",
"project",
"membership",
"record",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java#L41-L45 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/StoriesBase.java | StoriesBase.findByTask | public CollectionRequest<Story> findByTask(String task) {
String path = String.format("/tasks/%s/stories", task);
return new CollectionRequest<Story>(this, Story.class, path, "GET");
} | java | public CollectionRequest<Story> findByTask(String task) {
String path = String.format("/tasks/%s/stories", task);
return new CollectionRequest<Story>(this, Story.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Story",
">",
"findByTask",
"(",
"String",
"task",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/tasks/%s/stories\"",
",",
"task",
")",
";",
"return",
"new",
"CollectionRequest",
"<",
"Story",
">",
"("... | Returns the compact records for all stories on the task.
@param task Globally unique identifier for the task.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"stories",
"on",
"the",
"task",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L32-L36 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/StoriesBase.java | StoriesBase.findById | public ItemRequest<Story> findById(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "GET");
} | java | public ItemRequest<Story> findById(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Story",
">",
"findById",
"(",
"String",
"story",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/stories/%s\"",
",",
"story",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Story",
">",
"(",
"this",
",",... | Returns the full record for a single story.
@param story Globally unique identifier for the story.
@return Request object | [
"Returns",
"the",
"full",
"record",
"for",
"a",
"single",
"story",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L44-L48 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/StoriesBase.java | StoriesBase.update | public ItemRequest<Story> update(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "PUT");
} | java | public ItemRequest<Story> update(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "PUT");
} | [
"public",
"ItemRequest",
"<",
"Story",
">",
"update",
"(",
"String",
"story",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/stories/%s\"",
",",
"story",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Story",
">",
"(",
"this",
",",
... | Updates the story and returns the full record for the updated story.
Only comment stories can have their text updated, and only comment stories and
attachment stories can be pinned. Only one of `text` and `html_text` can be specified.
@param story Globally unique identifier for the story.
@return Request object | [
"Updates",
"the",
"story",
"and",
"returns",
"the",
"full",
"record",
"for",
"the",
"updated",
"story",
".",
"Only",
"comment",
"stories",
"can",
"have",
"their",
"text",
"updated",
"and",
"only",
"comment",
"stories",
"and",
"attachment",
"stories",
"can",
... | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L74-L78 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/StoriesBase.java | StoriesBase.delete | public ItemRequest<Story> delete(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "DELETE");
} | java | public ItemRequest<Story> delete(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "DELETE");
} | [
"public",
"ItemRequest",
"<",
"Story",
">",
"delete",
"(",
"String",
"story",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/stories/%s\"",
",",
"story",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Story",
">",
"(",
"this",
",",
... | Deletes a story. A user can only delete stories they have created. Returns an empty data record.
@param story Globally unique identifier for the story.
@return Request object | [
"Deletes",
"a",
"story",
".",
"A",
"user",
"can",
"only",
"delete",
"stories",
"they",
"have",
"created",
".",
"Returns",
"an",
"empty",
"data",
"record",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L86-L90 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/WorkspacesBase.java | WorkspacesBase.findById | public ItemRequest<Workspace> findById(String workspace) {
String path = String.format("/workspaces/%s", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "GET");
} | java | public ItemRequest<Workspace> findById(String workspace) {
String path = String.format("/workspaces/%s", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Workspace",
">",
"findById",
"(",
"String",
"workspace",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/workspaces/%s\"",
",",
"workspace",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Workspace",
">",
"(... | Returns the full workspace record for a single workspace.
@param workspace Globally unique identifier for the workspace or organization.
@return Request object | [
"Returns",
"the",
"full",
"workspace",
"record",
"for",
"a",
"single",
"workspace",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L39-L43 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/WorkspacesBase.java | WorkspacesBase.update | public ItemRequest<Workspace> update(String workspace) {
String path = String.format("/workspaces/%s", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "PUT");
} | java | public ItemRequest<Workspace> update(String workspace) {
String path = String.format("/workspaces/%s", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "PUT");
} | [
"public",
"ItemRequest",
"<",
"Workspace",
">",
"update",
"(",
"String",
"workspace",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/workspaces/%s\"",
",",
"workspace",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Workspace",
">",
"(",... | A specific, existing workspace can be updated by making a PUT request on
the URL for that workspace. Only the fields provided in the data block
will be updated; any unspecified fields will remain unchanged.
Currently the only field that can be modified for a workspace is its `name`.
Returns the complete, updated workspace record.
@param workspace The workspace to update.
@return Request object | [
"A",
"specific",
"existing",
"workspace",
"can",
"be",
"updated",
"by",
"making",
"a",
"PUT",
"request",
"on",
"the",
"URL",
"for",
"that",
"workspace",
".",
"Only",
"the",
"fields",
"provided",
"in",
"the",
"data",
"block",
"will",
"be",
"updated",
";",
... | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L67-L71 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/WorkspacesBase.java | WorkspacesBase.addUser | public ItemRequest<Workspace> addUser(String workspace) {
String path = String.format("/workspaces/%s/addUser", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "POST");
} | java | public ItemRequest<Workspace> addUser(String workspace) {
String path = String.format("/workspaces/%s/addUser", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Workspace",
">",
"addUser",
"(",
"String",
"workspace",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/workspaces/%s/addUser\"",
",",
"workspace",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Workspace",
">... | The user can be referenced by their globally unique user ID or their email address.
Returns the full user record for the invited user.
@param workspace The workspace or organization to invite the user to.
@return Request object | [
"The",
"user",
"can",
"be",
"referenced",
"by",
"their",
"globally",
"unique",
"user",
"ID",
"or",
"their",
"email",
"address",
".",
"Returns",
"the",
"full",
"user",
"record",
"for",
"the",
"invited",
"user",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L96-L100 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/WorkspacesBase.java | WorkspacesBase.removeUser | public ItemRequest<Workspace> removeUser(String workspace) {
String path = String.format("/workspaces/%s/removeUser", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "POST");
} | java | public ItemRequest<Workspace> removeUser(String workspace) {
String path = String.format("/workspaces/%s/removeUser", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Workspace",
">",
"removeUser",
"(",
"String",
"workspace",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/workspaces/%s/removeUser\"",
",",
"workspace",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Workspace"... | The user making this call must be an admin in the workspace.
Returns an empty data record.
@param workspace The workspace or organization to invite the user to.
@return Request object | [
"The",
"user",
"making",
"this",
"call",
"must",
"be",
"an",
"admin",
"in",
"the",
"workspace",
".",
"Returns",
"an",
"empty",
"data",
"record",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L109-L113 | train |
Asana/java-asana | src/main/java/com/asana/resources/Attachments.java | Attachments.createOnTask | public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) {
MultipartContent.Part part = new MultipartContent.Part()
.setContent(new InputStreamContent(fileType, fileContent))
.setHeaders(new HttpHeaders().set(
"Content-Disposition",
String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName?
));
MultipartContent content = new MultipartContent()
.setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString()))
.addPart(part);
String path = String.format("/tasks/%s/attachments", task);
return new ItemRequest<Attachment>(this, Attachment.class, path, "POST")
.data(content);
} | java | public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) {
MultipartContent.Part part = new MultipartContent.Part()
.setContent(new InputStreamContent(fileType, fileContent))
.setHeaders(new HttpHeaders().set(
"Content-Disposition",
String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName?
));
MultipartContent content = new MultipartContent()
.setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString()))
.addPart(part);
String path = String.format("/tasks/%s/attachments", task);
return new ItemRequest<Attachment>(this, Attachment.class, path, "POST")
.data(content);
} | [
"public",
"ItemRequest",
"<",
"Attachment",
">",
"createOnTask",
"(",
"String",
"task",
",",
"InputStream",
"fileContent",
",",
"String",
"fileName",
",",
"String",
"fileType",
")",
"{",
"MultipartContent",
".",
"Part",
"part",
"=",
"new",
"MultipartContent",
".... | Upload a file and attach it to a task
@param task Globally unique identifier for the task.
@param fileContent Content of the file to be uploaded
@param fileName Name of the file to be uploaded
@param fileType MIME type of the file to be uploaded
@return Request object | [
"Upload",
"a",
"file",
"and",
"attach",
"it",
"to",
"a",
"task"
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/Attachments.java#L29-L43 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/OrganizationExportsBase.java | OrganizationExportsBase.findById | public ItemRequest<OrganizationExport> findById(String organizationExport) {
String path = String.format("/organization_exports/%s", organizationExport);
return new ItemRequest<OrganizationExport>(this, OrganizationExport.class, path, "GET");
} | java | public ItemRequest<OrganizationExport> findById(String organizationExport) {
String path = String.format("/organization_exports/%s", organizationExport);
return new ItemRequest<OrganizationExport>(this, OrganizationExport.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"OrganizationExport",
">",
"findById",
"(",
"String",
"organizationExport",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/organization_exports/%s\"",
",",
"organizationExport",
")",
";",
"return",
"new",
"ItemReques... | Returns details of a previously-requested Organization export.
@param organizationExport Globally unique identifier for the Organization export.
@return Request object | [
"Returns",
"details",
"of",
"a",
"previously",
"-",
"requested",
"Organization",
"export",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/OrganizationExportsBase.java#L37-L41 | train |
Asana/java-asana | src/main/java/com/asana/requests/Request.java | Request.option | public Request option(String key, Object value) {
this.options.put(key, value);
return this;
} | java | public Request option(String key, Object value) {
this.options.put(key, value);
return this;
} | [
"public",
"Request",
"option",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"this",
".",
"options",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets a client option per-request
@param key Option name
@param value Option value
@return The request itself | [
"Sets",
"a",
"client",
"option",
"per",
"-",
"request"
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/requests/Request.java#L114-L117 | train |
Asana/java-asana | src/main/java/com/asana/requests/Request.java | Request.header | public Request header(String key, String value) {
this.headers.put(key, value);
return this;
} | java | public Request header(String key, String value) {
this.headers.put(key, value);
return this;
} | [
"public",
"Request",
"header",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"this",
".",
"headers",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets a header per-request
@param key Header key
@param value Header value
@return The request itself | [
"Sets",
"a",
"header",
"per",
"-",
"request"
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/requests/Request.java#L126-L129 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/AttachmentsBase.java | AttachmentsBase.findById | public ItemRequest<Attachment> findById(String attachment) {
String path = String.format("/attachments/%s", attachment);
return new ItemRequest<Attachment>(this, Attachment.class, path, "GET");
} | java | public ItemRequest<Attachment> findById(String attachment) {
String path = String.format("/attachments/%s", attachment);
return new ItemRequest<Attachment>(this, Attachment.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Attachment",
">",
"findById",
"(",
"String",
"attachment",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/attachments/%s\"",
",",
"attachment",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Attachment",
">",... | Returns the full record for a single attachment.
@param attachment Globally unique identifier for the attachment.
@return Request object | [
"Returns",
"the",
"full",
"record",
"for",
"a",
"single",
"attachment",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/AttachmentsBase.java#L28-L32 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/AttachmentsBase.java | AttachmentsBase.findByTask | public CollectionRequest<Attachment> findByTask(String task) {
String path = String.format("/tasks/%s/attachments", task);
return new CollectionRequest<Attachment>(this, Attachment.class, path, "GET");
} | java | public CollectionRequest<Attachment> findByTask(String task) {
String path = String.format("/tasks/%s/attachments", task);
return new CollectionRequest<Attachment>(this, Attachment.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Attachment",
">",
"findByTask",
"(",
"String",
"task",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/tasks/%s/attachments\"",
",",
"task",
")",
";",
"return",
"new",
"CollectionRequest",
"<",
"Attachment"... | Returns the compact records for all attachments on the task.
@param task Globally unique identifier for the task.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"attachments",
"on",
"the",
"task",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/AttachmentsBase.java#L40-L44 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/SectionsBase.java | SectionsBase.createInProject | public ItemRequest<Section> createInProject(String project) {
String path = String.format("/projects/%s/sections", project);
return new ItemRequest<Section>(this, Section.class, path, "POST");
} | java | public ItemRequest<Section> createInProject(String project) {
String path = String.format("/projects/%s/sections", project);
return new ItemRequest<Section>(this, Section.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Section",
">",
"createInProject",
"(",
"String",
"project",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/projects/%s/sections\"",
",",
"project",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Section",
">"... | Creates a new section in a project.
Returns the full record of the newly created section.
@param project The project to create the section in
@return Request object | [
"Creates",
"a",
"new",
"section",
"in",
"a",
"project",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L30-L34 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/SectionsBase.java | SectionsBase.findByProject | public CollectionRequest<Section> findByProject(String project) {
String path = String.format("/projects/%s/sections", project);
return new CollectionRequest<Section>(this, Section.class, path, "GET");
} | java | public CollectionRequest<Section> findByProject(String project) {
String path = String.format("/projects/%s/sections", project);
return new CollectionRequest<Section>(this, Section.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Section",
">",
"findByProject",
"(",
"String",
"project",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/projects/%s/sections\"",
",",
"project",
")",
";",
"return",
"new",
"CollectionRequest",
"<",
"Secti... | Returns the compact records for all sections in the specified project.
@param project The project to get sections from.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"sections",
"in",
"the",
"specified",
"project",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L42-L46 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/SectionsBase.java | SectionsBase.findById | public ItemRequest<Section> findById(String section) {
String path = String.format("/sections/%s", section);
return new ItemRequest<Section>(this, Section.class, path, "GET");
} | java | public ItemRequest<Section> findById(String section) {
String path = String.format("/sections/%s", section);
return new ItemRequest<Section>(this, Section.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Section",
">",
"findById",
"(",
"String",
"section",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/sections/%s\"",
",",
"section",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Section",
">",
"(",
"this... | Returns the complete record for a single section.
@param section The section to get.
@return Request object | [
"Returns",
"the",
"complete",
"record",
"for",
"a",
"single",
"section",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L54-L58 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/SectionsBase.java | SectionsBase.delete | public ItemRequest<Section> delete(String section) {
String path = String.format("/sections/%s", section);
return new ItemRequest<Section>(this, Section.class, path, "DELETE");
} | java | public ItemRequest<Section> delete(String section) {
String path = String.format("/sections/%s", section);
return new ItemRequest<Section>(this, Section.class, path, "DELETE");
} | [
"public",
"ItemRequest",
"<",
"Section",
">",
"delete",
"(",
"String",
"section",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/sections/%s\"",
",",
"section",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Section",
">",
"(",
"this",... | A specific, existing section can be deleted by making a DELETE request
on the URL for that section.
Note that sections must be empty to be deleted.
The last remaining section in a board view cannot be deleted.
Returns an empty data block.
@param section The section to delete.
@return Request object | [
"A",
"specific",
"existing",
"section",
"can",
"be",
"deleted",
"by",
"making",
"a",
"DELETE",
"request",
"on",
"the",
"URL",
"for",
"that",
"section",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L94-L98 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/SectionsBase.java | SectionsBase.insertInProject | public ItemRequest<Section> insertInProject(String project) {
String path = String.format("/projects/%s/sections/insert", project);
return new ItemRequest<Section>(this, Section.class, path, "POST");
} | java | public ItemRequest<Section> insertInProject(String project) {
String path = String.format("/projects/%s/sections/insert", project);
return new ItemRequest<Section>(this, Section.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Section",
">",
"insertInProject",
"(",
"String",
"project",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/projects/%s/sections/insert\"",
",",
"project",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Section"... | Move sections relative to each other in a board view. One of
`before_section` or `after_section` is required.
Sections cannot be moved between projects.
At this point in time, moving sections is not supported in list views, only board views.
Returns an empty data block.
@param project The project in which to reorder the given section
@return Request object | [
"Move",
"sections",
"relative",
"to",
"each",
"other",
"in",
"a",
"board",
"view",
".",
"One",
"of",
"before_section",
"or",
"after_section",
"is",
"required",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L113-L117 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.findById | public ItemRequest<Team> findById(String team) {
String path = String.format("/teams/%s", team);
return new ItemRequest<Team>(this, Team.class, path, "GET");
} | java | public ItemRequest<Team> findById(String team) {
String path = String.format("/teams/%s", team);
return new ItemRequest<Team>(this, Team.class, path, "GET");
} | [
"public",
"ItemRequest",
"<",
"Team",
">",
"findById",
"(",
"String",
"team",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/teams/%s\"",
",",
"team",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Team",
">",
"(",
"this",
",",
"Te... | Returns the full record for a single team.
@param team Globally unique identifier for the team.
@return Request object | [
"Returns",
"the",
"full",
"record",
"for",
"a",
"single",
"team",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L27-L31 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.findByOrganization | public CollectionRequest<Team> findByOrganization(String organization) {
String path = String.format("/organizations/%s/teams", organization);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | java | public CollectionRequest<Team> findByOrganization(String organization) {
String path = String.format("/organizations/%s/teams", organization);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Team",
">",
"findByOrganization",
"(",
"String",
"organization",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/organizations/%s/teams\"",
",",
"organization",
")",
";",
"return",
"new",
"CollectionRequest",
... | Returns the compact records for all teams in the organization visible to
the authorized user.
@param organization Globally unique identifier for the workspace or organization.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"teams",
"in",
"the",
"organization",
"visible",
"to",
"the",
"authorized",
"user",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L40-L44 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.findByUser | public CollectionRequest<Team> findByUser(String user) {
String path = String.format("/users/%s/teams", user);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | java | public CollectionRequest<Team> findByUser(String user) {
String path = String.format("/users/%s/teams", user);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Team",
">",
"findByUser",
"(",
"String",
"user",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/users/%s/teams\"",
",",
"user",
")",
";",
"return",
"new",
"CollectionRequest",
"<",
"Team",
">",
"(",
... | Returns the compact records for all teams to which user is assigned.
@param user An identifier for the user. Can be one of an email address,
the globally unique identifier for the user, or the keyword `me`
to indicate the current user making the request.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"teams",
"to",
"which",
"user",
"is",
"assigned",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L54-L58 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.users | public CollectionRequest<Team> users(String team) {
String path = String.format("/teams/%s/users", team);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | java | public CollectionRequest<Team> users(String team) {
String path = String.format("/teams/%s/users", team);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | [
"public",
"CollectionRequest",
"<",
"Team",
">",
"users",
"(",
"String",
"team",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/teams/%s/users\"",
",",
"team",
")",
";",
"return",
"new",
"CollectionRequest",
"<",
"Team",
">",
"(",
"this... | Returns the compact records for all users that are members of the team.
@param team Globally unique identifier for the team.
@return Request object | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"users",
"that",
"are",
"members",
"of",
"the",
"team",
"."
] | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L66-L70 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.addUser | public ItemRequest<Team> addUser(String team) {
String path = String.format("/teams/%s/addUser", team);
return new ItemRequest<Team>(this, Team.class, path, "POST");
} | java | public ItemRequest<Team> addUser(String team) {
String path = String.format("/teams/%s/addUser", team);
return new ItemRequest<Team>(this, Team.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Team",
">",
"addUser",
"(",
"String",
"team",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/teams/%s/addUser\"",
",",
"team",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Team",
">",
"(",
"this",
","... | The user making this call must be a member of the team in order to add others.
The user to add must exist in the same organization as the team in order to be added.
The user to add can be referenced by their globally unique user ID or their email address.
Returns the full user record for the added user.
@param team Globally unique identifier for the team.
@return Request object | [
"The",
"user",
"making",
"this",
"call",
"must",
"be",
"a",
"member",
"of",
"the",
"team",
"in",
"order",
"to",
"add",
"others",
".",
"The",
"user",
"to",
"add",
"must",
"exist",
"in",
"the",
"same",
"organization",
"as",
"the",
"team",
"in",
"order",
... | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L81-L85 | train |
Asana/java-asana | src/main/java/com/asana/resources/gen/TeamsBase.java | TeamsBase.removeUser | public ItemRequest<Team> removeUser(String team) {
String path = String.format("/teams/%s/removeUser", team);
return new ItemRequest<Team>(this, Team.class, path, "POST");
} | java | public ItemRequest<Team> removeUser(String team) {
String path = String.format("/teams/%s/removeUser", team);
return new ItemRequest<Team>(this, Team.class, path, "POST");
} | [
"public",
"ItemRequest",
"<",
"Team",
">",
"removeUser",
"(",
"String",
"team",
")",
"{",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/teams/%s/removeUser\"",
",",
"team",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Team",
">",
"(",
"this",... | The user to remove can be referenced by their globally unique user ID or their email address.
Removes the user from the specified team. Returns an empty data record.
@param team Globally unique identifier for the team.
@return Request object | [
"The",
"user",
"to",
"remove",
"can",
"be",
"referenced",
"by",
"their",
"globally",
"unique",
"user",
"ID",
"or",
"their",
"email",
"address",
".",
"Removes",
"the",
"user",
"from",
"the",
"specified",
"team",
".",
"Returns",
"an",
"empty",
"data",
"recor... | abeea92fd5a71260a5d804db4da94e52fd7a15a7 | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L94-L98 | train |
cdapio/netty-http | src/main/java/io/cdap/http/AbstractHttpHandler.java | AbstractHttpHandler.sendInternalRequest | protected InternalHttpResponse sendInternalRequest(HttpRequest request) {
InternalHttpResponder responder = new InternalHttpResponder();
httpResourceHandler.handle(request, responder);
return responder.getResponse();
} | java | protected InternalHttpResponse sendInternalRequest(HttpRequest request) {
InternalHttpResponder responder = new InternalHttpResponder();
httpResourceHandler.handle(request, responder);
return responder.getResponse();
} | [
"protected",
"InternalHttpResponse",
"sendInternalRequest",
"(",
"HttpRequest",
"request",
")",
"{",
"InternalHttpResponder",
"responder",
"=",
"new",
"InternalHttpResponder",
"(",
")",
";",
"httpResourceHandler",
".",
"handle",
"(",
"request",
",",
"responder",
")",
... | Send a request to another handler internal to the server, getting back the response body and response code.
@param request request to send to another handler.
@return {@link InternalHttpResponse} containing the response code and body. | [
"Send",
"a",
"request",
"to",
"another",
"handler",
"internal",
"to",
"the",
"server",
"getting",
"back",
"the",
"response",
"body",
"and",
"response",
"code",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/AbstractHttpHandler.java#L47-L51 | train |
cdapio/netty-http | src/main/java/io/cdap/http/SSLHandlerFactory.java | SSLHandlerFactory.create | public SslHandler create(ByteBufAllocator bufferAllocator) {
SSLEngine engine = sslContext.newEngine(bufferAllocator);
engine.setNeedClientAuth(needClientAuth);
engine.setUseClientMode(false);
return new SslHandler(engine);
} | java | public SslHandler create(ByteBufAllocator bufferAllocator) {
SSLEngine engine = sslContext.newEngine(bufferAllocator);
engine.setNeedClientAuth(needClientAuth);
engine.setUseClientMode(false);
return new SslHandler(engine);
} | [
"public",
"SslHandler",
"create",
"(",
"ByteBufAllocator",
"bufferAllocator",
")",
"{",
"SSLEngine",
"engine",
"=",
"sslContext",
".",
"newEngine",
"(",
"bufferAllocator",
")",
";",
"engine",
".",
"setNeedClientAuth",
"(",
"needClientAuth",
")",
";",
"engine",
"."... | Creates an SslHandler
@param bufferAllocator the buffer allocator
@return instance of {@code SslHandler} | [
"Creates",
"an",
"SslHandler"
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/SSLHandlerFactory.java#L86-L91 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceHandler.java | HttpResourceHandler.getHttpMethods | private Set<HttpMethod> getHttpMethods(Method method) {
Set<HttpMethod> httpMethods = new HashSet<>();
if (method.isAnnotationPresent(GET.class)) {
httpMethods.add(HttpMethod.GET);
}
if (method.isAnnotationPresent(PUT.class)) {
httpMethods.add(HttpMethod.PUT);
}
if (method.isAnnotationPresent(POST.class)) {
httpMethods.add(HttpMethod.POST);
}
if (method.isAnnotationPresent(DELETE.class)) {
httpMethods.add(HttpMethod.DELETE);
}
return Collections.unmodifiableSet(httpMethods);
} | java | private Set<HttpMethod> getHttpMethods(Method method) {
Set<HttpMethod> httpMethods = new HashSet<>();
if (method.isAnnotationPresent(GET.class)) {
httpMethods.add(HttpMethod.GET);
}
if (method.isAnnotationPresent(PUT.class)) {
httpMethods.add(HttpMethod.PUT);
}
if (method.isAnnotationPresent(POST.class)) {
httpMethods.add(HttpMethod.POST);
}
if (method.isAnnotationPresent(DELETE.class)) {
httpMethods.add(HttpMethod.DELETE);
}
return Collections.unmodifiableSet(httpMethods);
} | [
"private",
"Set",
"<",
"HttpMethod",
">",
"getHttpMethods",
"(",
"Method",
"method",
")",
"{",
"Set",
"<",
"HttpMethod",
">",
"httpMethods",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"if",
"(",
"method",
".",
"isAnnotationPresent",
"(",
"GET",
".",
"cl... | Fetches the HttpMethod from annotations and returns String representation of HttpMethod.
Return emptyString if not present.
@param method Method handling the http request.
@return String representation of HttpMethod from annotations or emptyString as a default. | [
"Fetches",
"the",
"HttpMethod",
"from",
"annotations",
"and",
"returns",
"String",
"representation",
"of",
"HttpMethod",
".",
"Return",
"emptyString",
"if",
"not",
"present",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L137-L154 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceHandler.java | HttpResourceHandler.handle | public void handle(HttpRequest request, HttpResponder responder) {
if (urlRewriter != null) {
try {
request.setUri(URI.create(request.uri()).normalize().toString());
if (!urlRewriter.rewrite(request, responder)) {
return;
}
} catch (Throwable t) {
responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Caught exception processing request. Reason: %s",
t.getMessage()));
LOG.error("Exception thrown during rewriting of uri {}", request.uri(), t);
return;
}
}
try {
String path = URI.create(request.uri()).normalize().getPath();
List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations
= patternRouter.getDestinations(path);
PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> matchedDestination =
getMatchedDestination(routableDestinations, request.method(), path);
if (matchedDestination != null) {
//Found a httpresource route to it.
HttpResourceModel httpResourceModel = matchedDestination.getDestination();
// Call preCall method of handler hooks.
boolean terminated = false;
HandlerInfo info = new HandlerInfo(httpResourceModel.getMethod().getDeclaringClass().getName(),
httpResourceModel.getMethod().getName());
for (HandlerHook hook : handlerHooks) {
if (!hook.preCall(request, responder, info)) {
// Terminate further request processing if preCall returns false.
terminated = true;
break;
}
}
// Call httpresource method
if (!terminated) {
// Wrap responder to make post hook calls.
responder = new WrappedHttpResponder(responder, handlerHooks, request, info);
if (httpResourceModel.handle(request, responder, matchedDestination.getGroupNameValues()).isStreaming()) {
responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED,
String.format("Body Consumer not supported for internalHttpResponder: %s",
request.uri()));
}
}
} else if (routableDestinations.size() > 0) {
//Found a matching resource but could not find the right HttpMethod so return 405
responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED,
String.format("Problem accessing: %s. Reason: Method Not Allowed", request.uri()));
} else {
responder.sendString(HttpResponseStatus.NOT_FOUND, String.format("Problem accessing: %s. Reason: Not Found",
request.uri()));
}
} catch (Throwable t) {
responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Caught exception processing request. Reason: %s", t.getMessage()));
LOG.error("Exception thrown during request processing for uri {}", request.uri(), t);
}
} | java | public void handle(HttpRequest request, HttpResponder responder) {
if (urlRewriter != null) {
try {
request.setUri(URI.create(request.uri()).normalize().toString());
if (!urlRewriter.rewrite(request, responder)) {
return;
}
} catch (Throwable t) {
responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Caught exception processing request. Reason: %s",
t.getMessage()));
LOG.error("Exception thrown during rewriting of uri {}", request.uri(), t);
return;
}
}
try {
String path = URI.create(request.uri()).normalize().getPath();
List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations
= patternRouter.getDestinations(path);
PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> matchedDestination =
getMatchedDestination(routableDestinations, request.method(), path);
if (matchedDestination != null) {
//Found a httpresource route to it.
HttpResourceModel httpResourceModel = matchedDestination.getDestination();
// Call preCall method of handler hooks.
boolean terminated = false;
HandlerInfo info = new HandlerInfo(httpResourceModel.getMethod().getDeclaringClass().getName(),
httpResourceModel.getMethod().getName());
for (HandlerHook hook : handlerHooks) {
if (!hook.preCall(request, responder, info)) {
// Terminate further request processing if preCall returns false.
terminated = true;
break;
}
}
// Call httpresource method
if (!terminated) {
// Wrap responder to make post hook calls.
responder = new WrappedHttpResponder(responder, handlerHooks, request, info);
if (httpResourceModel.handle(request, responder, matchedDestination.getGroupNameValues()).isStreaming()) {
responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED,
String.format("Body Consumer not supported for internalHttpResponder: %s",
request.uri()));
}
}
} else if (routableDestinations.size() > 0) {
//Found a matching resource but could not find the right HttpMethod so return 405
responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED,
String.format("Problem accessing: %s. Reason: Method Not Allowed", request.uri()));
} else {
responder.sendString(HttpResponseStatus.NOT_FOUND, String.format("Problem accessing: %s. Reason: Not Found",
request.uri()));
}
} catch (Throwable t) {
responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Caught exception processing request. Reason: %s", t.getMessage()));
LOG.error("Exception thrown during request processing for uri {}", request.uri(), t);
}
} | [
"public",
"void",
"handle",
"(",
"HttpRequest",
"request",
",",
"HttpResponder",
"responder",
")",
"{",
"if",
"(",
"urlRewriter",
"!=",
"null",
")",
"{",
"try",
"{",
"request",
".",
"setUri",
"(",
"URI",
".",
"create",
"(",
"request",
".",
"uri",
"(",
... | Call the appropriate handler for handling the httprequest. 404 if path is not found. 405 if path is found but
httpMethod does not match what's configured.
@param request instance of {@code HttpRequest}
@param responder instance of {@code HttpResponder} to handle the request. | [
"Call",
"the",
"appropriate",
"handler",
"for",
"handling",
"the",
"httprequest",
".",
"404",
"if",
"path",
"is",
"not",
"found",
".",
"405",
"if",
"path",
"is",
"found",
"but",
"httpMethod",
"does",
"not",
"match",
"what",
"s",
"configured",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L163-L227 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceHandler.java | HttpResourceHandler.getMatchedDestination | private PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>
getMatchedDestination(List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations,
HttpMethod targetHttpMethod, String requestUri) {
LOG.trace("Routable destinations for request {}: {}", requestUri, routableDestinations);
Iterable<String> requestUriParts = splitAndOmitEmpty(requestUri, '/');
List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> matchedDestinations = new ArrayList<>();
long maxScore = 0;
for (PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> destination : routableDestinations) {
HttpResourceModel resourceModel = destination.getDestination();
for (HttpMethod httpMethod : resourceModel.getHttpMethod()) {
if (targetHttpMethod.equals(httpMethod)) {
long score = getWeightedMatchScore(requestUriParts, splitAndOmitEmpty(resourceModel.getPath(), '/'));
LOG.trace("Max score = {}. Weighted score for {} is {}. ", maxScore, destination, score);
if (score > maxScore) {
maxScore = score;
matchedDestinations.clear();
matchedDestinations.add(destination);
} else if (score == maxScore) {
matchedDestinations.add(destination);
}
}
}
}
if (matchedDestinations.size() > 1) {
throw new IllegalStateException(String.format("Multiple matched handlers found for request uri %s: %s",
requestUri, matchedDestinations));
} else if (matchedDestinations.size() == 1) {
return matchedDestinations.get(0);
}
return null;
} | java | private PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>
getMatchedDestination(List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations,
HttpMethod targetHttpMethod, String requestUri) {
LOG.trace("Routable destinations for request {}: {}", requestUri, routableDestinations);
Iterable<String> requestUriParts = splitAndOmitEmpty(requestUri, '/');
List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> matchedDestinations = new ArrayList<>();
long maxScore = 0;
for (PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> destination : routableDestinations) {
HttpResourceModel resourceModel = destination.getDestination();
for (HttpMethod httpMethod : resourceModel.getHttpMethod()) {
if (targetHttpMethod.equals(httpMethod)) {
long score = getWeightedMatchScore(requestUriParts, splitAndOmitEmpty(resourceModel.getPath(), '/'));
LOG.trace("Max score = {}. Weighted score for {} is {}. ", maxScore, destination, score);
if (score > maxScore) {
maxScore = score;
matchedDestinations.clear();
matchedDestinations.add(destination);
} else if (score == maxScore) {
matchedDestinations.add(destination);
}
}
}
}
if (matchedDestinations.size() > 1) {
throw new IllegalStateException(String.format("Multiple matched handlers found for request uri %s: %s",
requestUri, matchedDestinations));
} else if (matchedDestinations.size() == 1) {
return matchedDestinations.get(0);
}
return null;
} | [
"private",
"PatternPathRouterWithGroups",
".",
"RoutableDestination",
"<",
"HttpResourceModel",
">",
"getMatchedDestination",
"(",
"List",
"<",
"PatternPathRouterWithGroups",
".",
"RoutableDestination",
"<",
"HttpResourceModel",
">",
">",
"routableDestinations",
",",
"HttpMet... | Get HttpResourceModel which matches the HttpMethod of the request.
@param routableDestinations List of ResourceModels.
@param targetHttpMethod HttpMethod.
@param requestUri request URI.
@return RoutableDestination that matches httpMethod that needs to be handled. null if there are no matches. | [
"Get",
"HttpResourceModel",
"which",
"matches",
"the",
"HttpMethod",
"of",
"the",
"request",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L307-L341 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceHandler.java | HttpResourceHandler.getWeightedMatchScore | private long getWeightedMatchScore(Iterable<String> requestUriParts, Iterable<String> destUriParts) {
// The score calculated below is a base 5 number
// The score will have one digit for one part of the URI
// This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13
// We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during
// score calculation
long score = 0;
for (Iterator<String> rit = requestUriParts.iterator(), dit = destUriParts.iterator();
rit.hasNext() && dit.hasNext(); ) {
String requestPart = rit.next();
String destPart = dit.next();
if (requestPart.equals(destPart)) {
score = (score * 5) + 4;
} else if (PatternPathRouterWithGroups.GROUP_PATTERN.matcher(destPart).matches()) {
score = (score * 5) + 3;
} else {
score = (score * 5) + 2;
}
}
return score;
} | java | private long getWeightedMatchScore(Iterable<String> requestUriParts, Iterable<String> destUriParts) {
// The score calculated below is a base 5 number
// The score will have one digit for one part of the URI
// This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13
// We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during
// score calculation
long score = 0;
for (Iterator<String> rit = requestUriParts.iterator(), dit = destUriParts.iterator();
rit.hasNext() && dit.hasNext(); ) {
String requestPart = rit.next();
String destPart = dit.next();
if (requestPart.equals(destPart)) {
score = (score * 5) + 4;
} else if (PatternPathRouterWithGroups.GROUP_PATTERN.matcher(destPart).matches()) {
score = (score * 5) + 3;
} else {
score = (score * 5) + 2;
}
}
return score;
} | [
"private",
"long",
"getWeightedMatchScore",
"(",
"Iterable",
"<",
"String",
">",
"requestUriParts",
",",
"Iterable",
"<",
"String",
">",
"destUriParts",
")",
"{",
"// The score calculated below is a base 5 number",
"// The score will have one digit for one part of the URI",
"//... | Generate a weighted score based on position for matches of URI parts.
The matches are weighted in descending order from left to right.
Exact match is weighted higher than group match, and group match is weighted higher than wildcard match.
@param requestUriParts the parts of request URI
@param destUriParts the parts of destination URI
@return weighted score | [
"Generate",
"a",
"weighted",
"score",
"based",
"on",
"position",
"for",
"matches",
"of",
"URI",
"parts",
".",
"The",
"matches",
"are",
"weighted",
"in",
"descending",
"order",
"from",
"left",
"to",
"right",
".",
"Exact",
"match",
"is",
"weighted",
"higher",
... | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L352-L372 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceHandler.java | HttpResourceHandler.splitAndOmitEmpty | private static Iterable<String> splitAndOmitEmpty(final String str, final char splitChar) {
return new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
int startIdx = 0;
String next = null;
@Override
public boolean hasNext() {
while (next == null && startIdx < str.length()) {
int idx = str.indexOf(splitChar, startIdx);
if (idx == startIdx) {
// Omit empty string
startIdx++;
continue;
}
if (idx >= 0) {
// Found the next part
next = str.substring(startIdx, idx);
startIdx = idx;
} else {
// The last part
if (startIdx < str.length()) {
next = str.substring(startIdx);
startIdx = str.length();
}
break;
}
}
return next != null;
}
@Override
public String next() {
if (hasNext()) {
String next = this.next;
this.next = null;
return next;
}
throw new NoSuchElementException("No more element");
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
};
}
};
} | java | private static Iterable<String> splitAndOmitEmpty(final String str, final char splitChar) {
return new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
int startIdx = 0;
String next = null;
@Override
public boolean hasNext() {
while (next == null && startIdx < str.length()) {
int idx = str.indexOf(splitChar, startIdx);
if (idx == startIdx) {
// Omit empty string
startIdx++;
continue;
}
if (idx >= 0) {
// Found the next part
next = str.substring(startIdx, idx);
startIdx = idx;
} else {
// The last part
if (startIdx < str.length()) {
next = str.substring(startIdx);
startIdx = str.length();
}
break;
}
}
return next != null;
}
@Override
public String next() {
if (hasNext()) {
String next = this.next;
this.next = null;
return next;
}
throw new NoSuchElementException("No more element");
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
};
}
};
} | [
"private",
"static",
"Iterable",
"<",
"String",
">",
"splitAndOmitEmpty",
"(",
"final",
"String",
"str",
",",
"final",
"char",
"splitChar",
")",
"{",
"return",
"new",
"Iterable",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<"... | Helper method to split a string by a given character, with empty parts omitted. | [
"Helper",
"method",
"to",
"split",
"a",
"string",
"by",
"a",
"given",
"character",
"with",
"empty",
"parts",
"omitted",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L403-L454 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/ParamConvertUtils.java | ParamConvertUtils.createPrimitiveTypeConverter | @Nullable
private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) {
Object defaultValue = defaultValue(resultClass);
if (defaultValue == null) {
// For primitive type, the default value shouldn't be null
return null;
}
return new BasicConverter(defaultValue) {
@Override
protected Object convert(String value) throws Exception {
return valueOf(value, resultClass);
}
};
} | java | @Nullable
private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) {
Object defaultValue = defaultValue(resultClass);
if (defaultValue == null) {
// For primitive type, the default value shouldn't be null
return null;
}
return new BasicConverter(defaultValue) {
@Override
protected Object convert(String value) throws Exception {
return valueOf(value, resultClass);
}
};
} | [
"@",
"Nullable",
"private",
"static",
"Converter",
"<",
"List",
"<",
"String",
">",
",",
"Object",
">",
"createPrimitiveTypeConverter",
"(",
"final",
"Class",
"<",
"?",
">",
"resultClass",
")",
"{",
"Object",
"defaultValue",
"=",
"defaultValue",
"(",
"resultCl... | Creates a converter function that converts value into primitive type.
@return A converter function or {@code null} if the given type is not primitive type or boxed type | [
"Creates",
"a",
"converter",
"function",
"that",
"converts",
"value",
"into",
"primitive",
"type",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L158-L173 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/ParamConvertUtils.java | ParamConvertUtils.createStringConstructorConverter | private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) {
try {
final Constructor<?> constructor = resultClass.getConstructor(String.class);
return new BasicConverter(defaultValue(resultClass)) {
@Override
protected Object convert(String value) throws Exception {
return constructor.newInstance(value);
}
};
} catch (Exception e) {
return null;
}
} | java | private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) {
try {
final Constructor<?> constructor = resultClass.getConstructor(String.class);
return new BasicConverter(defaultValue(resultClass)) {
@Override
protected Object convert(String value) throws Exception {
return constructor.newInstance(value);
}
};
} catch (Exception e) {
return null;
}
} | [
"private",
"static",
"Converter",
"<",
"List",
"<",
"String",
">",
",",
"Object",
">",
"createStringConstructorConverter",
"(",
"Class",
"<",
"?",
">",
"resultClass",
")",
"{",
"try",
"{",
"final",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"resultCla... | Creates a converter function that converts value using a constructor that accepts a single String argument.
@return A converter function or {@code null} if the given type doesn't have a public constructor that accepts
a single String argument. | [
"Creates",
"a",
"converter",
"function",
"that",
"converts",
"value",
"using",
"a",
"constructor",
"that",
"accepts",
"a",
"single",
"String",
"argument",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L182-L194 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/ParamConvertUtils.java | ParamConvertUtils.valueOf | @Nullable
private static Object valueOf(String value, Class<?> cls) {
if (cls == Boolean.TYPE) {
return Boolean.valueOf(value);
}
if (cls == Character.TYPE) {
return value.length() >= 1 ? value.charAt(0) : defaultValue(char.class);
}
if (cls == Byte.TYPE) {
return Byte.valueOf(value);
}
if (cls == Short.TYPE) {
return Short.valueOf(value);
}
if (cls == Integer.TYPE) {
return Integer.valueOf(value);
}
if (cls == Long.TYPE) {
return Long.valueOf(value);
}
if (cls == Float.TYPE) {
return Float.valueOf(value);
}
if (cls == Double.TYPE) {
return Double.valueOf(value);
}
return null;
} | java | @Nullable
private static Object valueOf(String value, Class<?> cls) {
if (cls == Boolean.TYPE) {
return Boolean.valueOf(value);
}
if (cls == Character.TYPE) {
return value.length() >= 1 ? value.charAt(0) : defaultValue(char.class);
}
if (cls == Byte.TYPE) {
return Byte.valueOf(value);
}
if (cls == Short.TYPE) {
return Short.valueOf(value);
}
if (cls == Integer.TYPE) {
return Integer.valueOf(value);
}
if (cls == Long.TYPE) {
return Long.valueOf(value);
}
if (cls == Float.TYPE) {
return Float.valueOf(value);
}
if (cls == Double.TYPE) {
return Double.valueOf(value);
}
return null;
} | [
"@",
"Nullable",
"private",
"static",
"Object",
"valueOf",
"(",
"String",
"value",
",",
"Class",
"<",
"?",
">",
"cls",
")",
"{",
"if",
"(",
"cls",
"==",
"Boolean",
".",
"TYPE",
")",
"{",
"return",
"Boolean",
".",
"valueOf",
"(",
"value",
")",
";",
... | Returns the value of the primitive type from the given string value.
@param value the value to parse
@param cls the primitive type class
@return the boxed type value or {@code null} if the given class is not a primitive type | [
"Returns",
"the",
"value",
"of",
"the",
"primitive",
"type",
"from",
"the",
"given",
"string",
"value",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L314-L341 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/ParamConvertUtils.java | ParamConvertUtils.getRawClass | private static Class<?> getRawClass(Type type) {
if (type instanceof Class) {
return (Class<?>) type;
}
if (type instanceof ParameterizedType) {
return getRawClass(((ParameterizedType) type).getRawType());
}
// For TypeVariable and WildcardType, returns the first upper bound.
if (type instanceof TypeVariable) {
return getRawClass(((TypeVariable) type).getBounds()[0]);
}
if (type instanceof WildcardType) {
return getRawClass(((WildcardType) type).getUpperBounds()[0]);
}
if (type instanceof GenericArrayType) {
Class<?> componentClass = getRawClass(((GenericArrayType) type).getGenericComponentType());
return Array.newInstance(componentClass, 0).getClass();
}
// This shouldn't happen as we captured all implementations of Type above (as or Java 8)
throw new IllegalArgumentException("Unsupported type " + type + " of type class " + type.getClass());
} | java | private static Class<?> getRawClass(Type type) {
if (type instanceof Class) {
return (Class<?>) type;
}
if (type instanceof ParameterizedType) {
return getRawClass(((ParameterizedType) type).getRawType());
}
// For TypeVariable and WildcardType, returns the first upper bound.
if (type instanceof TypeVariable) {
return getRawClass(((TypeVariable) type).getBounds()[0]);
}
if (type instanceof WildcardType) {
return getRawClass(((WildcardType) type).getUpperBounds()[0]);
}
if (type instanceof GenericArrayType) {
Class<?> componentClass = getRawClass(((GenericArrayType) type).getGenericComponentType());
return Array.newInstance(componentClass, 0).getClass();
}
// This shouldn't happen as we captured all implementations of Type above (as or Java 8)
throw new IllegalArgumentException("Unsupported type " + type + " of type class " + type.getClass());
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"getRawClass",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
")",
"{",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"}",
"if",
"(",
"type",
"instanceof",
"Parameteriz... | Returns the raw class of the given type. | [
"Returns",
"the",
"raw",
"class",
"of",
"the",
"given",
"type",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L346-L366 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpMethodInfo.java | HttpMethodInfo.invoke | void invoke(HttpRequest request) throws Exception {
bodyConsumer = null;
Object invokeResult;
try {
args[0] = this.request = request;
invokeResult = method.invoke(handler, args);
} catch (InvocationTargetException e) {
exceptionHandler.handle(e.getTargetException(), request, responder);
return;
} catch (Throwable t) {
exceptionHandler.handle(t, request, responder);
return;
}
if (isStreaming) {
// Casting guarantee to be succeeded.
bodyConsumer = (BodyConsumer) invokeResult;
}
} | java | void invoke(HttpRequest request) throws Exception {
bodyConsumer = null;
Object invokeResult;
try {
args[0] = this.request = request;
invokeResult = method.invoke(handler, args);
} catch (InvocationTargetException e) {
exceptionHandler.handle(e.getTargetException(), request, responder);
return;
} catch (Throwable t) {
exceptionHandler.handle(t, request, responder);
return;
}
if (isStreaming) {
// Casting guarantee to be succeeded.
bodyConsumer = (BodyConsumer) invokeResult;
}
} | [
"void",
"invoke",
"(",
"HttpRequest",
"request",
")",
"throws",
"Exception",
"{",
"bodyConsumer",
"=",
"null",
";",
"Object",
"invokeResult",
";",
"try",
"{",
"args",
"[",
"0",
"]",
"=",
"this",
".",
"request",
"=",
"request",
";",
"invokeResult",
"=",
"... | Calls the httpHandler method. | [
"Calls",
"the",
"httpHandler",
"method",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpMethodInfo.java#L77-L95 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpMethodInfo.java | HttpMethodInfo.sendError | void sendError(HttpResponseStatus status, Throwable ex) {
String msg;
if (ex instanceof InvocationTargetException) {
msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage());
} else {
msg = String.format("Exception Encountered while processing request: %s", ex.getMessage());
}
// Send the status and message, followed by closing of the connection.
responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE));
if (bodyConsumer != null) {
bodyConsumerError(ex);
}
} | java | void sendError(HttpResponseStatus status, Throwable ex) {
String msg;
if (ex instanceof InvocationTargetException) {
msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage());
} else {
msg = String.format("Exception Encountered while processing request: %s", ex.getMessage());
}
// Send the status and message, followed by closing of the connection.
responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE));
if (bodyConsumer != null) {
bodyConsumerError(ex);
}
} | [
"void",
"sendError",
"(",
"HttpResponseStatus",
"status",
",",
"Throwable",
"ex",
")",
"{",
"String",
"msg",
";",
"if",
"(",
"ex",
"instanceof",
"InvocationTargetException",
")",
"{",
"msg",
"=",
"String",
".",
"format",
"(",
"\"Exception Encountered while process... | Sends the error to responder. | [
"Sends",
"the",
"error",
"to",
"responder",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpMethodInfo.java#L170-L184 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java | PatternPathRouterWithGroups.add | public void add(final String source, final T destination) {
// replace multiple slashes with a single slash.
String path = source.replaceAll("/+", "/");
path = (path.endsWith("/") && path.length() > 1)
? path.substring(0, path.length() - 1) : path;
String[] parts = path.split("/", maxPathParts + 2);
if (parts.length - 1 > maxPathParts) {
throw new IllegalArgumentException(String.format("Number of parts of path %s exceeds allowed limit %s",
source, maxPathParts));
}
StringBuilder sb = new StringBuilder();
List<String> groupNames = new ArrayList<>();
for (String part : parts) {
Matcher groupMatcher = GROUP_PATTERN.matcher(part);
if (groupMatcher.matches()) {
groupNames.add(groupMatcher.group(1));
sb.append("([^/]+?)");
} else if (WILD_CARD_PATTERN.matcher(part).matches()) {
sb.append(".*?");
} else {
sb.append(part);
}
sb.append("/");
}
//Ignore the last "/"
sb.setLength(sb.length() - 1);
Pattern pattern = Pattern.compile(sb.toString());
patternRouteList.add(ImmutablePair.of(pattern, new RouteDestinationWithGroups(destination, groupNames)));
} | java | public void add(final String source, final T destination) {
// replace multiple slashes with a single slash.
String path = source.replaceAll("/+", "/");
path = (path.endsWith("/") && path.length() > 1)
? path.substring(0, path.length() - 1) : path;
String[] parts = path.split("/", maxPathParts + 2);
if (parts.length - 1 > maxPathParts) {
throw new IllegalArgumentException(String.format("Number of parts of path %s exceeds allowed limit %s",
source, maxPathParts));
}
StringBuilder sb = new StringBuilder();
List<String> groupNames = new ArrayList<>();
for (String part : parts) {
Matcher groupMatcher = GROUP_PATTERN.matcher(part);
if (groupMatcher.matches()) {
groupNames.add(groupMatcher.group(1));
sb.append("([^/]+?)");
} else if (WILD_CARD_PATTERN.matcher(part).matches()) {
sb.append(".*?");
} else {
sb.append(part);
}
sb.append("/");
}
//Ignore the last "/"
sb.setLength(sb.length() - 1);
Pattern pattern = Pattern.compile(sb.toString());
patternRouteList.add(ImmutablePair.of(pattern, new RouteDestinationWithGroups(destination, groupNames)));
} | [
"public",
"void",
"add",
"(",
"final",
"String",
"source",
",",
"final",
"T",
"destination",
")",
"{",
"// replace multiple slashes with a single slash.",
"String",
"path",
"=",
"source",
".",
"replaceAll",
"(",
"\"/+\"",
",",
"\"/\"",
")",
";",
"path",
"=",
"... | Add a source and destination.
@param source Source path to be routed. Routed path can have named wild-card pattern with braces "{}".
@param destination Destination of the path. | [
"Add",
"a",
"source",
"and",
"destination",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java#L62-L97 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java | PatternPathRouterWithGroups.getDestinations | public List<RoutableDestination<T>> getDestinations(String path) {
String cleanPath = (path.endsWith("/") && path.length() > 1)
? path.substring(0, path.length() - 1) : path;
List<RoutableDestination<T>> result = new ArrayList<>();
for (ImmutablePair<Pattern, RouteDestinationWithGroups> patternRoute : patternRouteList) {
Map<String, String> groupNameValuesBuilder = new HashMap<>();
Matcher matcher = patternRoute.getFirst().matcher(cleanPath);
if (matcher.matches()) {
int matchIndex = 1;
for (String name : patternRoute.getSecond().getGroupNames()) {
String value = matcher.group(matchIndex);
groupNameValuesBuilder.put(name, value);
matchIndex++;
}
result.add(new RoutableDestination<>(patternRoute.getSecond().getDestination(), groupNameValuesBuilder));
}
}
return result;
} | java | public List<RoutableDestination<T>> getDestinations(String path) {
String cleanPath = (path.endsWith("/") && path.length() > 1)
? path.substring(0, path.length() - 1) : path;
List<RoutableDestination<T>> result = new ArrayList<>();
for (ImmutablePair<Pattern, RouteDestinationWithGroups> patternRoute : patternRouteList) {
Map<String, String> groupNameValuesBuilder = new HashMap<>();
Matcher matcher = patternRoute.getFirst().matcher(cleanPath);
if (matcher.matches()) {
int matchIndex = 1;
for (String name : patternRoute.getSecond().getGroupNames()) {
String value = matcher.group(matchIndex);
groupNameValuesBuilder.put(name, value);
matchIndex++;
}
result.add(new RoutableDestination<>(patternRoute.getSecond().getDestination(), groupNameValuesBuilder));
}
}
return result;
} | [
"public",
"List",
"<",
"RoutableDestination",
"<",
"T",
">",
">",
"getDestinations",
"(",
"String",
"path",
")",
"{",
"String",
"cleanPath",
"=",
"(",
"path",
".",
"endsWith",
"(",
"\"/\"",
")",
"&&",
"path",
".",
"length",
"(",
")",
">",
"1",
")",
"... | Get a list of destinations and the values matching templated parameter for the given path.
Returns an empty list when there are no destinations that are matched.
@param path path to be routed.
@return List of Destinations matching the given route. | [
"Get",
"a",
"list",
"of",
"destinations",
"and",
"the",
"values",
"matching",
"templated",
"parameter",
"for",
"the",
"given",
"path",
".",
"Returns",
"an",
"empty",
"list",
"when",
"there",
"are",
"no",
"destinations",
"that",
"are",
"matched",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java#L106-L127 | train |
cdapio/netty-http | src/main/java/io/cdap/http/NettyHttpService.java | NettyHttpService.start | public synchronized void start() throws Exception {
if (state == State.RUNNING) {
LOG.debug("Ignore start() call on HTTP service {} since it has already been started.", serviceName);
return;
}
if (state != State.NOT_STARTED) {
if (state == State.STOPPED) {
throw new IllegalStateException("Cannot start the HTTP service "
+ serviceName + " again since it has been stopped");
}
throw new IllegalStateException("Cannot start the HTTP service "
+ serviceName + " because it was failed earlier");
}
try {
LOG.info("Starting HTTP Service {} at address {}", serviceName, bindAddress);
channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
resourceHandler.init(handlerContext);
eventExecutorGroup = createEventExecutorGroup(execThreadPoolSize);
bootstrap = createBootstrap(channelGroup);
Channel serverChannel = bootstrap.bind(bindAddress).sync().channel();
channelGroup.add(serverChannel);
bindAddress = (InetSocketAddress) serverChannel.localAddress();
LOG.debug("Started HTTP Service {} at address {}", serviceName, bindAddress);
state = State.RUNNING;
} catch (Throwable t) {
// Release resources if there is any failure
channelGroup.close().awaitUninterruptibly();
try {
if (bootstrap != null) {
shutdownExecutorGroups(0, 5, TimeUnit.SECONDS,
bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup);
} else {
shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, eventExecutorGroup);
}
} catch (Throwable t2) {
t.addSuppressed(t2);
}
state = State.FAILED;
throw t;
}
} | java | public synchronized void start() throws Exception {
if (state == State.RUNNING) {
LOG.debug("Ignore start() call on HTTP service {} since it has already been started.", serviceName);
return;
}
if (state != State.NOT_STARTED) {
if (state == State.STOPPED) {
throw new IllegalStateException("Cannot start the HTTP service "
+ serviceName + " again since it has been stopped");
}
throw new IllegalStateException("Cannot start the HTTP service "
+ serviceName + " because it was failed earlier");
}
try {
LOG.info("Starting HTTP Service {} at address {}", serviceName, bindAddress);
channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
resourceHandler.init(handlerContext);
eventExecutorGroup = createEventExecutorGroup(execThreadPoolSize);
bootstrap = createBootstrap(channelGroup);
Channel serverChannel = bootstrap.bind(bindAddress).sync().channel();
channelGroup.add(serverChannel);
bindAddress = (InetSocketAddress) serverChannel.localAddress();
LOG.debug("Started HTTP Service {} at address {}", serviceName, bindAddress);
state = State.RUNNING;
} catch (Throwable t) {
// Release resources if there is any failure
channelGroup.close().awaitUninterruptibly();
try {
if (bootstrap != null) {
shutdownExecutorGroups(0, 5, TimeUnit.SECONDS,
bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup);
} else {
shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, eventExecutorGroup);
}
} catch (Throwable t2) {
t.addSuppressed(t2);
}
state = State.FAILED;
throw t;
}
} | [
"public",
"synchronized",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"RUNNING",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Ignore start() call on HTTP service {} since it has already been started.\"",
",",
"serviceName",... | Starts the HTTP service.
@throws Exception if the service failed to started | [
"Starts",
"the",
"HTTP",
"service",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L158-L201 | train |
cdapio/netty-http | src/main/java/io/cdap/http/NettyHttpService.java | NettyHttpService.stop | public synchronized void stop(long quietPeriod, long timeout, TimeUnit unit) throws Exception {
if (state == State.STOPPED) {
LOG.debug("Ignore stop() call on HTTP service {} since it has already been stopped.", serviceName);
return;
}
LOG.info("Stopping HTTP Service {}", serviceName);
try {
try {
channelGroup.close().awaitUninterruptibly();
} finally {
try {
shutdownExecutorGroups(quietPeriod, timeout, unit,
bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup);
} finally {
resourceHandler.destroy(handlerContext);
}
}
} catch (Throwable t) {
state = State.FAILED;
throw t;
}
state = State.STOPPED;
LOG.debug("Stopped HTTP Service {} on address {}", serviceName, bindAddress);
} | java | public synchronized void stop(long quietPeriod, long timeout, TimeUnit unit) throws Exception {
if (state == State.STOPPED) {
LOG.debug("Ignore stop() call on HTTP service {} since it has already been stopped.", serviceName);
return;
}
LOG.info("Stopping HTTP Service {}", serviceName);
try {
try {
channelGroup.close().awaitUninterruptibly();
} finally {
try {
shutdownExecutorGroups(quietPeriod, timeout, unit,
bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup);
} finally {
resourceHandler.destroy(handlerContext);
}
}
} catch (Throwable t) {
state = State.FAILED;
throw t;
}
state = State.STOPPED;
LOG.debug("Stopped HTTP Service {} on address {}", serviceName, bindAddress);
} | [
"public",
"synchronized",
"void",
"stop",
"(",
"long",
"quietPeriod",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"Exception",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"STOPPED",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Ignore stop() ... | Stops the HTTP service gracefully and release all resources.
@param quietPeriod the quiet period as described in the documentation of {@link EventExecutorGroup}
@param timeout the maximum amount of time to wait until the executor is
{@linkplain EventExecutorGroup#shutdown()}
regardless if a task was submitted during the quiet period
@param unit the unit of {@code quietPeriod} and {@code timeout}
@throws Exception if there is exception raised during shutdown. | [
"Stops",
"the",
"HTTP",
"service",
"gracefully",
"and",
"release",
"all",
"resources",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L237-L262 | train |
cdapio/netty-http | src/main/java/io/cdap/http/NettyHttpService.java | NettyHttpService.createBootstrap | private ServerBootstrap createBootstrap(final ChannelGroup channelGroup) throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(bossThreadPoolSize,
createDaemonThreadFactory(serviceName + "-boss-thread-%d"));
EventLoopGroup workerGroup = new NioEventLoopGroup(workerThreadPoolSize,
createDaemonThreadFactory(serviceName + "-worker-thread-%d"));
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap
.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
channelGroup.add(ch);
ChannelPipeline pipeline = ch.pipeline();
if (sslHandlerFactory != null) {
// Add SSLHandler if SSL is enabled
pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc()));
}
pipeline.addLast("codec", new HttpServerCodec());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("keepAlive", new HttpServerKeepAliveHandler());
pipeline.addLast("router", new RequestRouter(resourceHandler, httpChunkLimit, sslHandlerFactory != null));
if (eventExecutorGroup == null) {
pipeline.addLast("dispatcher", new HttpDispatcher());
} else {
pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher());
}
if (pipelineModifier != null) {
pipelineModifier.modify(pipeline);
}
}
});
for (Map.Entry<ChannelOption, Object> entry : channelConfigs.entrySet()) {
bootstrap.option(entry.getKey(), entry.getValue());
}
for (Map.Entry<ChannelOption, Object> entry : childChannelConfigs.entrySet()) {
bootstrap.childOption(entry.getKey(), entry.getValue());
}
return bootstrap;
} | java | private ServerBootstrap createBootstrap(final ChannelGroup channelGroup) throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(bossThreadPoolSize,
createDaemonThreadFactory(serviceName + "-boss-thread-%d"));
EventLoopGroup workerGroup = new NioEventLoopGroup(workerThreadPoolSize,
createDaemonThreadFactory(serviceName + "-worker-thread-%d"));
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap
.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
channelGroup.add(ch);
ChannelPipeline pipeline = ch.pipeline();
if (sslHandlerFactory != null) {
// Add SSLHandler if SSL is enabled
pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc()));
}
pipeline.addLast("codec", new HttpServerCodec());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("keepAlive", new HttpServerKeepAliveHandler());
pipeline.addLast("router", new RequestRouter(resourceHandler, httpChunkLimit, sslHandlerFactory != null));
if (eventExecutorGroup == null) {
pipeline.addLast("dispatcher", new HttpDispatcher());
} else {
pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher());
}
if (pipelineModifier != null) {
pipelineModifier.modify(pipeline);
}
}
});
for (Map.Entry<ChannelOption, Object> entry : channelConfigs.entrySet()) {
bootstrap.option(entry.getKey(), entry.getValue());
}
for (Map.Entry<ChannelOption, Object> entry : childChannelConfigs.entrySet()) {
bootstrap.childOption(entry.getKey(), entry.getValue());
}
return bootstrap;
} | [
"private",
"ServerBootstrap",
"createBootstrap",
"(",
"final",
"ChannelGroup",
"channelGroup",
")",
"throws",
"Exception",
"{",
"EventLoopGroup",
"bossGroup",
"=",
"new",
"NioEventLoopGroup",
"(",
"bossThreadPoolSize",
",",
"createDaemonThreadFactory",
"(",
"serviceName",
... | Creates the server bootstrap. | [
"Creates",
"the",
"server",
"bootstrap",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L322-L366 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/RequestRouter.java | RequestRouter.channelRead | @Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
try {
if (exceptionRaised.get()) {
return;
}
if (!(msg instanceof HttpRequest)) {
// If there is no methodInfo, it means the request was already rejected.
// What we received here is just residue of the request, which can be ignored.
if (methodInfo != null) {
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
}
return;
}
HttpRequest request = (HttpRequest) msg;
BasicHttpResponder responder = new BasicHttpResponder(ctx.channel(), sslEnabled);
// Reset the methodInfo for the incoming request error handling
methodInfo = null;
methodInfo = prepareHandleMethod(request, responder, ctx);
if (methodInfo != null) {
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
} else {
if (!responder.isResponded()) {
// If not yet responded, just respond with a not found and close the connection
HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND);
HttpUtil.setContentLength(response, 0);
HttpUtil.setKeepAlive(response, false);
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
// If already responded, just close the connection
ctx.channel().close();
}
}
} finally {
ReferenceCountUtil.release(msg);
}
} | java | @Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
try {
if (exceptionRaised.get()) {
return;
}
if (!(msg instanceof HttpRequest)) {
// If there is no methodInfo, it means the request was already rejected.
// What we received here is just residue of the request, which can be ignored.
if (methodInfo != null) {
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
}
return;
}
HttpRequest request = (HttpRequest) msg;
BasicHttpResponder responder = new BasicHttpResponder(ctx.channel(), sslEnabled);
// Reset the methodInfo for the incoming request error handling
methodInfo = null;
methodInfo = prepareHandleMethod(request, responder, ctx);
if (methodInfo != null) {
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
} else {
if (!responder.isResponded()) {
// If not yet responded, just respond with a not found and close the connection
HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND);
HttpUtil.setContentLength(response, 0);
HttpUtil.setKeepAlive(response, false);
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
// If already responded, just close the connection
ctx.channel().close();
}
}
} finally {
ReferenceCountUtil.release(msg);
}
} | [
"@",
"Override",
"public",
"void",
"channelRead",
"(",
"ChannelHandlerContext",
"ctx",
",",
"Object",
"msg",
")",
"throws",
"Exception",
"{",
"try",
"{",
"if",
"(",
"exceptionRaised",
".",
"get",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
... | If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked
the response will be written back immediately. | [
"If",
"the",
"HttpRequest",
"is",
"valid",
"and",
"handled",
"it",
"will",
"be",
"sent",
"upstream",
"if",
"it",
"cannot",
"be",
"invoked",
"the",
"response",
"will",
"be",
"written",
"back",
"immediately",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/RequestRouter.java#L67-L108 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceModel.java | HttpResourceModel.handle | @SuppressWarnings("unchecked")
public HttpMethodInfo handle(HttpRequest request,
HttpResponder responder, Map<String, String> groupValues) throws Exception {
//TODO: Refactor group values.
try {
if (httpMethods.contains(request.method())) {
//Setup args for reflection call
Object [] args = new Object[paramsInfo.size()];
int idx = 0;
for (Map<Class<? extends Annotation>, ParameterInfo<?>> info : paramsInfo) {
if (info.containsKey(PathParam.class)) {
args[idx] = getPathParamValue(info, groupValues);
}
if (info.containsKey(QueryParam.class)) {
args[idx] = getQueryParamValue(info, request.uri());
}
if (info.containsKey(HeaderParam.class)) {
args[idx] = getHeaderParamValue(info, request);
}
idx++;
}
return new HttpMethodInfo(method, handler, responder, args, exceptionHandler);
} else {
//Found a matching resource but could not find the right HttpMethod so return 405
throw new HandlerException(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format
("Problem accessing: %s. Reason: Method Not Allowed", request.uri()));
}
} catch (Throwable e) {
throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Error in executing request: %s %s", request.method(),
request.uri()), e);
}
} | java | @SuppressWarnings("unchecked")
public HttpMethodInfo handle(HttpRequest request,
HttpResponder responder, Map<String, String> groupValues) throws Exception {
//TODO: Refactor group values.
try {
if (httpMethods.contains(request.method())) {
//Setup args for reflection call
Object [] args = new Object[paramsInfo.size()];
int idx = 0;
for (Map<Class<? extends Annotation>, ParameterInfo<?>> info : paramsInfo) {
if (info.containsKey(PathParam.class)) {
args[idx] = getPathParamValue(info, groupValues);
}
if (info.containsKey(QueryParam.class)) {
args[idx] = getQueryParamValue(info, request.uri());
}
if (info.containsKey(HeaderParam.class)) {
args[idx] = getHeaderParamValue(info, request);
}
idx++;
}
return new HttpMethodInfo(method, handler, responder, args, exceptionHandler);
} else {
//Found a matching resource but could not find the right HttpMethod so return 405
throw new HandlerException(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format
("Problem accessing: %s. Reason: Method Not Allowed", request.uri()));
}
} catch (Throwable e) {
throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR,
String.format("Error in executing request: %s %s", request.method(),
request.uri()), e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"HttpMethodInfo",
"handle",
"(",
"HttpRequest",
"request",
",",
"HttpResponder",
"responder",
",",
"Map",
"<",
"String",
",",
"String",
">",
"groupValues",
")",
"throws",
"Exception",
"{",
"//TODO: Refa... | Handle http Request.
@param request HttpRequest to be handled.
@param responder HttpResponder to write the response.
@param groupValues Values needed for the invocation. | [
"Handle",
"http",
"Request",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceModel.java#L113-L147 | train |
cdapio/netty-http | src/main/java/io/cdap/http/internal/HttpResourceModel.java | HttpResourceModel.createParametersInfos | private List<Map<Class<? extends Annotation>, ParameterInfo<?>>> createParametersInfos(Method method) {
if (method.getParameterTypes().length <= 2) {
return Collections.emptyList();
}
List<Map<Class<? extends Annotation>, ParameterInfo<?>>> result = new ArrayList<>();
Type[] parameterTypes = method.getGenericParameterTypes();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 2; i < parameterAnnotations.length; i++) {
Annotation[] annotations = parameterAnnotations[i];
Map<Class<? extends Annotation>, ParameterInfo<?>> paramAnnotations = new IdentityHashMap<>();
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
ParameterInfo<?> parameterInfo;
if (PathParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createPathParamConverter(parameterTypes[i]));
} else if (QueryParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createQueryParamConverter(parameterTypes[i]));
} else if (HeaderParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createHeaderParamConverter(parameterTypes[i]));
} else {
parameterInfo = ParameterInfo.create(annotation, null);
}
paramAnnotations.put(annotationType, parameterInfo);
}
// Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more.
int presence = 0;
for (Class<? extends Annotation> annotationClass : paramAnnotations.keySet()) {
if (SUPPORTED_PARAM_ANNOTATIONS.contains(annotationClass)) {
presence++;
}
}
if (presence != 1) {
throw new IllegalArgumentException(
String.format("Must have exactly one annotation from %s for parameter %d in method %s",
SUPPORTED_PARAM_ANNOTATIONS, i, method));
}
result.add(Collections.unmodifiableMap(paramAnnotations));
}
return Collections.unmodifiableList(result);
} | java | private List<Map<Class<? extends Annotation>, ParameterInfo<?>>> createParametersInfos(Method method) {
if (method.getParameterTypes().length <= 2) {
return Collections.emptyList();
}
List<Map<Class<? extends Annotation>, ParameterInfo<?>>> result = new ArrayList<>();
Type[] parameterTypes = method.getGenericParameterTypes();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 2; i < parameterAnnotations.length; i++) {
Annotation[] annotations = parameterAnnotations[i];
Map<Class<? extends Annotation>, ParameterInfo<?>> paramAnnotations = new IdentityHashMap<>();
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
ParameterInfo<?> parameterInfo;
if (PathParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createPathParamConverter(parameterTypes[i]));
} else if (QueryParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createQueryParamConverter(parameterTypes[i]));
} else if (HeaderParam.class.isAssignableFrom(annotationType)) {
parameterInfo = ParameterInfo.create(annotation,
ParamConvertUtils.createHeaderParamConverter(parameterTypes[i]));
} else {
parameterInfo = ParameterInfo.create(annotation, null);
}
paramAnnotations.put(annotationType, parameterInfo);
}
// Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more.
int presence = 0;
for (Class<? extends Annotation> annotationClass : paramAnnotations.keySet()) {
if (SUPPORTED_PARAM_ANNOTATIONS.contains(annotationClass)) {
presence++;
}
}
if (presence != 1) {
throw new IllegalArgumentException(
String.format("Must have exactly one annotation from %s for parameter %d in method %s",
SUPPORTED_PARAM_ANNOTATIONS, i, method));
}
result.add(Collections.unmodifiableMap(paramAnnotations));
}
return Collections.unmodifiableList(result);
} | [
"private",
"List",
"<",
"Map",
"<",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
",",
"ParameterInfo",
"<",
"?",
">",
">",
">",
"createParametersInfos",
"(",
"Method",
"method",
")",
"{",
"if",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
".",
... | Gathers all parameters' annotations for the given method, starting from the third parameter. | [
"Gathers",
"all",
"parameters",
"annotations",
"for",
"the",
"given",
"method",
"starting",
"from",
"the",
"third",
"parameter",
"."
] | 02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f | https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceModel.java#L209-L259 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java | ServiceFuture.fromResponse | public static <T> ServiceFuture<T> fromResponse(final Observable<ServiceResponse<T>> observable) {
final ServiceFuture<T> serviceFuture = new ServiceFuture<>();
serviceFuture.subscription = observable
.last()
.subscribe(new Action1<ServiceResponse<T>>() {
@Override
public void call(ServiceResponse<T> t) {
serviceFuture.set(t.body());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | java | public static <T> ServiceFuture<T> fromResponse(final Observable<ServiceResponse<T>> observable) {
final ServiceFuture<T> serviceFuture = new ServiceFuture<>();
serviceFuture.subscription = observable
.last()
.subscribe(new Action1<ServiceResponse<T>>() {
@Override
public void call(ServiceResponse<T> t) {
serviceFuture.set(t.body());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | [
"public",
"static",
"<",
"T",
">",
"ServiceFuture",
"<",
"T",
">",
"fromResponse",
"(",
"final",
"Observable",
"<",
"ServiceResponse",
"<",
"T",
">",
">",
"observable",
")",
"{",
"final",
"ServiceFuture",
"<",
"T",
">",
"serviceFuture",
"=",
"new",
"Servic... | Creates a ServiceCall from an observable object.
@param observable the observable to create from
@param <T> the type of the response
@return the created ServiceCall | [
"Creates",
"a",
"ServiceCall",
"from",
"an",
"observable",
"object",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java#L39-L55 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java | ServiceFuture.fromResponse | public static <T> ServiceFuture<T> fromResponse(final Observable<ServiceResponse<T>> observable, final ServiceCallback<T> callback) {
final ServiceFuture<T> serviceFuture = new ServiceFuture<>();
serviceFuture.subscription = observable
.last()
.subscribe(new Action1<ServiceResponse<T>>() {
@Override
public void call(ServiceResponse<T> t) {
if (callback != null) {
callback.success(t.body());
}
serviceFuture.set(t.body());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
if (callback != null) {
callback.failure(throwable);
}
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | java | public static <T> ServiceFuture<T> fromResponse(final Observable<ServiceResponse<T>> observable, final ServiceCallback<T> callback) {
final ServiceFuture<T> serviceFuture = new ServiceFuture<>();
serviceFuture.subscription = observable
.last()
.subscribe(new Action1<ServiceResponse<T>>() {
@Override
public void call(ServiceResponse<T> t) {
if (callback != null) {
callback.success(t.body());
}
serviceFuture.set(t.body());
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
if (callback != null) {
callback.failure(throwable);
}
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | [
"public",
"static",
"<",
"T",
">",
"ServiceFuture",
"<",
"T",
">",
"fromResponse",
"(",
"final",
"Observable",
"<",
"ServiceResponse",
"<",
"T",
">",
">",
"observable",
",",
"final",
"ServiceCallback",
"<",
"T",
">",
"callback",
")",
"{",
"final",
"Service... | Creates a ServiceCall from an observable object and a callback.
@param observable the observable to create from
@param callback the callback to call when events happen
@param <T> the type of the response
@return the created ServiceCall | [
"Creates",
"a",
"ServiceCall",
"from",
"an",
"observable",
"object",
"and",
"a",
"callback",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java#L65-L87 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java | ServiceFuture.fromBody | public static ServiceFuture<Void> fromBody(final Completable completable, final ServiceCallback<Void> callback) {
final ServiceFuture<Void> serviceFuture = new ServiceFuture<>();
completable.subscribe(new Action0() {
Void value = null;
@Override
public void call() {
if (callback != null) {
callback.success(value);
}
serviceFuture.set(value);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
if (callback != null) {
callback.failure(throwable);
}
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | java | public static ServiceFuture<Void> fromBody(final Completable completable, final ServiceCallback<Void> callback) {
final ServiceFuture<Void> serviceFuture = new ServiceFuture<>();
completable.subscribe(new Action0() {
Void value = null;
@Override
public void call() {
if (callback != null) {
callback.success(value);
}
serviceFuture.set(value);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
if (callback != null) {
callback.failure(throwable);
}
serviceFuture.setException(throwable);
}
});
return serviceFuture;
} | [
"public",
"static",
"ServiceFuture",
"<",
"Void",
">",
"fromBody",
"(",
"final",
"Completable",
"completable",
",",
"final",
"ServiceCallback",
"<",
"Void",
">",
"callback",
")",
"{",
"final",
"ServiceFuture",
"<",
"Void",
">",
"serviceFuture",
"=",
"new",
"Se... | Creates a ServiceFuture from an Completable object and a callback.
@param completable the completable to create from
@param callback the callback to call when event happen
@return the created ServiceFuture | [
"Creates",
"a",
"ServiceFuture",
"from",
"an",
"Completable",
"object",
"and",
"a",
"callback",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/ServiceFuture.java#L128-L149 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourcesCachedImpl.java | ExternalChildResourcesCachedImpl.cacheCollection | protected void cacheCollection() {
this.clear();
for (FluentModelTImpl childResource : this.listChildResources()) {
this.childCollection.put(childResource.childResourceKey(), childResource);
}
} | java | protected void cacheCollection() {
this.clear();
for (FluentModelTImpl childResource : this.listChildResources()) {
this.childCollection.put(childResource.childResourceKey(), childResource);
}
} | [
"protected",
"void",
"cacheCollection",
"(",
")",
"{",
"this",
".",
"clear",
"(",
")",
";",
"for",
"(",
"FluentModelTImpl",
"childResource",
":",
"this",
".",
"listChildResources",
"(",
")",
")",
"{",
"this",
".",
"childCollection",
".",
"put",
"(",
"child... | Initializes the external child resource collection. | [
"Initializes",
"the",
"external",
"child",
"resource",
"collection",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourcesCachedImpl.java#L178-L183 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.addDependencyGraph | public void addDependencyGraph(DAGraph<DataT, NodeT> dependencyGraph) {
this.rootNode.addDependency(dependencyGraph.rootNode.key());
Map<String, NodeT> sourceNodeTable = dependencyGraph.nodeTable;
Map<String, NodeT> targetNodeTable = this.nodeTable;
this.merge(sourceNodeTable, targetNodeTable);
dependencyGraph.parentDAGs.add(this);
if (this.hasParents()) {
this.bubbleUpNodeTable(this, new LinkedList<String>());
}
} | java | public void addDependencyGraph(DAGraph<DataT, NodeT> dependencyGraph) {
this.rootNode.addDependency(dependencyGraph.rootNode.key());
Map<String, NodeT> sourceNodeTable = dependencyGraph.nodeTable;
Map<String, NodeT> targetNodeTable = this.nodeTable;
this.merge(sourceNodeTable, targetNodeTable);
dependencyGraph.parentDAGs.add(this);
if (this.hasParents()) {
this.bubbleUpNodeTable(this, new LinkedList<String>());
}
} | [
"public",
"void",
"addDependencyGraph",
"(",
"DAGraph",
"<",
"DataT",
",",
"NodeT",
">",
"dependencyGraph",
")",
"{",
"this",
".",
"rootNode",
".",
"addDependency",
"(",
"dependencyGraph",
".",
"rootNode",
".",
"key",
"(",
")",
")",
";",
"Map",
"<",
"Strin... | Mark root of this DAG depends on given DAG's root.
@param dependencyGraph the dependency DAG | [
"Mark",
"root",
"of",
"this",
"DAG",
"depends",
"on",
"given",
"DAG",
"s",
"root",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L101-L110 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.prepareForEnumeration | public void prepareForEnumeration() {
if (isPreparer()) {
for (NodeT node : nodeTable.values()) {
// Prepare each node for traversal
node.initialize();
if (!this.isRootNode(node)) {
// Mark other sub-DAGs as non-preparer
node.setPreparer(false);
}
}
initializeDependentKeys();
initializeQueue();
}
} | java | public void prepareForEnumeration() {
if (isPreparer()) {
for (NodeT node : nodeTable.values()) {
// Prepare each node for traversal
node.initialize();
if (!this.isRootNode(node)) {
// Mark other sub-DAGs as non-preparer
node.setPreparer(false);
}
}
initializeDependentKeys();
initializeQueue();
}
} | [
"public",
"void",
"prepareForEnumeration",
"(",
")",
"{",
"if",
"(",
"isPreparer",
"(",
")",
")",
"{",
"for",
"(",
"NodeT",
"node",
":",
"nodeTable",
".",
"values",
"(",
")",
")",
"{",
"// Prepare each node for traversal",
"node",
".",
"initialize",
"(",
"... | Prepares this DAG for node enumeration using getNext method, each call to getNext returns next node
in the DAG with no dependencies. | [
"Prepares",
"this",
"DAG",
"for",
"node",
"enumeration",
"using",
"getNext",
"method",
"each",
"call",
"to",
"getNext",
"returns",
"next",
"node",
"in",
"the",
"DAG",
"with",
"no",
"dependencies",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L125-L138 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.getNext | public NodeT getNext() {
String nextItemKey = queue.poll();
if (nextItemKey == null) {
return null;
}
return nodeTable.get(nextItemKey);
} | java | public NodeT getNext() {
String nextItemKey = queue.poll();
if (nextItemKey == null) {
return null;
}
return nodeTable.get(nextItemKey);
} | [
"public",
"NodeT",
"getNext",
"(",
")",
"{",
"String",
"nextItemKey",
"=",
"queue",
".",
"poll",
"(",
")",
";",
"if",
"(",
"nextItemKey",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"nodeTable",
".",
"get",
"(",
"nextItemKey",
")",
... | Gets next node in the DAG which has no dependency or all of it's dependencies are resolved and
ready to be consumed.
@return next node or null if all the nodes have been explored or no node is available at this moment. | [
"Gets",
"next",
"node",
"in",
"the",
"DAG",
"which",
"has",
"no",
"dependency",
"or",
"all",
"of",
"it",
"s",
"dependencies",
"are",
"resolved",
"and",
"ready",
"to",
"be",
"consumed",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L146-L152 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.reportCompletion | public void reportCompletion(NodeT completed) {
completed.setPreparer(true);
String dependency = completed.key();
for (String dependentKey : nodeTable.get(dependency).dependentKeys()) {
DAGNode<DataT, NodeT> dependent = nodeTable.get(dependentKey);
dependent.lock().lock();
try {
dependent.onSuccessfulResolution(dependency);
if (dependent.hasAllResolved()) {
queue.add(dependent.key());
}
} finally {
dependent.lock().unlock();
}
}
} | java | public void reportCompletion(NodeT completed) {
completed.setPreparer(true);
String dependency = completed.key();
for (String dependentKey : nodeTable.get(dependency).dependentKeys()) {
DAGNode<DataT, NodeT> dependent = nodeTable.get(dependentKey);
dependent.lock().lock();
try {
dependent.onSuccessfulResolution(dependency);
if (dependent.hasAllResolved()) {
queue.add(dependent.key());
}
} finally {
dependent.lock().unlock();
}
}
} | [
"public",
"void",
"reportCompletion",
"(",
"NodeT",
"completed",
")",
"{",
"completed",
".",
"setPreparer",
"(",
"true",
")",
";",
"String",
"dependency",
"=",
"completed",
".",
"key",
"(",
")",
";",
"for",
"(",
"String",
"dependentKey",
":",
"nodeTable",
... | Reports that a node is resolved hence other nodes depends on it can consume it.
@param completed the node ready to be consumed | [
"Reports",
"that",
"a",
"node",
"is",
"resolved",
"hence",
"other",
"nodes",
"depends",
"on",
"it",
"can",
"consume",
"it",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L159-L174 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.reportError | public void reportError(NodeT faulted, Throwable throwable) {
faulted.setPreparer(true);
String dependency = faulted.key();
for (String dependentKey : nodeTable.get(dependency).dependentKeys()) {
DAGNode<DataT, NodeT> dependent = nodeTable.get(dependentKey);
dependent.lock().lock();
try {
dependent.onFaultedResolution(dependency, throwable);
if (dependent.hasAllResolved()) {
queue.add(dependent.key());
}
} finally {
dependent.lock().unlock();
}
}
} | java | public void reportError(NodeT faulted, Throwable throwable) {
faulted.setPreparer(true);
String dependency = faulted.key();
for (String dependentKey : nodeTable.get(dependency).dependentKeys()) {
DAGNode<DataT, NodeT> dependent = nodeTable.get(dependentKey);
dependent.lock().lock();
try {
dependent.onFaultedResolution(dependency, throwable);
if (dependent.hasAllResolved()) {
queue.add(dependent.key());
}
} finally {
dependent.lock().unlock();
}
}
} | [
"public",
"void",
"reportError",
"(",
"NodeT",
"faulted",
",",
"Throwable",
"throwable",
")",
"{",
"faulted",
".",
"setPreparer",
"(",
"true",
")",
";",
"String",
"dependency",
"=",
"faulted",
".",
"key",
"(",
")",
";",
"for",
"(",
"String",
"dependentKey"... | Reports that a node is faulted.
@param faulted the node faulted
@param throwable the reason for fault | [
"Reports",
"that",
"a",
"node",
"is",
"faulted",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L182-L197 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.initializeQueue | private void initializeQueue() {
this.queue.clear();
for (Map.Entry<String, NodeT> entry: nodeTable.entrySet()) {
if (!entry.getValue().hasDependencies()) {
this.queue.add(entry.getKey());
}
}
if (queue.isEmpty()) {
throw new IllegalStateException("Detected circular dependency");
}
} | java | private void initializeQueue() {
this.queue.clear();
for (Map.Entry<String, NodeT> entry: nodeTable.entrySet()) {
if (!entry.getValue().hasDependencies()) {
this.queue.add(entry.getKey());
}
}
if (queue.isEmpty()) {
throw new IllegalStateException("Detected circular dependency");
}
} | [
"private",
"void",
"initializeQueue",
"(",
")",
"{",
"this",
".",
"queue",
".",
"clear",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"NodeT",
">",
"entry",
":",
"nodeTable",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
... | Initializes the queue that tracks the next set of nodes with no dependencies or
whose dependencies are resolved. | [
"Initializes",
"the",
"queue",
"that",
"tracks",
"the",
"next",
"set",
"of",
"nodes",
"with",
"no",
"dependencies",
"or",
"whose",
"dependencies",
"are",
"resolved",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L234-L244 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.merge | private void merge(Map<String, NodeT> source, Map<String, NodeT> target) {
for (Map.Entry<String, NodeT> entry : source.entrySet()) {
String key = entry.getKey();
if (!target.containsKey(key)) {
target.put(key, entry.getValue());
}
}
} | java | private void merge(Map<String, NodeT> source, Map<String, NodeT> target) {
for (Map.Entry<String, NodeT> entry : source.entrySet()) {
String key = entry.getKey();
if (!target.containsKey(key)) {
target.put(key, entry.getValue());
}
}
} | [
"private",
"void",
"merge",
"(",
"Map",
"<",
"String",
",",
"NodeT",
">",
"source",
",",
"Map",
"<",
"String",
",",
"NodeT",
">",
"target",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"NodeT",
">",
"entry",
":",
"source",
".",
... | Copies entries in the source map to target map.
@param source source map
@param target target map | [
"Copies",
"entries",
"in",
"the",
"source",
"map",
"to",
"target",
"map",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L252-L259 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.bubbleUpNodeTable | private void bubbleUpNodeTable(DAGraph<DataT, NodeT> from, LinkedList<String> path) {
if (path.contains(from.rootNode.key())) {
path.push(from.rootNode.key()); // For better error message
throw new IllegalStateException("Detected circular dependency: " + StringUtils.join(path, " -> "));
}
path.push(from.rootNode.key());
for (DAGraph<DataT, NodeT> to : from.parentDAGs) {
this.merge(from.nodeTable, to.nodeTable);
this.bubbleUpNodeTable(to, path);
}
path.pop();
} | java | private void bubbleUpNodeTable(DAGraph<DataT, NodeT> from, LinkedList<String> path) {
if (path.contains(from.rootNode.key())) {
path.push(from.rootNode.key()); // For better error message
throw new IllegalStateException("Detected circular dependency: " + StringUtils.join(path, " -> "));
}
path.push(from.rootNode.key());
for (DAGraph<DataT, NodeT> to : from.parentDAGs) {
this.merge(from.nodeTable, to.nodeTable);
this.bubbleUpNodeTable(to, path);
}
path.pop();
} | [
"private",
"void",
"bubbleUpNodeTable",
"(",
"DAGraph",
"<",
"DataT",
",",
"NodeT",
">",
"from",
",",
"LinkedList",
"<",
"String",
">",
"path",
")",
"{",
"if",
"(",
"path",
".",
"contains",
"(",
"from",
".",
"rootNode",
".",
"key",
"(",
")",
")",
")"... | Propagates node table of given DAG to all of it ancestors. | [
"Propagates",
"node",
"table",
"of",
"given",
"DAG",
"to",
"all",
"of",
"it",
"ancestors",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L264-L275 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.create | public static IndexableTaskItem create(final FunctionalTaskItem taskItem) {
return new IndexableTaskItem() {
@Override
protected Observable<Indexable> invokeTaskAsync(TaskGroup.InvocationContext context) {
FunctionalTaskItem.Context fContext = new FunctionalTaskItem.Context(this);
fContext.setInnerContext(context);
return taskItem.call(fContext);
}
};
} | java | public static IndexableTaskItem create(final FunctionalTaskItem taskItem) {
return new IndexableTaskItem() {
@Override
protected Observable<Indexable> invokeTaskAsync(TaskGroup.InvocationContext context) {
FunctionalTaskItem.Context fContext = new FunctionalTaskItem.Context(this);
fContext.setInnerContext(context);
return taskItem.call(fContext);
}
};
} | [
"public",
"static",
"IndexableTaskItem",
"create",
"(",
"final",
"FunctionalTaskItem",
"taskItem",
")",
"{",
"return",
"new",
"IndexableTaskItem",
"(",
")",
"{",
"@",
"Override",
"protected",
"Observable",
"<",
"Indexable",
">",
"invokeTaskAsync",
"(",
"TaskGroup",
... | Creates an IndexableTaskItem from provided FunctionalTaskItem.
@param taskItem functional TaskItem
@return IndexableTaskItem | [
"Creates",
"an",
"IndexableTaskItem",
"from",
"provided",
"FunctionalTaskItem",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L63-L72 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.addeDependency | @SuppressWarnings("unchecked")
protected String addeDependency(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addDependency(dependency);
} | java | @SuppressWarnings("unchecked")
protected String addeDependency(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addDependency(dependency);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"String",
"addeDependency",
"(",
"Appliable",
"<",
"?",
"extends",
"Indexable",
">",
"appliable",
")",
"{",
"TaskGroup",
".",
"HasTaskGroup",
"dependency",
"=",
"(",
"TaskGroup",
".",
"HasTaskGroup",... | Add an appliable dependency for this task item.
@param appliable the appliable dependency.
@return the key to be used as parameter to taskResult(string) method to retrieve updated dependency | [
"Add",
"an",
"appliable",
"dependency",
"for",
"this",
"task",
"item",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L136-L140 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.addPostRunDependent | public String addPostRunDependent(FunctionalTaskItem dependent) {
Objects.requireNonNull(dependent);
return this.taskGroup().addPostRunDependent(dependent);
} | java | public String addPostRunDependent(FunctionalTaskItem dependent) {
Objects.requireNonNull(dependent);
return this.taskGroup().addPostRunDependent(dependent);
} | [
"public",
"String",
"addPostRunDependent",
"(",
"FunctionalTaskItem",
"dependent",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"dependent",
")",
";",
"return",
"this",
".",
"taskGroup",
"(",
")",
".",
"addPostRunDependent",
"(",
"dependent",
")",
";",
"}"
] | Add a "post-run" dependent task item for this task item.
@param dependent the "post-run" dependent task item.
@return key to be used as parameter to taskResult(string) method to retrieve result of root
task in the given dependent task group | [
"Add",
"a",
"post",
"-",
"run",
"dependent",
"task",
"item",
"for",
"this",
"task",
"item",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L162-L165 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.addPostRunDependent | @SuppressWarnings("unchecked")
protected String addPostRunDependent(Creatable<? extends Indexable> creatable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) creatable;
return this.addPostRunDependent(dependency);
} | java | @SuppressWarnings("unchecked")
protected String addPostRunDependent(Creatable<? extends Indexable> creatable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) creatable;
return this.addPostRunDependent(dependency);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"String",
"addPostRunDependent",
"(",
"Creatable",
"<",
"?",
"extends",
"Indexable",
">",
"creatable",
")",
"{",
"TaskGroup",
".",
"HasTaskGroup",
"dependency",
"=",
"(",
"TaskGroup",
".",
"HasTaskGr... | Add a creatable "post-run" dependent for this task item.
@param creatable the creatable "post-run" dependent.
@return the key to be used as parameter to taskResult(string) method to retrieve created "post-run" dependent | [
"Add",
"a",
"creatable",
"post",
"-",
"run",
"dependent",
"for",
"this",
"task",
"item",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L186-L190 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.addPostRunDependent | @SuppressWarnings("unchecked")
protected String addPostRunDependent(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addPostRunDependent(dependency);
} | java | @SuppressWarnings("unchecked")
protected String addPostRunDependent(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addPostRunDependent(dependency);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"String",
"addPostRunDependent",
"(",
"Appliable",
"<",
"?",
"extends",
"Indexable",
">",
"appliable",
")",
"{",
"TaskGroup",
".",
"HasTaskGroup",
"dependency",
"=",
"(",
"TaskGroup",
".",
"HasTaskGr... | Add an appliable "post-run" dependent for this task item.
@param appliable the appliable "post-run" dependent.
@return the key to be used as parameter to taskResult(string) method to retrieve updated "post-run" dependent | [
"Add",
"an",
"appliable",
"post",
"-",
"run",
"dependent",
"for",
"this",
"task",
"item",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L198-L202 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java | IndexableTaskItem.taskResult | @SuppressWarnings("unchecked")
protected <T extends Indexable> T taskResult(String key) {
Indexable result = this.taskGroup.taskResult(key);
if (result == null) {
return null;
} else {
T castedResult = (T) result;
return castedResult;
}
} | java | @SuppressWarnings("unchecked")
protected <T extends Indexable> T taskResult(String key) {
Indexable result = this.taskGroup.taskResult(key);
if (result == null) {
return null;
} else {
T castedResult = (T) result;
return castedResult;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"T",
"extends",
"Indexable",
">",
"T",
"taskResult",
"(",
"String",
"key",
")",
"{",
"Indexable",
"result",
"=",
"this",
".",
"taskGroup",
".",
"taskResult",
"(",
"key",
")",
";",
"if",
... | Get result of one of the task that belongs to this task's task group.
@param key the task key
@param <T> the actual type of the task result
@return the task result, null will be returned if task has not produced a result yet | [
"Get",
"result",
"of",
"one",
"of",
"the",
"task",
"that",
"belongs",
"to",
"this",
"task",
"s",
"task",
"group",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/IndexableTaskItem.java#L224-L233 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/Region.java | Region.create | public static Region create(String name, String label) {
Region region = VALUES_BY_NAME.get(name.toLowerCase());
if (region != null) {
return region;
} else {
return new Region(name, label);
}
} | java | public static Region create(String name, String label) {
Region region = VALUES_BY_NAME.get(name.toLowerCase());
if (region != null) {
return region;
} else {
return new Region(name, label);
}
} | [
"public",
"static",
"Region",
"create",
"(",
"String",
"name",
",",
"String",
"label",
")",
"{",
"Region",
"region",
"=",
"VALUES_BY_NAME",
".",
"get",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"region",
"!=",
"null",
")",
"{",
... | Creates a region from a name and a label.
@param name the uniquely identifiable name of the region
@param label the label of the region
@return the newly created region | [
"Creates",
"a",
"region",
"from",
"a",
"name",
"and",
"a",
"label",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/Region.java#L129-L136 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/Region.java | Region.fromName | public static Region fromName(String name) {
if (name == null) {
return null;
}
Region region = VALUES_BY_NAME.get(name.toLowerCase().replace(" ", ""));
if (region != null) {
return region;
} else {
return Region.create(name.toLowerCase().replace(" ", ""), name);
}
} | java | public static Region fromName(String name) {
if (name == null) {
return null;
}
Region region = VALUES_BY_NAME.get(name.toLowerCase().replace(" ", ""));
if (region != null) {
return region;
} else {
return Region.create(name.toLowerCase().replace(" ", ""), name);
}
} | [
"public",
"static",
"Region",
"fromName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Region",
"region",
"=",
"VALUES_BY_NAME",
".",
"get",
"(",
"name",
".",
"toLowerCase",
"(",
")",
".",
"... | Parses a name into a Region object and creates a new Region instance if not found among the existing ones.
@param name a region name
@return the parsed or created region | [
"Parses",
"a",
"name",
"into",
"a",
"Region",
"object",
"and",
"creates",
"a",
"new",
"Region",
"instance",
"if",
"not",
"found",
"among",
"the",
"existing",
"ones",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/Region.java#L179-L190 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourceCollectionImpl.java | ExternalChildResourceCollectionImpl.prepareForFutureCommitOrPostRun | protected FluentModelTImpl prepareForFutureCommitOrPostRun(FluentModelTImpl childResource) {
if (this.isPostRunMode) {
if (!childResource.taskGroup().dependsOn(this.parentTaskGroup)) {
this.parentTaskGroup.addPostRunDependentTaskGroup(childResource.taskGroup());
}
return childResource;
} else {
return childResource;
}
} | java | protected FluentModelTImpl prepareForFutureCommitOrPostRun(FluentModelTImpl childResource) {
if (this.isPostRunMode) {
if (!childResource.taskGroup().dependsOn(this.parentTaskGroup)) {
this.parentTaskGroup.addPostRunDependentTaskGroup(childResource.taskGroup());
}
return childResource;
} else {
return childResource;
}
} | [
"protected",
"FluentModelTImpl",
"prepareForFutureCommitOrPostRun",
"(",
"FluentModelTImpl",
"childResource",
")",
"{",
"if",
"(",
"this",
".",
"isPostRunMode",
")",
"{",
"if",
"(",
"!",
"childResource",
".",
"taskGroup",
"(",
")",
".",
"dependsOn",
"(",
"this",
... | Mark the given child resource as the post run dependent of the parent of this collection.
@param childResource the child resource | [
"Mark",
"the",
"given",
"child",
"resource",
"as",
"the",
"post",
"run",
"dependent",
"of",
"the",
"parent",
"of",
"this",
"collection",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourceCollectionImpl.java#L113-L122 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourceCollectionImpl.java | ExternalChildResourceCollectionImpl.find | protected FluentModelTImpl find(String key) {
for (Map.Entry<String, FluentModelTImpl> entry : this.childCollection.entrySet()) {
if (entry.getKey().equalsIgnoreCase(key)) {
return entry.getValue();
}
}
return null;
} | java | protected FluentModelTImpl find(String key) {
for (Map.Entry<String, FluentModelTImpl> entry : this.childCollection.entrySet()) {
if (entry.getKey().equalsIgnoreCase(key)) {
return entry.getValue();
}
}
return null;
} | [
"protected",
"FluentModelTImpl",
"find",
"(",
"String",
"key",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"FluentModelTImpl",
">",
"entry",
":",
"this",
".",
"childCollection",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
... | Finds a child resource with the given key.
@param key the child resource key
@return null if no child resource exists with the given name else the child resource | [
"Finds",
"a",
"child",
"resource",
"with",
"the",
"given",
"key",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourceCollectionImpl.java#L294-L301 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceFuture.java | AzureServiceFuture.fromPageResponse | public static <E> ServiceFuture<List<E>> fromPageResponse(Observable<ServiceResponse<Page<E>>> first, final Func1<String, Observable<ServiceResponse<Page<E>>>> next, final ListOperationCallback<E> callback) {
final AzureServiceFuture<List<E>> serviceCall = new AzureServiceFuture<>();
final PagingSubscriber<E> subscriber = new PagingSubscriber<>(serviceCall, next, callback);
serviceCall.setSubscription(first
.single()
.subscribe(subscriber));
return serviceCall;
} | java | public static <E> ServiceFuture<List<E>> fromPageResponse(Observable<ServiceResponse<Page<E>>> first, final Func1<String, Observable<ServiceResponse<Page<E>>>> next, final ListOperationCallback<E> callback) {
final AzureServiceFuture<List<E>> serviceCall = new AzureServiceFuture<>();
final PagingSubscriber<E> subscriber = new PagingSubscriber<>(serviceCall, next, callback);
serviceCall.setSubscription(first
.single()
.subscribe(subscriber));
return serviceCall;
} | [
"public",
"static",
"<",
"E",
">",
"ServiceFuture",
"<",
"List",
"<",
"E",
">",
">",
"fromPageResponse",
"(",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"E",
">",
">",
">",
"first",
",",
"final",
"Func1",
"<",
"String",
",",
"Observable",
... | Creates a ServiceCall from a paging operation.
@param first the observable to the first page
@param next the observable to poll subsequent pages
@param callback the client-side callback
@param <E> the element type
@return the future based ServiceCall | [
"Creates",
"a",
"ServiceCall",
"from",
"a",
"paging",
"operation",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceFuture.java#L38-L45 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceFuture.java | AzureServiceFuture.fromHeaderPageResponse | public static <E, V> ServiceFuture<List<E>> fromHeaderPageResponse(Observable<ServiceResponseWithHeaders<Page<E>, V>> first, final Func1<String, Observable<ServiceResponseWithHeaders<Page<E>, V>>> next, final ListOperationCallback<E> callback) {
final AzureServiceFuture<List<E>> serviceCall = new AzureServiceFuture<>();
final PagingSubscriber<E> subscriber = new PagingSubscriber<>(serviceCall, new Func1<String, Observable<ServiceResponse<Page<E>>>>() {
@Override
public Observable<ServiceResponse<Page<E>>> call(String s) {
return next.call(s)
.map(new Func1<ServiceResponseWithHeaders<Page<E>, V>, ServiceResponse<Page<E>>>() {
@Override
public ServiceResponse<Page<E>> call(ServiceResponseWithHeaders<Page<E>, V> pageVServiceResponseWithHeaders) {
return pageVServiceResponseWithHeaders;
}
});
}
}, callback);
serviceCall.setSubscription(first
.single()
.subscribe(subscriber));
return serviceCall;
} | java | public static <E, V> ServiceFuture<List<E>> fromHeaderPageResponse(Observable<ServiceResponseWithHeaders<Page<E>, V>> first, final Func1<String, Observable<ServiceResponseWithHeaders<Page<E>, V>>> next, final ListOperationCallback<E> callback) {
final AzureServiceFuture<List<E>> serviceCall = new AzureServiceFuture<>();
final PagingSubscriber<E> subscriber = new PagingSubscriber<>(serviceCall, new Func1<String, Observable<ServiceResponse<Page<E>>>>() {
@Override
public Observable<ServiceResponse<Page<E>>> call(String s) {
return next.call(s)
.map(new Func1<ServiceResponseWithHeaders<Page<E>, V>, ServiceResponse<Page<E>>>() {
@Override
public ServiceResponse<Page<E>> call(ServiceResponseWithHeaders<Page<E>, V> pageVServiceResponseWithHeaders) {
return pageVServiceResponseWithHeaders;
}
});
}
}, callback);
serviceCall.setSubscription(first
.single()
.subscribe(subscriber));
return serviceCall;
} | [
"public",
"static",
"<",
"E",
",",
"V",
">",
"ServiceFuture",
"<",
"List",
"<",
"E",
">",
">",
"fromHeaderPageResponse",
"(",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"E",
">",
",",
"V",
">",
">",
"first",
",",
"final",
"Func1",... | Creates a ServiceCall from a paging operation that returns a header response.
@param first the observable to the first page
@param next the observable to poll subsequent pages
@param callback the client-side callback
@param <E> the element type
@param <V> the header object type
@return the future based ServiceCall | [
"Creates",
"a",
"ServiceCall",
"from",
"a",
"paging",
"operation",
"that",
"returns",
"a",
"header",
"response",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceFuture.java#L57-L75 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java | FlatteningDeserializer.findNestedNode | private static JsonNode findNestedNode(JsonNode jsonNode, String composedKey) {
String[] jsonNodeKeys = splitKeyByFlatteningDots(composedKey);
for (String jsonNodeKey : jsonNodeKeys) {
jsonNode = jsonNode.get(unescapeEscapedDots(jsonNodeKey));
if (jsonNode == null) {
return null;
}
}
return jsonNode;
} | java | private static JsonNode findNestedNode(JsonNode jsonNode, String composedKey) {
String[] jsonNodeKeys = splitKeyByFlatteningDots(composedKey);
for (String jsonNodeKey : jsonNodeKeys) {
jsonNode = jsonNode.get(unescapeEscapedDots(jsonNodeKey));
if (jsonNode == null) {
return null;
}
}
return jsonNode;
} | [
"private",
"static",
"JsonNode",
"findNestedNode",
"(",
"JsonNode",
"jsonNode",
",",
"String",
"composedKey",
")",
"{",
"String",
"[",
"]",
"jsonNodeKeys",
"=",
"splitKeyByFlatteningDots",
"(",
"composedKey",
")",
";",
"for",
"(",
"String",
"jsonNodeKey",
":",
"... | Given a json node, find a nested node using given composed key.
@param jsonNode the parent json node
@param composedKey a key combines multiple keys using flattening dots.
Flattening dots are dot character '.' those are not preceded by slash '\'
Each flattening dot represents a level with following key as field key in that level
@return nested json node located using given composed key | [
"Given",
"a",
"json",
"node",
"find",
"a",
"nested",
"node",
"using",
"given",
"composed",
"key",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java#L168-L177 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java | FlatteningDeserializer.newJsonParserForNode | private static JsonParser newJsonParserForNode(JsonNode jsonNode) throws IOException {
JsonParser parser = new JsonFactory().createParser(jsonNode.toString());
parser.nextToken();
return parser;
} | java | private static JsonParser newJsonParserForNode(JsonNode jsonNode) throws IOException {
JsonParser parser = new JsonFactory().createParser(jsonNode.toString());
parser.nextToken();
return parser;
} | [
"private",
"static",
"JsonParser",
"newJsonParserForNode",
"(",
"JsonNode",
"jsonNode",
")",
"throws",
"IOException",
"{",
"JsonParser",
"parser",
"=",
"new",
"JsonFactory",
"(",
")",
".",
"createParser",
"(",
"jsonNode",
".",
"toString",
"(",
")",
")",
";",
"... | Create a JsonParser for a given json node.
@param jsonNode the json node
@return the json parser
@throws IOException | [
"Create",
"a",
"JsonParser",
"for",
"a",
"given",
"json",
"node",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java#L229-L233 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java | ExternalChildResourceImpl.addDependency | protected String addDependency(FunctionalTaskItem dependency) {
Objects.requireNonNull(dependency);
return this.taskGroup().addDependency(dependency);
} | java | protected String addDependency(FunctionalTaskItem dependency) {
Objects.requireNonNull(dependency);
return this.taskGroup().addDependency(dependency);
} | [
"protected",
"String",
"addDependency",
"(",
"FunctionalTaskItem",
"dependency",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"dependency",
")",
";",
"return",
"this",
".",
"taskGroup",
"(",
")",
".",
"addDependency",
"(",
"dependency",
")",
";",
"}"
] | Add a dependency task item for this model.
@param dependency the dependency task item.
@return key to be used as parameter to taskResult(string) method to retrieve result the task item | [
"Add",
"a",
"dependency",
"task",
"item",
"for",
"this",
"model",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java#L201-L204 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java | ExternalChildResourceImpl.addDependency | protected String addDependency(TaskGroup.HasTaskGroup dependency) {
Objects.requireNonNull(dependency);
this.taskGroup().addDependencyTaskGroup(dependency.taskGroup());
return dependency.taskGroup().key();
} | java | protected String addDependency(TaskGroup.HasTaskGroup dependency) {
Objects.requireNonNull(dependency);
this.taskGroup().addDependencyTaskGroup(dependency.taskGroup());
return dependency.taskGroup().key();
} | [
"protected",
"String",
"addDependency",
"(",
"TaskGroup",
".",
"HasTaskGroup",
"dependency",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"dependency",
")",
";",
"this",
".",
"taskGroup",
"(",
")",
".",
"addDependencyTaskGroup",
"(",
"dependency",
".",
"task... | Add a dependency task group for this model.
@param dependency the dependency.
@return key to be used as parameter to taskResult(string) method to retrieve result of root
task in the given dependency task group | [
"Add",
"a",
"dependency",
"task",
"group",
"for",
"this",
"model",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java#L213-L217 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java | ExternalChildResourceImpl.addPostRunDependent | @SuppressWarnings("unchecked")
protected void addPostRunDependent(Executable<? extends Indexable> executable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) executable;
this.addPostRunDependent(dependency);
} | java | @SuppressWarnings("unchecked")
protected void addPostRunDependent(Executable<? extends Indexable> executable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) executable;
this.addPostRunDependent(dependency);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"addPostRunDependent",
"(",
"Executable",
"<",
"?",
"extends",
"Indexable",
">",
"executable",
")",
"{",
"TaskGroup",
".",
"HasTaskGroup",
"dependency",
"=",
"(",
"TaskGroup",
".",
"HasTaskGr... | Add an executable "post-run" dependent for this model.
@param executable the executable "post-run" dependent
@return the key to be used as parameter to taskResult(string) method to retrieve result of executing
the executable "post-run" dependent | [
"Add",
"an",
"executable",
"post",
"-",
"run",
"dependent",
"for",
"this",
"model",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ExternalChildResourceImpl.java#L312-L316 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Graph.java | Graph.addNode | public void addNode(NodeT node) {
node.setOwner(this);
nodeTable.put(node.key(), node);
} | java | public void addNode(NodeT node) {
node.setOwner(this);
nodeTable.put(node.key(), node);
} | [
"public",
"void",
"addNode",
"(",
"NodeT",
"node",
")",
"{",
"node",
".",
"setOwner",
"(",
"this",
")",
";",
"nodeTable",
".",
"put",
"(",
"node",
".",
"key",
"(",
")",
",",
"node",
")",
";",
"}"
] | Adds a node to this graph.
@param node the node | [
"Adds",
"a",
"node",
"to",
"this",
"graph",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Graph.java#L79-L82 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Graph.java | Graph.findPath | protected String findPath(String start, String end) {
if (start.equals(end)) {
return start;
} else {
return findPath(start, parent.get(end)) + " -> " + end;
}
} | java | protected String findPath(String start, String end) {
if (start.equals(end)) {
return start;
} else {
return findPath(start, parent.get(end)) + " -> " + end;
}
} | [
"protected",
"String",
"findPath",
"(",
"String",
"start",
",",
"String",
"end",
")",
"{",
"if",
"(",
"start",
".",
"equals",
"(",
"end",
")",
")",
"{",
"return",
"start",
";",
"}",
"else",
"{",
"return",
"findPath",
"(",
"start",
",",
"parent",
".",... | Find the path.
@param start key of first node in the path
@param end key of last node in the path
@return string containing the nodes keys in the path separated by arrow symbol | [
"Find",
"the",
"path",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Graph.java#L156-L162 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/ListToMapConverter.java | ListToMapConverter.convertToUnmodifiableMap | public Map<String, ImplT> convertToUnmodifiableMap(List<InnerT> innerList) {
Map<String, ImplT> result = new HashMap<>();
for (InnerT inner : innerList) {
result.put(name(inner), impl(inner));
}
return Collections.unmodifiableMap(result);
} | java | public Map<String, ImplT> convertToUnmodifiableMap(List<InnerT> innerList) {
Map<String, ImplT> result = new HashMap<>();
for (InnerT inner : innerList) {
result.put(name(inner), impl(inner));
}
return Collections.unmodifiableMap(result);
} | [
"public",
"Map",
"<",
"String",
",",
"ImplT",
">",
"convertToUnmodifiableMap",
"(",
"List",
"<",
"InnerT",
">",
"innerList",
")",
"{",
"Map",
"<",
"String",
",",
"ImplT",
">",
"result",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"InnerT",
... | Converts the passed list of inners to unmodifiable map of impls.
@param innerList list of the inners.
@return map of the impls | [
"Converts",
"the",
"passed",
"list",
"of",
"inners",
"to",
"unmodifiable",
"map",
"of",
"impls",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/ListToMapConverter.java#L29-L36 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java | Utils.createOdataFilterForTags | public static String createOdataFilterForTags(String tagName, String tagValue) {
if (tagName == null) {
return null;
} else if (tagValue == null) {
return String.format("tagname eq '%s'", tagName);
} else {
return String.format("tagname eq '%s' and tagvalue eq '%s'", tagName, tagValue);
}
} | java | public static String createOdataFilterForTags(String tagName, String tagValue) {
if (tagName == null) {
return null;
} else if (tagValue == null) {
return String.format("tagname eq '%s'", tagName);
} else {
return String.format("tagname eq '%s' and tagvalue eq '%s'", tagName, tagValue);
}
} | [
"public",
"static",
"String",
"createOdataFilterForTags",
"(",
"String",
"tagName",
",",
"String",
"tagValue",
")",
"{",
"if",
"(",
"tagName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"tagValue",
"==",
"null",
")",
"{",
"ret... | Creates an Odata filter string that can be used for filtering list results by tags.
@param tagName the name of the tag. If not provided, all resources will be returned.
@param tagValue the value of the tag. If not provided, only tag name will be filtered.
@return the Odata filter to pass into list methods | [
"Creates",
"an",
"Odata",
"filter",
"string",
"that",
"can",
"be",
"used",
"for",
"filtering",
"list",
"results",
"by",
"tags",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java#L90-L98 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java | Utils.downloadFileAsync | public static Observable<byte[]> downloadFileAsync(String url, Retrofit retrofit) {
FileService service = retrofit.create(FileService.class);
Observable<ResponseBody> response = service.download(url);
return response.map(new Func1<ResponseBody, byte[]>() {
@Override
public byte[] call(ResponseBody responseBody) {
try {
return responseBody.bytes();
} catch (IOException e) {
throw Exceptions.propagate(e);
}
}
});
} | java | public static Observable<byte[]> downloadFileAsync(String url, Retrofit retrofit) {
FileService service = retrofit.create(FileService.class);
Observable<ResponseBody> response = service.download(url);
return response.map(new Func1<ResponseBody, byte[]>() {
@Override
public byte[] call(ResponseBody responseBody) {
try {
return responseBody.bytes();
} catch (IOException e) {
throw Exceptions.propagate(e);
}
}
});
} | [
"public",
"static",
"Observable",
"<",
"byte",
"[",
"]",
">",
"downloadFileAsync",
"(",
"String",
"url",
",",
"Retrofit",
"retrofit",
")",
"{",
"FileService",
"service",
"=",
"retrofit",
".",
"create",
"(",
"FileService",
".",
"class",
")",
";",
"Observable"... | Download a file asynchronously.
@param url the URL pointing to the file
@param retrofit the retrofit client
@return an Observable pointing to the content of the file | [
"Download",
"a",
"file",
"asynchronously",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java#L124-L137 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java | Utils.toPagedList | public static <OutT, InT> PagedList<OutT> toPagedList(List<InT> list, final Func1<InT, OutT> mapper) {
PageImpl<InT> page = new PageImpl<>();
page.setItems(list);
page.setNextPageLink(null);
PagedList<InT> pagedList = new PagedList<InT>(page) {
@Override
public Page<InT> nextPage(String nextPageLink) {
return null;
}
};
PagedListConverter<InT, OutT> converter = new PagedListConverter<InT, OutT>() {
@Override
public Observable<OutT> typeConvertAsync(InT inner) {
return Observable.just(mapper.call(inner));
}
};
return converter.convert(pagedList);
} | java | public static <OutT, InT> PagedList<OutT> toPagedList(List<InT> list, final Func1<InT, OutT> mapper) {
PageImpl<InT> page = new PageImpl<>();
page.setItems(list);
page.setNextPageLink(null);
PagedList<InT> pagedList = new PagedList<InT>(page) {
@Override
public Page<InT> nextPage(String nextPageLink) {
return null;
}
};
PagedListConverter<InT, OutT> converter = new PagedListConverter<InT, OutT>() {
@Override
public Observable<OutT> typeConvertAsync(InT inner) {
return Observable.just(mapper.call(inner));
}
};
return converter.convert(pagedList);
} | [
"public",
"static",
"<",
"OutT",
",",
"InT",
">",
"PagedList",
"<",
"OutT",
">",
"toPagedList",
"(",
"List",
"<",
"InT",
">",
"list",
",",
"final",
"Func1",
"<",
"InT",
",",
"OutT",
">",
"mapper",
")",
"{",
"PageImpl",
"<",
"InT",
">",
"page",
"=",... | Converts the given list of a type to paged list of a different type.
@param list the list to convert to paged list
@param mapper the mapper to map type in input list to output list
@param <OutT> the type of items in output paged list
@param <InT> the type of items in input paged list
@return the paged list | [
"Converts",
"the",
"given",
"list",
"of",
"a",
"type",
"to",
"paged",
"list",
"of",
"a",
"different",
"type",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java#L148-L165 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java | Utils.addToListIfNotExists | public static void addToListIfNotExists(List<String> list, String value) {
boolean found = false;
for (String item : list) {
if (item.equalsIgnoreCase(value)) {
found = true;
break;
}
}
if (!found) {
list.add(value);
}
} | java | public static void addToListIfNotExists(List<String> list, String value) {
boolean found = false;
for (String item : list) {
if (item.equalsIgnoreCase(value)) {
found = true;
break;
}
}
if (!found) {
list.add(value);
}
} | [
"public",
"static",
"void",
"addToListIfNotExists",
"(",
"List",
"<",
"String",
">",
"list",
",",
"String",
"value",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"String",
"item",
":",
"list",
")",
"{",
"if",
"(",
"item",
".",
"equalsIg... | Adds a value to the list if does not already exists.
@param list the list
@param value value to add if not exists in the list | [
"Adds",
"a",
"value",
"to",
"the",
"list",
"if",
"does",
"not",
"already",
"exists",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java#L173-L184 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java | Utils.removeFromList | public static void removeFromList(List<String> list, String value) {
int foundIndex = -1;
int i = 0;
for (String id : list) {
if (id.equalsIgnoreCase(value)) {
foundIndex = i;
break;
}
i++;
}
if (foundIndex != -1) {
list.remove(foundIndex);
}
} | java | public static void removeFromList(List<String> list, String value) {
int foundIndex = -1;
int i = 0;
for (String id : list) {
if (id.equalsIgnoreCase(value)) {
foundIndex = i;
break;
}
i++;
}
if (foundIndex != -1) {
list.remove(foundIndex);
}
} | [
"public",
"static",
"void",
"removeFromList",
"(",
"List",
"<",
"String",
">",
"list",
",",
"String",
"value",
")",
"{",
"int",
"foundIndex",
"=",
"-",
"1",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"id",
":",
"list",
")",
"{",
"if",
... | Removes a value from the list.
@param list the list
@param value value to remove | [
"Removes",
"a",
"value",
"from",
"the",
"list",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/Utils.java#L192-L205 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/PagedListConverter.java | PagedListConverter.convert | public PagedList<V> convert(final PagedList<U> uList) {
if (uList == null || uList.isEmpty()) {
return new PagedList<V>() {
@Override
public Page<V> nextPage(String s) throws RestException, IOException {
return null;
}
};
}
Page<U> uPage = uList.currentPage();
final PageImpl<V> vPage = new PageImpl<>();
vPage.setNextPageLink(uPage.nextPageLink());
vPage.setItems(new ArrayList<V>());
loadConvertedList(uPage, vPage);
return new PagedList<V>(vPage) {
@Override
public Page<V> nextPage(String nextPageLink) throws RestException, IOException {
Page<U> uPage = uList.nextPage(nextPageLink);
final PageImpl<V> vPage = new PageImpl<>();
vPage.setNextPageLink(uPage.nextPageLink());
vPage.setItems(new ArrayList<V>());
loadConvertedList(uPage, vPage);
return vPage;
}
};
} | java | public PagedList<V> convert(final PagedList<U> uList) {
if (uList == null || uList.isEmpty()) {
return new PagedList<V>() {
@Override
public Page<V> nextPage(String s) throws RestException, IOException {
return null;
}
};
}
Page<U> uPage = uList.currentPage();
final PageImpl<V> vPage = new PageImpl<>();
vPage.setNextPageLink(uPage.nextPageLink());
vPage.setItems(new ArrayList<V>());
loadConvertedList(uPage, vPage);
return new PagedList<V>(vPage) {
@Override
public Page<V> nextPage(String nextPageLink) throws RestException, IOException {
Page<U> uPage = uList.nextPage(nextPageLink);
final PageImpl<V> vPage = new PageImpl<>();
vPage.setNextPageLink(uPage.nextPageLink());
vPage.setItems(new ArrayList<V>());
loadConvertedList(uPage, vPage);
return vPage;
}
};
} | [
"public",
"PagedList",
"<",
"V",
">",
"convert",
"(",
"final",
"PagedList",
"<",
"U",
">",
"uList",
")",
"{",
"if",
"(",
"uList",
"==",
"null",
"||",
"uList",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"PagedList",
"<",
"V",
">",
"(",
"... | Converts the paged list.
@param uList the resource list to convert from
@return the converted list | [
"Converts",
"the",
"paged",
"list",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/PagedListConverter.java#L53-L78 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java | CustomHeadersInterceptor.replaceHeader | public CustomHeadersInterceptor replaceHeader(String name, String value) {
this.headers.put(name, new ArrayList<String>());
this.headers.get(name).add(value);
return this;
} | java | public CustomHeadersInterceptor replaceHeader(String name, String value) {
this.headers.put(name, new ArrayList<String>());
this.headers.get(name).add(value);
return this;
} | [
"public",
"CustomHeadersInterceptor",
"replaceHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"this",
".",
"headers",
".",
"put",
"(",
"name",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"this",
".",
"headers",
".",... | Add a single header key-value pair. If one with the name already exists,
it gets replaced.
@param name the name of the header.
@param value the value of the header.
@return the interceptor instance itself. | [
"Add",
"a",
"single",
"header",
"key",
"-",
"value",
"pair",
".",
"If",
"one",
"with",
"the",
"name",
"already",
"exists",
"it",
"gets",
"replaced",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java#L64-L68 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java | CustomHeadersInterceptor.addHeader | public CustomHeadersInterceptor addHeader(String name, String value) {
if (!this.headers.containsKey(name)) {
this.headers.put(name, new ArrayList<String>());
}
this.headers.get(name).add(value);
return this;
} | java | public CustomHeadersInterceptor addHeader(String name, String value) {
if (!this.headers.containsKey(name)) {
this.headers.put(name, new ArrayList<String>());
}
this.headers.get(name).add(value);
return this;
} | [
"public",
"CustomHeadersInterceptor",
"addHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"!",
"this",
".",
"headers",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"this",
".",
"headers",
".",
"put",
"(",
"name",
",",
"n... | Add a single header key-value pair. If one with the name already exists,
both stay in the header map.
@param name the name of the header.
@param value the value of the header.
@return the interceptor instance itself. | [
"Add",
"a",
"single",
"header",
"key",
"-",
"value",
"pair",
".",
"If",
"one",
"with",
"the",
"name",
"already",
"exists",
"both",
"stay",
"in",
"the",
"header",
"map",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java#L78-L84 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java | CustomHeadersInterceptor.addHeaderMap | public CustomHeadersInterceptor addHeaderMap(Map<String, String> headers) {
for (Map.Entry<String, String> header : headers.entrySet()) {
this.headers.put(header.getKey(), Collections.singletonList(header.getValue()));
}
return this;
} | java | public CustomHeadersInterceptor addHeaderMap(Map<String, String> headers) {
for (Map.Entry<String, String> header : headers.entrySet()) {
this.headers.put(header.getKey(), Collections.singletonList(header.getValue()));
}
return this;
} | [
"public",
"CustomHeadersInterceptor",
"addHeaderMap",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"header",
":",
"headers",
".",
"entrySet",
"(",
")",
")",
"{",
... | Add all headers in a header map.
@param headers a map of headers.
@return the interceptor instance itself. | [
"Add",
"all",
"headers",
"in",
"a",
"header",
"map",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java#L103-L108 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java | CustomHeadersInterceptor.addHeaderMultimap | public CustomHeadersInterceptor addHeaderMultimap(Map<String, List<String>> headers) {
this.headers.putAll(headers);
return this;
} | java | public CustomHeadersInterceptor addHeaderMultimap(Map<String, List<String>> headers) {
this.headers.putAll(headers);
return this;
} | [
"public",
"CustomHeadersInterceptor",
"addHeaderMultimap",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
")",
"{",
"this",
".",
"headers",
".",
"putAll",
"(",
"headers",
")",
";",
"return",
"this",
";",
"}"
] | Add all headers in a header multimap.
@param headers a multimap of headers.
@return the interceptor instance itself. | [
"Add",
"all",
"headers",
"in",
"a",
"header",
"multimap",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java#L116-L119 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/RXMapper.java | RXMapper.map | public static <T> Observable<T> map(Observable<?> fromObservable, final T toValue) {
if (fromObservable != null) {
return fromObservable.subscribeOn(Schedulers.io())
.map(new RXMapper<T>(toValue));
} else {
return Observable.empty();
}
} | java | public static <T> Observable<T> map(Observable<?> fromObservable, final T toValue) {
if (fromObservable != null) {
return fromObservable.subscribeOn(Schedulers.io())
.map(new RXMapper<T>(toValue));
} else {
return Observable.empty();
}
} | [
"public",
"static",
"<",
"T",
">",
"Observable",
"<",
"T",
">",
"map",
"(",
"Observable",
"<",
"?",
">",
"fromObservable",
",",
"final",
"T",
"toValue",
")",
"{",
"if",
"(",
"fromObservable",
"!=",
"null",
")",
"{",
"return",
"fromObservable",
".",
"su... | Shortcut for mapping the output of an arbitrary observable to one returning an instance of a specific type, using the IO scheduler.
@param fromObservable the source observable
@param toValue the value to emit to the observer
@param <T> the type of the value to emit
@return an observable emitting the specified value | [
"Shortcut",
"for",
"mapping",
"the",
"output",
"of",
"an",
"arbitrary",
"observable",
"to",
"one",
"returning",
"an",
"instance",
"of",
"a",
"specific",
"type",
"using",
"the",
"IO",
"scheduler",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/RXMapper.java#L28-L35 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/RXMapper.java | RXMapper.mapToVoid | public static Observable<Void> mapToVoid(Observable<?> fromObservable) {
if (fromObservable != null) {
return fromObservable.subscribeOn(Schedulers.io())
.map(new RXMapper<Void>());
} else {
return Observable.empty();
}
} | java | public static Observable<Void> mapToVoid(Observable<?> fromObservable) {
if (fromObservable != null) {
return fromObservable.subscribeOn(Schedulers.io())
.map(new RXMapper<Void>());
} else {
return Observable.empty();
}
} | [
"public",
"static",
"Observable",
"<",
"Void",
">",
"mapToVoid",
"(",
"Observable",
"<",
"?",
">",
"fromObservable",
")",
"{",
"if",
"(",
"fromObservable",
"!=",
"null",
")",
"{",
"return",
"fromObservable",
".",
"subscribeOn",
"(",
"Schedulers",
".",
"io",
... | Shortcut for mapping an arbitrary observable to void, using the IO scheduler.
@param fromObservable the source observable
@return a void-emitting observable | [
"Shortcut",
"for",
"mapping",
"an",
"arbitrary",
"observable",
"to",
"void",
"using",
"the",
"IO",
"scheduler",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/RXMapper.java#L42-L49 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java | ResourceImpl.withTag | @SuppressWarnings("unchecked")
public final FluentModelImplT withTag(String key, String value) {
if (this.inner().getTags() == null) {
this.inner().withTags(new HashMap<String, String>());
}
this.inner().getTags().put(key, value);
return (FluentModelImplT) this;
} | java | @SuppressWarnings("unchecked")
public final FluentModelImplT withTag(String key, String value) {
if (this.inner().getTags() == null) {
this.inner().withTags(new HashMap<String, String>());
}
this.inner().getTags().put(key, value);
return (FluentModelImplT) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"FluentModelImplT",
"withTag",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"inner",
"(",
")",
".",
"getTags",
"(",
")",
"==",
"null",
")",
"{",
"... | Adds a tag to the resource.
@param key the key for the tag
@param value the value for the tag
@return the next stage of the definition/update | [
"Adds",
"a",
"tag",
"to",
"the",
"resource",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java#L109-L116 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java | ResourceImpl.withoutTag | @SuppressWarnings("unchecked")
public final FluentModelImplT withoutTag(String key) {
if (this.inner().getTags() != null) {
this.inner().getTags().remove(key);
}
return (FluentModelImplT) this;
} | java | @SuppressWarnings("unchecked")
public final FluentModelImplT withoutTag(String key) {
if (this.inner().getTags() != null) {
this.inner().getTags().remove(key);
}
return (FluentModelImplT) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"FluentModelImplT",
"withoutTag",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"this",
".",
"inner",
"(",
")",
".",
"getTags",
"(",
")",
"!=",
"null",
")",
"{",
"this",
".",
"inner",
... | Removes a tag from the resource.
@param key the key of the tag to remove
@return the next stage of the definition/update | [
"Removes",
"a",
"tag",
"from",
"the",
"resource",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/models/implementation/ResourceImpl.java#L123-L129 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/ListOperationCallback.java | ListOperationCallback.load | public void load(List<E> result) {
++pageCount;
if (this.result == null || this.result.isEmpty()) {
this.result = result;
} else {
this.result.addAll(result);
}
} | java | public void load(List<E> result) {
++pageCount;
if (this.result == null || this.result.isEmpty()) {
this.result = result;
} else {
this.result.addAll(result);
}
} | [
"public",
"void",
"load",
"(",
"List",
"<",
"E",
">",
"result",
")",
"{",
"++",
"pageCount",
";",
"if",
"(",
"this",
".",
"result",
"==",
"null",
"||",
"this",
".",
"result",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"result",
"=",
"result... | This method is called by the client to load the most recent list of resources.
This method should only be called by the service client.
@param result the most recent list of resources. | [
"This",
"method",
"is",
"called",
"by",
"the",
"client",
"to",
"load",
"the",
"most",
"recent",
"list",
"of",
"resources",
".",
"This",
"method",
"should",
"only",
"be",
"called",
"by",
"the",
"service",
"client",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/ListOperationCallback.java#L62-L69 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/DelayProvider.java | DelayProvider.delayedEmitAsync | public <T> Observable<T> delayedEmitAsync(T event, int milliseconds) {
return Observable.just(event).delay(milliseconds, TimeUnit.MILLISECONDS, Schedulers.immediate());
} | java | public <T> Observable<T> delayedEmitAsync(T event, int milliseconds) {
return Observable.just(event).delay(milliseconds, TimeUnit.MILLISECONDS, Schedulers.immediate());
} | [
"public",
"<",
"T",
">",
"Observable",
"<",
"T",
">",
"delayedEmitAsync",
"(",
"T",
"event",
",",
"int",
"milliseconds",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"event",
")",
".",
"delay",
"(",
"milliseconds",
",",
"TimeUnit",
".",
"MILLISECO... | Creates an observable that emits the given item after the specified time in milliseconds.
@param event the event to emit
@param milliseconds the delay in milliseconds
@param <T> the type of event
@return delayed observable | [
"Creates",
"an",
"observable",
"that",
"emits",
"the",
"given",
"item",
"after",
"the",
"specified",
"time",
"in",
"milliseconds",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/DelayProvider.java#L37-L39 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/SdkContext.java | SdkContext.randomResourceNames | public static String[] randomResourceNames(String prefix, int maxLen, int count) {
String[] names = new String[count];
ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer("");
for (int i = 0; i < count; i++) {
names[i] = resourceNamer.randomName(prefix, maxLen);
}
return names;
} | java | public static String[] randomResourceNames(String prefix, int maxLen, int count) {
String[] names = new String[count];
ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer("");
for (int i = 0; i < count; i++) {
names[i] = resourceNamer.randomName(prefix, maxLen);
}
return names;
} | [
"public",
"static",
"String",
"[",
"]",
"randomResourceNames",
"(",
"String",
"prefix",
",",
"int",
"maxLen",
",",
"int",
"count",
")",
"{",
"String",
"[",
"]",
"names",
"=",
"new",
"String",
"[",
"count",
"]",
";",
"ResourceNamer",
"resourceNamer",
"=",
... | Generates the specified number of random resource names with the same prefix.
@param prefix the prefix to be used if possible
@param maxLen the maximum length for the random generated name
@param count the number of names to generate
@return random names | [
"Generates",
"the",
"specified",
"number",
"of",
"random",
"resource",
"names",
"with",
"the",
"same",
"prefix",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/SdkContext.java#L57-L64 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.