code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
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> deleteById(String webhook) {
String path = String.format("/webhooks/%s", webhook);
return new ItemRequest<Webhook>(this, Webhook.class, path, "DELETE");
} | java |
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 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 ItemRequest<ProjectMembership> findById(String projectMembership) {
String path = String.format("/project_memberships/%s", projectMembership);
return new ItemRequest<ProjectMembership>(this, ProjectMembership.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");
} | java |
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> update(String story) {
String path = String.format("/stories/%s", story);
return new ItemRequest<Story>(this, Story.class, path, "PUT");
} | java |
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<Workspace> findById(String workspace) {
String path = String.format("/workspaces/%s", workspace);
return new ItemRequest<Workspace>(this, Workspace.class, path, "GET");
} | java |
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> addUser(String workspace) {
String path = String.format("/workspaces/%s/addUser", 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");
} | 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(
... | java |
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 Request option(String key, Object value) {
this.options.put(key, value);
return this;
} | java |
public Request header(String key, String value) {
this.headers.put(key, value);
return this;
} | java |
public ItemRequest<Attachment> findById(String attachment) {
String path = String.format("/attachments/%s", attachment);
return new ItemRequest<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");
} | java |
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 CollectionRequest<Section> findByProject(String project) {
String path = String.format("/projects/%s/sections", project);
return new CollectionRequest<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");
} | java |
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> insertInProject(String project) {
String path = String.format("/projects/%s/sections/insert", project);
return new ItemRequest<Section>(this, Section.class, path, "POST");
} | java |
public ItemRequest<Team> findById(String team) {
String path = String.format("/teams/%s", team);
return new ItemRequest<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");
} | java |
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> users(String team) {
String path = String.format("/teams/%s/users", team);
return new CollectionRequest<Team>(this, Team.class, path, "GET");
} | java |
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> removeUser(String team) {
String path = String.format("/teams/%s/removeUser", team);
return new ItemRequest<Team>(this, Team.class, path, "POST");
} | java |
protected InternalHttpResponse sendInternalRequest(HttpRequest request) {
InternalHttpResponder responder = new InternalHttpResponder();
httpResourceHandler.handle(request, responder);
return responder.getResponse();
} | java |
public SslHandler create(ByteBufAllocator bufferAllocator) {
SSLEngine engine = sslContext.newEngine(bufferAllocator);
engine.setNeedClientAuth(needClientAuth);
engine.setUseClientMode(false);
return new SslHandler(engine);
} | 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.isAnnotat... | 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.send... | java |
private PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>
getMatchedDestination(List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations,
HttpMethod targetHttpMethod, String requestUri) {
LOG.trace("Routable destinations for request {}... | 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 l... | 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
pub... | 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 BasicConve... | 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 valu... | 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(va... | 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 (typ... | 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)... | 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 reque... | 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... | 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> patternRout... | 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 IllegalStateExc... | 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... | java |
private ServerBootstrap createBootstrap(final ChannelGroup channelGroup) throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(bossThreadPoolSize,
createDaemonThreadFactory(serviceName + "-boss-thread-%d"));
EventLoopGroup workerGroup = new NioE... | 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... | 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 reflect... | 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 = meth... | 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>>() {
@Overrid... | 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<Servi... | 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() {
... | java |
protected void cacheCollection() {
this.clear();
for (FluentModelTImpl childResource : this.listChildResources()) {
this.childCollection.put(childResource.childResourceKey(), childResource);
}
} | 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, targetNode... | 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
... | java |
public NodeT getNext() {
String nextItemKey = queue.poll();
if (nextItemKey == null) {
return null;
}
return nodeTable.get(nextItemKey);
} | 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()... | 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.loc... | 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 IllegalSta... | 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());
}
}
} | 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, " -> "));
... | java |
public static IndexableTaskItem create(final FunctionalTaskItem taskItem) {
return new IndexableTaskItem() {
@Override
protected Observable<Indexable> invokeTaskAsync(TaskGroup.InvocationContext context) {
FunctionalTaskItem.Context fContext = new FunctionalTaskItem.Conte... | java |
@SuppressWarnings("unchecked")
protected String addeDependency(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addDependency(dependency);
} | java |
public String addPostRunDependent(FunctionalTaskItem dependent) {
Objects.requireNonNull(dependent);
return this.taskGroup().addPostRunDependent(dependent);
} | java |
@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(Appliable<? extends Indexable> appliable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) appliable;
return this.addPostRunDependent(dependency);
} | 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;
}
} | 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);
}
} | 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().repl... | java |
protected FluentModelTImpl prepareForFutureCommitOrPostRun(FluentModelTImpl childResource) {
if (this.isPostRunMode) {
if (!childResource.taskGroup().dependsOn(this.parentTaskGroup)) {
this.parentTaskGroup.addPostRunDependentTaskGroup(childResource.taskGroup());
}
... | 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;
} | 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 PagingSubscri... | 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 AzureServiceFu... | 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) {
... | java |
private static JsonParser newJsonParserForNode(JsonNode jsonNode) throws IOException {
JsonParser parser = new JsonFactory().createParser(jsonNode.toString());
parser.nextToken();
return parser;
} | java |
protected String addDependency(FunctionalTaskItem dependency) {
Objects.requireNonNull(dependency);
return this.taskGroup().addDependency(dependency);
} | java |
protected String addDependency(TaskGroup.HasTaskGroup dependency) {
Objects.requireNonNull(dependency);
this.taskGroup().addDependencyTaskGroup(dependency.taskGroup());
return dependency.taskGroup().key();
} | java |
@SuppressWarnings("unchecked")
protected void addPostRunDependent(Executable<? extends Indexable> executable) {
TaskGroup.HasTaskGroup dependency = (TaskGroup.HasTaskGroup) executable;
this.addPostRunDependent(dependency);
} | java |
public void addNode(NodeT node) {
node.setOwner(this);
nodeTable.put(node.key(), node);
} | java |
protected String findPath(String start, String end) {
if (start.equals(end)) {
return start;
} else {
return findPath(start, parent.get(end)) + " -> " + end;
}
} | 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);
} | 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... | 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
publi... | 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 Pa... | 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);
... | 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... | 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;
}
}... | java |
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 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 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 addHeaderMultimap(Map<String, List<String>> headers) {
this.headers.putAll(headers);
return this;
} | 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();
}
} | java |
public static Observable<Void> mapToVoid(Observable<?> fromObservable) {
if (fromObservable != null) {
return fromObservable.subscribeOn(Schedulers.io())
.map(new RXMapper<Void>());
} else {
return Observable.empty();
}
} | 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;
} | java |
@SuppressWarnings("unchecked")
public final FluentModelImplT withoutTag(String key) {
if (this.inner().getTags() != null) {
this.inner().getTags().remove(key);
}
return (FluentModelImplT) this;
} | java |
public void load(List<E> result) {
++pageCount;
if (this.result == null || this.result.isEmpty()) {
this.result = result;
} else {
this.result.addAll(result);
}
} | java |
public <T> Observable<T> delayedEmitAsync(T event, int milliseconds) {
return Observable.just(event).delay(milliseconds, TimeUnit.MILLISECONDS, Schedulers.immediate());
} | 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(pre... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.