id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,000 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java | WebcamDriverUtils.findClasses | private static List<Class<?>> findClasses(File dir, String pkgname, boolean flat) throws ClassNotFoundException {
List<Class<?>> classes = new ArrayList<Class<?>>();
if (!dir.exists()) {
return classes;
}
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory() && !flat) {
classes.addAll(findClasses(file, pkgname + "." + file.getName(), flat));
} else if (file.getName().endsWith(".class")) {
classes.add(Class.forName(pkgname + '.' + file.getName().substring(0, file.getName().length() - 6)));
}
}
return classes;
} | java | private static List<Class<?>> findClasses(File dir, String pkgname, boolean flat) throws ClassNotFoundException {
List<Class<?>> classes = new ArrayList<Class<?>>();
if (!dir.exists()) {
return classes;
}
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory() && !flat) {
classes.addAll(findClasses(file, pkgname + "." + file.getName(), flat));
} else if (file.getName().endsWith(".class")) {
classes.add(Class.forName(pkgname + '.' + file.getName().substring(0, file.getName().length() - 6)));
}
}
return classes;
} | [
"private",
"static",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"findClasses",
"(",
"File",
"dir",
",",
"String",
"pkgname",
",",
"boolean",
"flat",
")",
"throws",
"ClassNotFoundException",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
"=",
... | Recursive method used to find all classes in a given directory and
subdirectories.
@param dir base directory
@param pkgname package name for classes found inside the base directory
@param flat scan only one package level, do not dive into subdirectories
@return Classes list
@throws ClassNotFoundException | [
"Recursive",
"method",
"used",
"to",
"find",
"all",
"classes",
"in",
"a",
"given",
"directory",
"and",
"subdirectories",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java#L122-L139 |
31,001 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamProcessor.java | WebcamProcessor.process | public void process(WebcamTask task) throws InterruptedException {
if (started.compareAndSet(false, true)) {
runner = Executors.newSingleThreadExecutor(new ProcessorThreadFactory());
runner.execute(processor);
}
if (!runner.isShutdown()) {
processor.process(task);
} else {
throw new RejectedExecutionException("Cannot process because processor runner has been already shut down");
}
} | java | public void process(WebcamTask task) throws InterruptedException {
if (started.compareAndSet(false, true)) {
runner = Executors.newSingleThreadExecutor(new ProcessorThreadFactory());
runner.execute(processor);
}
if (!runner.isShutdown()) {
processor.process(task);
} else {
throw new RejectedExecutionException("Cannot process because processor runner has been already shut down");
}
} | [
"public",
"void",
"process",
"(",
"WebcamTask",
"task",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"started",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"runner",
"=",
"Executors",
".",
"newSingleThreadExecutor",
"(",
"new",
... | Process single webcam task.
@param task the task to be processed
@throws InterruptedException when thread has been interrupted | [
"Process",
"single",
"webcam",
"task",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamProcessor.java#L132-L144 |
31,002 | sarxos/webcam-capture | webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java | IpCamDeviceRegistry.register | public static IpCamDevice register(IpCamDevice ipcam) {
for (WebcamDevice d : DEVICES) {
String name = ipcam.getName();
if (d.getName().equals(name)) {
throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
}
}
DEVICES.add(ipcam);
rescan();
return ipcam;
} | java | public static IpCamDevice register(IpCamDevice ipcam) {
for (WebcamDevice d : DEVICES) {
String name = ipcam.getName();
if (d.getName().equals(name)) {
throw new WebcamException(String.format("Webcam with name '%s' is already registered", name));
}
}
DEVICES.add(ipcam);
rescan();
return ipcam;
} | [
"public",
"static",
"IpCamDevice",
"register",
"(",
"IpCamDevice",
"ipcam",
")",
"{",
"for",
"(",
"WebcamDevice",
"d",
":",
"DEVICES",
")",
"{",
"String",
"name",
"=",
"ipcam",
".",
"getName",
"(",
")",
";",
"if",
"(",
"d",
".",
"getName",
"(",
")",
... | Register IP camera.
@param ipcam the IP camera to be register
@return IP camera device | [
"Register",
"IP",
"camera",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java#L36-L50 |
31,003 | sarxos/webcam-capture | webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java | IpCamDeviceRegistry.isRegistered | public static boolean isRegistered(IpCamDevice ipcam) {
if (ipcam == null) {
throw new IllegalArgumentException("IP camera device cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(ipcam.getName())) {
return true;
}
}
return false;
} | java | public static boolean isRegistered(IpCamDevice ipcam) {
if (ipcam == null) {
throw new IllegalArgumentException("IP camera device cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(ipcam.getName())) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isRegistered",
"(",
"IpCamDevice",
"ipcam",
")",
"{",
"if",
"(",
"ipcam",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"IP camera device cannot be null\"",
")",
";",
"}",
"Iterator",
"<",
"IpCamDevice",... | Is device registered?
@param ipcam the IP camera device
@return True if device is registsred, false otherwise | [
"Is",
"device",
"registered?"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java#L83-L97 |
31,004 | sarxos/webcam-capture | webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java | IpCamDeviceRegistry.isRegistered | public static boolean isRegistered(String name) {
if (name == null) {
throw new IllegalArgumentException("Device name cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(name)) {
return true;
}
}
return false;
} | java | public static boolean isRegistered(String name) {
if (name == null) {
throw new IllegalArgumentException("Device name cannot be null");
}
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
if (di.next().getName().equals(name)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isRegistered",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Device name cannot be null\"",
")",
";",
"}",
"Iterator",
"<",
"IpCamDevice",
">",
"d... | Is device with given name registered?
@param name the name of device
@return True if device is registered, false otherwise | [
"Is",
"device",
"with",
"given",
"name",
"registered?"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java#L105-L119 |
31,005 | sarxos/webcam-capture | webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java | IpCamDeviceRegistry.unregister | public static boolean unregister(String name) {
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
IpCamDevice d = di.next();
if (d.getName().equals(name)) {
di.remove();
rescan();
return true;
}
}
return false;
} | java | public static boolean unregister(String name) {
Iterator<IpCamDevice> di = DEVICES.iterator();
while (di.hasNext()) {
IpCamDevice d = di.next();
if (d.getName().equals(name)) {
di.remove();
rescan();
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"unregister",
"(",
"String",
"name",
")",
"{",
"Iterator",
"<",
"IpCamDevice",
">",
"di",
"=",
"DEVICES",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"di",
".",
"hasNext",
"(",
")",
")",
"{",
"IpCamDevice",
"d",
"=",
... | Unregister IP camera with given name.
@param name the name of IP camera to be unregister
@return True if device has been registered, false otherwise | [
"Unregister",
"IP",
"camera",
"with",
"given",
"name",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ipcam/src/main/java/com/github/sarxos/webcam/ds/ipcam/IpCamDeviceRegistry.java#L200-L211 |
31,006 | sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDeallocator.java | WebcamDeallocator.store | protected static void store(Webcam[] webcams) {
if (HANDLER.get() == null) {
HANDLER.set(new WebcamDeallocator(webcams));
} else {
throw new IllegalStateException("Deallocator is already set!");
}
} | java | protected static void store(Webcam[] webcams) {
if (HANDLER.get() == null) {
HANDLER.set(new WebcamDeallocator(webcams));
} else {
throw new IllegalStateException("Deallocator is already set!");
}
} | [
"protected",
"static",
"void",
"store",
"(",
"Webcam",
"[",
"]",
"webcams",
")",
"{",
"if",
"(",
"HANDLER",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"HANDLER",
".",
"set",
"(",
"new",
"WebcamDeallocator",
"(",
"webcams",
")",
")",
";",
"}",
"e... | Store devices to be deallocated when TERM signal has been received.
@param webcams the webcams array to be stored in deallocator | [
"Store",
"devices",
"to",
"be",
"deallocated",
"when",
"TERM",
"signal",
"has",
"been",
"received",
"."
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDeallocator.java#L35-L41 |
31,007 | sarxos/webcam-capture | webcam-capture/src/example/java/MultipointMotionDetectionExample.java | MultipointMotionDetectionExample.motionDetected | @Override
public void motionDetected(WebcamMotionEvent wme) {
for (Point p : wme.getPoints()) {
motionPoints.put(p, 0);
}
} | java | @Override
public void motionDetected(WebcamMotionEvent wme) {
for (Point p : wme.getPoints()) {
motionPoints.put(p, 0);
}
} | [
"@",
"Override",
"public",
"void",
"motionDetected",
"(",
"WebcamMotionEvent",
"wme",
")",
"{",
"for",
"(",
"Point",
"p",
":",
"wme",
".",
"getPoints",
"(",
")",
")",
"{",
"motionPoints",
".",
"put",
"(",
"p",
",",
"0",
")",
";",
"}",
"}"
] | Gets the motion points from the motion detector and adds it to the HashMap | [
"Gets",
"the",
"motion",
"points",
"from",
"the",
"motion",
"detector",
"and",
"adds",
"it",
"to",
"the",
"HashMap"
] | efbdae04f9ba48db9ec621e94a9bcd6f031882c8 | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/example/java/MultipointMotionDetectionExample.java#L80-L85 |
31,008 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/job/JobExecutor.java | JobExecutor.execute | public JobReport execute(Job job) {
try {
return executorService.submit(job).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Unable to execute job " + job.getName(), e);
}
} | java | public JobReport execute(Job job) {
try {
return executorService.submit(job).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Unable to execute job " + job.getName(), e);
}
} | [
"public",
"JobReport",
"execute",
"(",
"Job",
"job",
")",
"{",
"try",
"{",
"return",
"executorService",
".",
"submit",
"(",
"job",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"ExecutionException",
"e",
")",
"{",
"throw... | Execute a job synchronously.
@param job to execute
@return the job report | [
"Execute",
"a",
"job",
"synchronously",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/job/JobExecutor.java#L81-L87 |
31,009 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/job/JobExecutor.java | JobExecutor.awaitTermination | public void awaitTermination(long timeout, TimeUnit unit) {
try {
executorService.awaitTermination(timeout, unit);
} catch (InterruptedException e) {
throw new RuntimeException("Job executor was interrupted while waiting");
}
} | java | public void awaitTermination(long timeout, TimeUnit unit) {
try {
executorService.awaitTermination(timeout, unit);
} catch (InterruptedException e) {
throw new RuntimeException("Job executor was interrupted while waiting");
}
} | [
"public",
"void",
"awaitTermination",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"try",
"{",
"executorService",
".",
"awaitTermination",
"(",
"timeout",
",",
"unit",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",... | Wait for jobs to terminate. | [
"Wait",
"for",
"jobs",
"to",
"terminate",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/job/JobExecutor.java#L133-L139 |
31,010 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/mapper/ObjectMapper.java | ObjectMapper.mapObject | public T mapObject(final Map<String, String> values) throws Exception {
T result = createInstance();
// for each field
for (Map.Entry<String, String> entry : values.entrySet()) {
String field = entry.getKey();
//get field raw value
String value = values.get(field);
Method setter = setters.get(field);
if (setter == null) {
LOGGER.warn("No public setter found for field {}, this field will be set to null (if object type) or default value (if primitive type)", field);
continue;
}
Class<?> type = setter.getParameterTypes()[0];
TypeConverter<String, ?> typeConverter = typeConverters.get(type);
if (typeConverter == null) {
LOGGER.warn(
"Type conversion not supported for type {}, field {} will be set to null (if object type) or default value (if primitive type)",
type, field);
continue;
}
if (value == null) {
LOGGER.warn("Attempting to convert null to type {} for field {}, this field will be set to null (if object type) or default value (if primitive type)", type, field);
continue;
}
if (value.isEmpty()) {
LOGGER.debug("Attempting to convert an empty string to type {} for field {}, this field will be ignored", type, field);
continue;
}
convertValue(result, field, value, setter, type, typeConverter);
}
return result;
} | java | public T mapObject(final Map<String, String> values) throws Exception {
T result = createInstance();
// for each field
for (Map.Entry<String, String> entry : values.entrySet()) {
String field = entry.getKey();
//get field raw value
String value = values.get(field);
Method setter = setters.get(field);
if (setter == null) {
LOGGER.warn("No public setter found for field {}, this field will be set to null (if object type) or default value (if primitive type)", field);
continue;
}
Class<?> type = setter.getParameterTypes()[0];
TypeConverter<String, ?> typeConverter = typeConverters.get(type);
if (typeConverter == null) {
LOGGER.warn(
"Type conversion not supported for type {}, field {} will be set to null (if object type) or default value (if primitive type)",
type, field);
continue;
}
if (value == null) {
LOGGER.warn("Attempting to convert null to type {} for field {}, this field will be set to null (if object type) or default value (if primitive type)", type, field);
continue;
}
if (value.isEmpty()) {
LOGGER.debug("Attempting to convert an empty string to type {} for field {}, this field will be ignored", type, field);
continue;
}
convertValue(result, field, value, setter, type, typeConverter);
}
return result;
} | [
"public",
"T",
"mapObject",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"values",
")",
"throws",
"Exception",
"{",
"T",
"result",
"=",
"createInstance",
"(",
")",
";",
"// for each field",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
... | Map values to fields of the target object type.
@param values fields values
@return A populated instance of the target type.
@throws Exception if values cannot be mapped to target object fields | [
"Map",
"values",
"to",
"fields",
"of",
"the",
"target",
"object",
"type",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/mapper/ObjectMapper.java#L77-L118 |
31,011 | j-easy/easy-batch | easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java | JobScheduler.scheduleAtWithInterval | public void scheduleAtWithInterval(final org.easybatch.core.job.Job job, final Date startTime, final int interval) throws JobSchedulerException {
checkNotNull(job, "job");
checkNotNull(startTime, "startTime");
String name = job.getName();
String jobName = JOB_NAME_PREFIX + name;
String triggerName = TRIGGER_NAME_PREFIX + name;
SimpleScheduleBuilder scheduleBuilder = simpleSchedule()
.withIntervalInSeconds(interval)
.repeatForever();
Trigger trigger = newTrigger()
.withIdentity(triggerName)
.startAt(startTime)
.withSchedule(scheduleBuilder)
.forJob(jobName)
.build();
JobDetail jobDetail = getJobDetail(job, jobName);
try {
LOGGER.info("Scheduling job ''{}'' to start at {} and every {} second(s)", name, startTime, interval);
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to schedule job '%s'", name), e);
}
} | java | public void scheduleAtWithInterval(final org.easybatch.core.job.Job job, final Date startTime, final int interval) throws JobSchedulerException {
checkNotNull(job, "job");
checkNotNull(startTime, "startTime");
String name = job.getName();
String jobName = JOB_NAME_PREFIX + name;
String triggerName = TRIGGER_NAME_PREFIX + name;
SimpleScheduleBuilder scheduleBuilder = simpleSchedule()
.withIntervalInSeconds(interval)
.repeatForever();
Trigger trigger = newTrigger()
.withIdentity(triggerName)
.startAt(startTime)
.withSchedule(scheduleBuilder)
.forJob(jobName)
.build();
JobDetail jobDetail = getJobDetail(job, jobName);
try {
LOGGER.info("Scheduling job ''{}'' to start at {} and every {} second(s)", name, startTime, interval);
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to schedule job '%s'", name), e);
}
} | [
"public",
"void",
"scheduleAtWithInterval",
"(",
"final",
"org",
".",
"easybatch",
".",
"core",
".",
"job",
".",
"Job",
"job",
",",
"final",
"Date",
"startTime",
",",
"final",
"int",
"interval",
")",
"throws",
"JobSchedulerException",
"{",
"checkNotNull",
"(",... | Schedule a job to start at a fixed point of time and repeat with interval period.
@param job the job to schedule
@param startTime the start time
@param interval the repeat interval in seconds | [
"Schedule",
"a",
"job",
"to",
"start",
"at",
"a",
"fixed",
"point",
"of",
"time",
"and",
"repeat",
"with",
"interval",
"period",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java#L174-L201 |
31,012 | j-easy/easy-batch | easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java | JobScheduler.unschedule | public void unschedule(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
LOGGER.info("Unscheduling job ''{}'' ", jobName);
try {
scheduler.unscheduleJob(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to unschedule job '%s'", jobName), e);
}
} | java | public void unschedule(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
LOGGER.info("Unscheduling job ''{}'' ", jobName);
try {
scheduler.unscheduleJob(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to unschedule job '%s'", jobName), e);
}
} | [
"public",
"void",
"unschedule",
"(",
"final",
"org",
".",
"easybatch",
".",
"core",
".",
"job",
".",
"Job",
"job",
")",
"throws",
"JobSchedulerException",
"{",
"String",
"jobName",
"=",
"job",
".",
"getName",
"(",
")",
";",
"LOGGER",
".",
"info",
"(",
... | Unschedule the given job.
@param job the job to unschedule
@throws JobSchedulerException thrown if an exception occurs during job unscheduling | [
"Unschedule",
"the",
"given",
"job",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java#L348-L356 |
31,013 | j-easy/easy-batch | easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java | JobScheduler.isScheduled | public boolean isScheduled(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
try {
return scheduler.checkExists(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to check if the job '%s' is scheduled", jobName), e);
}
} | java | public boolean isScheduled(final org.easybatch.core.job.Job job) throws JobSchedulerException {
String jobName = job.getName();
try {
return scheduler.checkExists(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
} catch (SchedulerException e) {
throw new JobSchedulerException(format("Unable to check if the job '%s' is scheduled", jobName), e);
}
} | [
"public",
"boolean",
"isScheduled",
"(",
"final",
"org",
".",
"easybatch",
".",
"core",
".",
"job",
".",
"Job",
"job",
")",
"throws",
"JobSchedulerException",
"{",
"String",
"jobName",
"=",
"job",
".",
"getName",
"(",
")",
";",
"try",
"{",
"return",
"sch... | Check if the given job is scheduled.
@param job the job to check
@return true if the job is scheduled, false else
@throws JobSchedulerException thrown if an exception occurs while checking if the job is scheduled | [
"Check",
"if",
"the",
"given",
"job",
"is",
"scheduled",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-extensions/easybatch-quartz/src/main/java/org/easybatch/extensions/quartz/JobScheduler.java#L365-L372 |
31,014 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/job/DefaultJobReportMerger.java | DefaultJobReportMerger.mergerReports | @Override
public JobReport mergerReports(JobReport... jobReports) {
List<Long> startTimes = new ArrayList<>();
List<Long> endTimes = new ArrayList<>();
List<String> jobNames = new ArrayList<>();
JobParameters parameters = new JobParameters();
JobMetrics metrics = new JobMetrics();
JobReport finalJobReport = new JobReport();
finalJobReport.setParameters(parameters);
finalJobReport.setMetrics(metrics);
finalJobReport.setStatus(JobStatus.COMPLETED);
for (JobReport jobReport : jobReports) {
startTimes.add(jobReport.getMetrics().getStartTime());
endTimes.add(jobReport.getMetrics().getEndTime());
calculateReadRecords(finalJobReport, jobReport);
calculateWrittenRecords(finalJobReport, jobReport);
calculateFilteredRecords(finalJobReport, jobReport);
calculateErrorRecords(finalJobReport, jobReport);
setStatus(finalJobReport, jobReport);
jobNames.add(jobReport.getJobName());
finalJobReport.setSystemProperties(jobReport.getSystemProperties()); // works unless partial jobs are run in different JVMs..
}
//merge results
finalJobReport.getMetrics().setStartTime(Collections.min(startTimes));
finalJobReport.getMetrics().setEndTime(Collections.max(endTimes));
// set name
finalJobReport.setJobName(concatenate(jobNames));
return finalJobReport;
} | java | @Override
public JobReport mergerReports(JobReport... jobReports) {
List<Long> startTimes = new ArrayList<>();
List<Long> endTimes = new ArrayList<>();
List<String> jobNames = new ArrayList<>();
JobParameters parameters = new JobParameters();
JobMetrics metrics = new JobMetrics();
JobReport finalJobReport = new JobReport();
finalJobReport.setParameters(parameters);
finalJobReport.setMetrics(metrics);
finalJobReport.setStatus(JobStatus.COMPLETED);
for (JobReport jobReport : jobReports) {
startTimes.add(jobReport.getMetrics().getStartTime());
endTimes.add(jobReport.getMetrics().getEndTime());
calculateReadRecords(finalJobReport, jobReport);
calculateWrittenRecords(finalJobReport, jobReport);
calculateFilteredRecords(finalJobReport, jobReport);
calculateErrorRecords(finalJobReport, jobReport);
setStatus(finalJobReport, jobReport);
jobNames.add(jobReport.getJobName());
finalJobReport.setSystemProperties(jobReport.getSystemProperties()); // works unless partial jobs are run in different JVMs..
}
//merge results
finalJobReport.getMetrics().setStartTime(Collections.min(startTimes));
finalJobReport.getMetrics().setEndTime(Collections.max(endTimes));
// set name
finalJobReport.setJobName(concatenate(jobNames));
return finalJobReport;
} | [
"@",
"Override",
"public",
"JobReport",
"mergerReports",
"(",
"JobReport",
"...",
"jobReports",
")",
"{",
"List",
"<",
"Long",
">",
"startTimes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Long",
">",
"endTimes",
"=",
"new",
"ArrayList",
... | Merge multiple reports into a consolidated one.
@param jobReports reports to merge
@return a merged report | [
"Merge",
"multiple",
"reports",
"into",
"a",
"consolidated",
"one",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/job/DefaultJobReportMerger.java#L54-L88 |
31,015 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/retry/RetryTemplate.java | RetryTemplate.execute | public <T> T execute(final Callable<T> callable) throws Exception {
int attempts = 0;
int maxAttempts = retryPolicy.getMaxAttempts();
long delay = retryPolicy.getDelay();
TimeUnit timeUnit = retryPolicy.getTimeUnit();
while(attempts < maxAttempts) {
try {
attempts++;
beforeCall();
T result = callable.call();
afterCall(result);
return result;
} catch (Exception e) {
onException(e);
if (attempts >= maxAttempts) {
onMaxAttempts(e);
throw e;
}
beforeWait();
sleep(timeUnit.toMillis(delay));
afterWait();
}
}
return null;
} | java | public <T> T execute(final Callable<T> callable) throws Exception {
int attempts = 0;
int maxAttempts = retryPolicy.getMaxAttempts();
long delay = retryPolicy.getDelay();
TimeUnit timeUnit = retryPolicy.getTimeUnit();
while(attempts < maxAttempts) {
try {
attempts++;
beforeCall();
T result = callable.call();
afterCall(result);
return result;
} catch (Exception e) {
onException(e);
if (attempts >= maxAttempts) {
onMaxAttempts(e);
throw e;
}
beforeWait();
sleep(timeUnit.toMillis(delay));
afterWait();
}
}
return null;
} | [
"public",
"<",
"T",
">",
"T",
"execute",
"(",
"final",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"Exception",
"{",
"int",
"attempts",
"=",
"0",
";",
"int",
"maxAttempts",
"=",
"retryPolicy",
".",
"getMaxAttempts",
"(",
")",
";",
"long",
"de... | Execute the callable with retries.
@param callable to execute
@param <T> the return type of the callable
@return the result of the callable
@throws Exception if the callable still throw an exception after all retries | [
"Execute",
"the",
"callable",
"with",
"retries",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/retry/RetryTemplate.java#L57-L81 |
31,016 | j-easy/easy-batch | easybatch-core/src/main/java/org/easybatch/core/record/PayloadExtractor.java | PayloadExtractor.extractPayloads | public static <P> List<P> extractPayloads(final List<? extends Record<P>> records) {
List<P> payloads = new ArrayList<>();
for (Record<P> record : records) {
payloads.add(record.getPayload());
}
return payloads;
} | java | public static <P> List<P> extractPayloads(final List<? extends Record<P>> records) {
List<P> payloads = new ArrayList<>();
for (Record<P> record : records) {
payloads.add(record.getPayload());
}
return payloads;
} | [
"public",
"static",
"<",
"P",
">",
"List",
"<",
"P",
">",
"extractPayloads",
"(",
"final",
"List",
"<",
"?",
"extends",
"Record",
"<",
"P",
">",
">",
"records",
")",
"{",
"List",
"<",
"P",
">",
"payloads",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
... | Extract the payload form each record.
@param records the list of records
@param <P> the type of payload
@return the list of payloads | [
"Extract",
"the",
"payload",
"form",
"each",
"record",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-core/src/main/java/org/easybatch/core/record/PayloadExtractor.java#L47-L53 |
31,017 | j-easy/easy-batch | easybatch-flatfile/src/main/java/org/easybatch/flatfile/FixedLengthRecordMapper.java | FixedLengthRecordMapper.calculateOffsets | private int[] calculateOffsets(final int[] lengths) {
int[] offsets = new int[lengths.length + 1];
offsets[0] = 0;
for (int i = 0; i < lengths.length; i++) {
offsets[i + 1] = offsets[i] + lengths[i];
}
return offsets;
} | java | private int[] calculateOffsets(final int[] lengths) {
int[] offsets = new int[lengths.length + 1];
offsets[0] = 0;
for (int i = 0; i < lengths.length; i++) {
offsets[i + 1] = offsets[i] + lengths[i];
}
return offsets;
} | [
"private",
"int",
"[",
"]",
"calculateOffsets",
"(",
"final",
"int",
"[",
"]",
"lengths",
")",
"{",
"int",
"[",
"]",
"offsets",
"=",
"new",
"int",
"[",
"lengths",
".",
"length",
"+",
"1",
"]",
";",
"offsets",
"[",
"0",
"]",
"=",
"0",
";",
"for",
... | utility method to calculate field offsets used to extract fields from record. | [
"utility",
"method",
"to",
"calculate",
"field",
"offsets",
"used",
"to",
"extract",
"fields",
"from",
"record",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-flatfile/src/main/java/org/easybatch/flatfile/FixedLengthRecordMapper.java#L109-L116 |
31,018 | j-easy/easy-batch | easybatch-flatfile/src/main/java/org/easybatch/flatfile/DelimitedRecordMapper.java | DelimitedRecordMapper.setDelimiter | public void setDelimiter(final String delimiter) {
String prefix = "";
//escape the "pipe" character used in regular expression of String.split method
if ("|".equals(delimiter)) {
prefix = "\\";
}
this.delimiter = prefix + delimiter;
} | java | public void setDelimiter(final String delimiter) {
String prefix = "";
//escape the "pipe" character used in regular expression of String.split method
if ("|".equals(delimiter)) {
prefix = "\\";
}
this.delimiter = prefix + delimiter;
} | [
"public",
"void",
"setDelimiter",
"(",
"final",
"String",
"delimiter",
")",
"{",
"String",
"prefix",
"=",
"\"\"",
";",
"//escape the \"pipe\" character used in regular expression of String.split method",
"if",
"(",
"\"|\"",
".",
"equals",
"(",
"delimiter",
")",
")",
"... | Set the delimiter to use.
@param delimiter the delimiter to use | [
"Set",
"the",
"delimiter",
"to",
"use",
"."
] | 46286e1091dae1206674e2a30e0609c31feae36c | https://github.com/j-easy/easy-batch/blob/46286e1091dae1206674e2a30e0609c31feae36c/easybatch-flatfile/src/main/java/org/easybatch/flatfile/DelimitedRecordMapper.java#L255-L262 |
31,019 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/RestAction.java | RestAction.queue | @SuppressWarnings("unchecked")
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
{
Route.CompiledRoute route = finalizeRoute();
Checks.notNull(route, "Route");
RequestBody data = finalizeData();
CaseInsensitiveMap<String, String> headers = finalizeHeaders();
BooleanSupplier finisher = getFinisher();
if (success == null)
success = DEFAULT_SUCCESS == null ? FALLBACK_CONSUMER : DEFAULT_SUCCESS;
if (failure == null)
failure = DEFAULT_FAILURE == null ? FALLBACK_CONSUMER : DEFAULT_FAILURE;
api.get().getRequester().request(new Request<>(this, success, failure, finisher, true, data, rawData, route, headers));
} | java | @SuppressWarnings("unchecked")
public void queue(Consumer<? super T> success, Consumer<? super Throwable> failure)
{
Route.CompiledRoute route = finalizeRoute();
Checks.notNull(route, "Route");
RequestBody data = finalizeData();
CaseInsensitiveMap<String, String> headers = finalizeHeaders();
BooleanSupplier finisher = getFinisher();
if (success == null)
success = DEFAULT_SUCCESS == null ? FALLBACK_CONSUMER : DEFAULT_SUCCESS;
if (failure == null)
failure = DEFAULT_FAILURE == null ? FALLBACK_CONSUMER : DEFAULT_FAILURE;
api.get().getRequester().request(new Request<>(this, success, failure, finisher, true, data, rawData, route, headers));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"queue",
"(",
"Consumer",
"<",
"?",
"super",
"T",
">",
"success",
",",
"Consumer",
"<",
"?",
"super",
"Throwable",
">",
"failure",
")",
"{",
"Route",
".",
"CompiledRoute",
"route",
"=",
... | Submits a Request for execution.
<p><b>This method is asynchronous</b>
@param success
The success callback that will be called at a convenient time
for the API. (can be null)
@param failure
The failure callback that will be called if the Request
encounters an exception at its execution point. | [
"Submits",
"a",
"Request",
"for",
"execution",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/RestAction.java#L332-L345 |
31,020 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/WebSocketClient.java | WebSocketClient.reconnect | public void reconnect(boolean callFromQueue) throws InterruptedException
{
Set<MDC.MDCCloseable> contextEntries = null;
Map<String, String> previousContext = null;
{
ConcurrentMap<String, String> contextMap = api.getContextMap();
if (callFromQueue && contextMap != null)
{
previousContext = MDC.getCopyOfContextMap();
contextEntries = contextMap.entrySet().stream()
.map((entry) -> MDC.putCloseable(entry.getKey(), entry.getValue()))
.collect(Collectors.toSet());
}
}
if (shutdown)
{
api.setStatus(JDA.Status.SHUTDOWN);
api.getEventManager().handle(new ShutdownEvent(api, OffsetDateTime.now(), 1000));
return;
}
String message = "";
if (callFromQueue)
message = String.format("Queue is attempting to reconnect a shard...%s ", shardInfo != null ? " Shard: " + shardInfo.getShardString() : "");
LOG.debug("{}Attempting to reconnect in {}s", message, reconnectTimeoutS);
while (shouldReconnect)
{
api.setStatus(JDA.Status.WAITING_TO_RECONNECT);
int delay = reconnectTimeoutS;
Thread.sleep(delay * 1000);
handleIdentifyRateLimit = false;
api.setStatus(JDA.Status.ATTEMPTING_TO_RECONNECT);
LOG.debug("Attempting to reconnect!");
try
{
connect();
break;
}
catch (RejectedExecutionException ex)
{
// JDA has already been shutdown so we can stop here
api.setStatus(JDA.Status.SHUTDOWN);
api.getEventManager().handle(new ShutdownEvent(api, OffsetDateTime.now(), 1000));
return;
}
catch (RuntimeException ex)
{
reconnectTimeoutS = Math.min(reconnectTimeoutS << 1, api.getMaxReconnectDelay());
LOG.warn("Reconnect failed! Next attempt in {}s", reconnectTimeoutS);
}
}
if (contextEntries != null)
contextEntries.forEach(MDC.MDCCloseable::close);
if (previousContext != null)
previousContext.forEach(MDC::put);
} | java | public void reconnect(boolean callFromQueue) throws InterruptedException
{
Set<MDC.MDCCloseable> contextEntries = null;
Map<String, String> previousContext = null;
{
ConcurrentMap<String, String> contextMap = api.getContextMap();
if (callFromQueue && contextMap != null)
{
previousContext = MDC.getCopyOfContextMap();
contextEntries = contextMap.entrySet().stream()
.map((entry) -> MDC.putCloseable(entry.getKey(), entry.getValue()))
.collect(Collectors.toSet());
}
}
if (shutdown)
{
api.setStatus(JDA.Status.SHUTDOWN);
api.getEventManager().handle(new ShutdownEvent(api, OffsetDateTime.now(), 1000));
return;
}
String message = "";
if (callFromQueue)
message = String.format("Queue is attempting to reconnect a shard...%s ", shardInfo != null ? " Shard: " + shardInfo.getShardString() : "");
LOG.debug("{}Attempting to reconnect in {}s", message, reconnectTimeoutS);
while (shouldReconnect)
{
api.setStatus(JDA.Status.WAITING_TO_RECONNECT);
int delay = reconnectTimeoutS;
Thread.sleep(delay * 1000);
handleIdentifyRateLimit = false;
api.setStatus(JDA.Status.ATTEMPTING_TO_RECONNECT);
LOG.debug("Attempting to reconnect!");
try
{
connect();
break;
}
catch (RejectedExecutionException ex)
{
// JDA has already been shutdown so we can stop here
api.setStatus(JDA.Status.SHUTDOWN);
api.getEventManager().handle(new ShutdownEvent(api, OffsetDateTime.now(), 1000));
return;
}
catch (RuntimeException ex)
{
reconnectTimeoutS = Math.min(reconnectTimeoutS << 1, api.getMaxReconnectDelay());
LOG.warn("Reconnect failed! Next attempt in {}s", reconnectTimeoutS);
}
}
if (contextEntries != null)
contextEntries.forEach(MDC.MDCCloseable::close);
if (previousContext != null)
previousContext.forEach(MDC::put);
} | [
"public",
"void",
"reconnect",
"(",
"boolean",
"callFromQueue",
")",
"throws",
"InterruptedException",
"{",
"Set",
"<",
"MDC",
".",
"MDCCloseable",
">",
"contextEntries",
"=",
"null",
";",
"Map",
"<",
"String",
",",
"String",
">",
"previousContext",
"=",
"null... | This method is used to start the reconnect of the JDA instance.
It is public for access from SessionReconnectQueue extensions.
@param callFromQueue
whether this was in SessionReconnectQueue and got polled | [
"This",
"method",
"is",
"used",
"to",
"start",
"the",
"reconnect",
"of",
"the",
"JDA",
"instance",
".",
"It",
"is",
"public",
"for",
"access",
"from",
"SessionReconnectQueue",
"extensions",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/WebSocketClient.java#L534-L588 |
31,021 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/managers/GuildController.java | GuildController.setNickname | @CheckReturnValue
public AuditableRestAction<Void> setNickname(Member member, String nickname)
{
Checks.notNull(member, "Member");
checkGuild(member.getGuild(), "Member");
if(member.equals(getGuild().getSelfMember()))
{
if(!member.hasPermission(Permission.NICKNAME_CHANGE)
&& !member.hasPermission(Permission.NICKNAME_MANAGE))
throw new InsufficientPermissionException(Permission.NICKNAME_CHANGE, "You neither have NICKNAME_CHANGE nor NICKNAME_MANAGE permission!");
}
else
{
checkPermission(Permission.NICKNAME_MANAGE);
checkPosition(member);
}
if (Objects.equals(nickname, member.getNickname()))
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
if (nickname == null)
nickname = "";
JSONObject body = new JSONObject().put("nick", nickname);
Route.CompiledRoute route;
if (member.equals(getGuild().getSelfMember()))
route = Route.Guilds.MODIFY_SELF_NICK.compile(getGuild().getId());
else
route = Route.Guilds.MODIFY_MEMBER.compile(getGuild().getId(), member.getUser().getId());
return new AuditableRestAction<Void>(getGuild().getJDA(), route, body)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
} | java | @CheckReturnValue
public AuditableRestAction<Void> setNickname(Member member, String nickname)
{
Checks.notNull(member, "Member");
checkGuild(member.getGuild(), "Member");
if(member.equals(getGuild().getSelfMember()))
{
if(!member.hasPermission(Permission.NICKNAME_CHANGE)
&& !member.hasPermission(Permission.NICKNAME_MANAGE))
throw new InsufficientPermissionException(Permission.NICKNAME_CHANGE, "You neither have NICKNAME_CHANGE nor NICKNAME_MANAGE permission!");
}
else
{
checkPermission(Permission.NICKNAME_MANAGE);
checkPosition(member);
}
if (Objects.equals(nickname, member.getNickname()))
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
if (nickname == null)
nickname = "";
JSONObject body = new JSONObject().put("nick", nickname);
Route.CompiledRoute route;
if (member.equals(getGuild().getSelfMember()))
route = Route.Guilds.MODIFY_SELF_NICK.compile(getGuild().getId());
else
route = Route.Guilds.MODIFY_MEMBER.compile(getGuild().getId(), member.getUser().getId());
return new AuditableRestAction<Void>(getGuild().getJDA(), route, body)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
} | [
"@",
"CheckReturnValue",
"public",
"AuditableRestAction",
"<",
"Void",
">",
"setNickname",
"(",
"Member",
"member",
",",
"String",
"nickname",
")",
"{",
"Checks",
".",
"notNull",
"(",
"member",
",",
"\"Member\"",
")",
";",
"checkGuild",
"(",
"member",
".",
"... | Changes a Member's nickname in this guild.
The nickname is visible to all members of this guild.
<p>To change the nickname for the currently logged in account
only the Permission {@link net.dv8tion.jda.core.Permission#NICKNAME_CHANGE NICKNAME_CHANGE} is required.
<br>To change the nickname of <b>any</b> {@link net.dv8tion.jda.core.entities.Member Member} for this {@link net.dv8tion.jda.core.entities.Guild Guild}
the Permission {@link net.dv8tion.jda.core.Permission#NICKNAME_MANAGE NICKNAME_MANAGE} is required.
<p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
<ul>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
<br>The nickname of the target Member is not modifiable due to a permission discrepancy</li>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
<br>We were removed from the Guild before finishing the task</li>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
<br>The specified Member was removed from the Guild before finishing the task</li>
</ul>
@param member
The {@link net.dv8tion.jda.core.entities.Member Member} for which the nickname should be changed.
@param nickname
The new nickname of the {@link net.dv8tion.jda.core.entities.Member Member}, provide {@code null} or an
empty String to reset the nickname
@throws IllegalArgumentException
If the specified {@link net.dv8tion.jda.core.entities.Member Member}
is not from the same {@link net.dv8tion.jda.core.entities.Guild Guild}.
Or if the provided member is {@code null}
@throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
<ul>
<li>If attempting to set nickname for self and the logged in account has neither {@link net.dv8tion.jda.core.Permission#NICKNAME_CHANGE}
or {@link net.dv8tion.jda.core.Permission#NICKNAME_MANAGE}</li>
<li>If attempting to set nickname for another member and the logged in account does not have {@link net.dv8tion.jda.core.Permission#NICKNAME_MANAGE}</li>
</ul>
@throws net.dv8tion.jda.core.exceptions.HierarchyException
If attempting to set nickname for another member and the logged in account cannot manipulate the other user due to permission hierarchy position.
<br>See {@link net.dv8tion.jda.core.utils.PermissionUtil#canInteract(Member, Member) PermissionUtil.canInteract(Member, Member)}
@return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction} | [
"Changes",
"a",
"Member",
"s",
"nickname",
"in",
"this",
"guild",
".",
"The",
"nickname",
"is",
"visible",
"to",
"all",
"members",
"of",
"this",
"guild",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/managers/GuildController.java#L221-L264 |
31,022 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/managers/GuildController.java | GuildController.unban | @CheckReturnValue
public AuditableRestAction<Void> unban(String userId)
{
Checks.isSnowflake(userId, "User ID");
checkPermission(Permission.BAN_MEMBERS);
Route.CompiledRoute route = Route.Guilds.UNBAN.compile(getGuild().getId(), userId);
return new AuditableRestAction<Void>(getGuild().getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else if (response.code == 404)
request.onFailure(new IllegalArgumentException("User with provided id \"" + userId + "\" is not banned! Cannot unban a user who is not currently banned!"));
else
request.onFailure(response);
}
};
} | java | @CheckReturnValue
public AuditableRestAction<Void> unban(String userId)
{
Checks.isSnowflake(userId, "User ID");
checkPermission(Permission.BAN_MEMBERS);
Route.CompiledRoute route = Route.Guilds.UNBAN.compile(getGuild().getId(), userId);
return new AuditableRestAction<Void>(getGuild().getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else if (response.code == 404)
request.onFailure(new IllegalArgumentException("User with provided id \"" + userId + "\" is not banned! Cannot unban a user who is not currently banned!"));
else
request.onFailure(response);
}
};
} | [
"@",
"CheckReturnValue",
"public",
"AuditableRestAction",
"<",
"Void",
">",
"unban",
"(",
"String",
"userId",
")",
"{",
"Checks",
".",
"isSnowflake",
"(",
"userId",
",",
"\"User ID\"",
")",
";",
"checkPermission",
"(",
"Permission",
".",
"BAN_MEMBERS",
")",
";... | Unbans the a user specified by the userId from this Guild.
<p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
<ul>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
<br>The target Member cannot be unbanned due to a permission discrepancy</li>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
<br>We were removed from the Guild before finishing the task</li>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_USER UNKNOWN_USER}
<br>The specified User is invalid</li>
</ul>
@param userId
The id of the {@link net.dv8tion.jda.core.entities.User User} to unban.
@throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
If the logged in account does not have the {@link net.dv8tion.jda.core.Permission#BAN_MEMBERS} permission.
@throws IllegalArgumentException
If the provided id is null or blank
@return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction} | [
"Unbans",
"the",
"a",
"user",
"specified",
"by",
"the",
"userId",
"from",
"this",
"Guild",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/managers/GuildController.java#L914-L934 |
31,023 | DV8FromTheWorld/JDA | src/examples/java/MessageListenerExample.java | MessageListenerExample.main | public static void main(String[] args)
{
//We construct a builder for a BOT account. If we wanted to use a CLIENT account
// we would use AccountType.CLIENT
try
{
JDA jda = new JDABuilder("Your-Token-Goes-Here") // The token of the account that is logging in.
.addEventListener(new MessageListenerExample()) // An instance of a class that will handle events.
.build();
jda.awaitReady(); // Blocking guarantees that JDA will be completely loaded.
System.out.println("Finished Building JDA!");
}
catch (LoginException e)
{
//If anything goes wrong in terms of authentication, this is the exception that will represent it
e.printStackTrace();
}
catch (InterruptedException e)
{
//Due to the fact that awaitReady is a blocking method, one which waits until JDA is fully loaded,
// the waiting can be interrupted. This is the exception that would fire in that situation.
//As a note: in this extremely simplified example this will never occur. In fact, this will never occur unless
// you use awaitReady in a thread that has the possibility of being interrupted (async thread usage and interrupts)
e.printStackTrace();
}
} | java | public static void main(String[] args)
{
//We construct a builder for a BOT account. If we wanted to use a CLIENT account
// we would use AccountType.CLIENT
try
{
JDA jda = new JDABuilder("Your-Token-Goes-Here") // The token of the account that is logging in.
.addEventListener(new MessageListenerExample()) // An instance of a class that will handle events.
.build();
jda.awaitReady(); // Blocking guarantees that JDA will be completely loaded.
System.out.println("Finished Building JDA!");
}
catch (LoginException e)
{
//If anything goes wrong in terms of authentication, this is the exception that will represent it
e.printStackTrace();
}
catch (InterruptedException e)
{
//Due to the fact that awaitReady is a blocking method, one which waits until JDA is fully loaded,
// the waiting can be interrupted. This is the exception that would fire in that situation.
//As a note: in this extremely simplified example this will never occur. In fact, this will never occur unless
// you use awaitReady in a thread that has the possibility of being interrupted (async thread usage and interrupts)
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"//We construct a builder for a BOT account. If we wanted to use a CLIENT account",
"// we would use AccountType.CLIENT",
"try",
"{",
"JDA",
"jda",
"=",
"new",
"JDABuilder",
"(",
"\"Your-Token-Go... | This is the method where the program starts. | [
"This",
"is",
"the",
"method",
"where",
"the",
"program",
"starts",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/examples/java/MessageListenerExample.java#L36-L61 |
31,024 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/audit/AuditLogEntry.java | AuditLogEntry.getChangesForKeys | public List<AuditLogChange> getChangesForKeys(AuditLogKey... keys)
{
Checks.notNull(keys, "Keys");
List<AuditLogChange> changes = new ArrayList<>(keys.length);
for (AuditLogKey key : keys)
{
AuditLogChange change = getChangeByKey(key);
if (change != null)
changes.add(change);
}
return Collections.unmodifiableList(changes);
} | java | public List<AuditLogChange> getChangesForKeys(AuditLogKey... keys)
{
Checks.notNull(keys, "Keys");
List<AuditLogChange> changes = new ArrayList<>(keys.length);
for (AuditLogKey key : keys)
{
AuditLogChange change = getChangeByKey(key);
if (change != null)
changes.add(change);
}
return Collections.unmodifiableList(changes);
} | [
"public",
"List",
"<",
"AuditLogChange",
">",
"getChangesForKeys",
"(",
"AuditLogKey",
"...",
"keys",
")",
"{",
"Checks",
".",
"notNull",
"(",
"keys",
",",
"\"Keys\"",
")",
";",
"List",
"<",
"AuditLogChange",
">",
"changes",
"=",
"new",
"ArrayList",
"<>",
... | Filters all changes by the specified keys
@param keys
Varargs {@link net.dv8tion.jda.core.audit.AuditLogKey AuditLogKeys} to look for
@throws java.lang.IllegalArgumentException
If provided with null array
@return Possibly-empty, never-null immutable list of {@link AuditLogChange AuditLogChanges} | [
"Filters",
"all",
"changes",
"by",
"the",
"specified",
"keys"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/audit/AuditLogEntry.java#L211-L222 |
31,025 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/bot/sharding/DefaultShardManagerBuilder.java | DefaultShardManagerBuilder.removeEventListenerProviders | public DefaultShardManagerBuilder removeEventListenerProviders(final Collection<IntFunction<Object>> listenerProviders)
{
Checks.noneNull(listenerProviders, "listener providers");
this.listenerProviders.removeAll(listenerProviders);
return this;
} | java | public DefaultShardManagerBuilder removeEventListenerProviders(final Collection<IntFunction<Object>> listenerProviders)
{
Checks.noneNull(listenerProviders, "listener providers");
this.listenerProviders.removeAll(listenerProviders);
return this;
} | [
"public",
"DefaultShardManagerBuilder",
"removeEventListenerProviders",
"(",
"final",
"Collection",
"<",
"IntFunction",
"<",
"Object",
">",
">",
"listenerProviders",
")",
"{",
"Checks",
".",
"noneNull",
"(",
"listenerProviders",
",",
"\"listener providers\"",
")",
";",
... | Removes all provided listener providers from the list of listener providers.
@param listenerProviders
The listener provider(s) to remove from the list of listener providers.
@return The DefaultShardManagerBuilder instance. Useful for chaining. | [
"Removes",
"all",
"provided",
"listener",
"providers",
"from",
"the",
"list",
"of",
"listener",
"providers",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/bot/sharding/DefaultShardManagerBuilder.java#L361-L367 |
31,026 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/MessageAction.java | MessageAction.clearFiles | @CheckReturnValue
public MessageAction clearFiles(BiConsumer<String, InputStream> finalizer)
{
Checks.notNull(finalizer, "Finalizer");
for (Iterator<Map.Entry<String, InputStream>> it = files.entrySet().iterator(); it.hasNext();)
{
Map.Entry<String, InputStream> entry = it.next();
finalizer.accept(entry.getKey(), entry.getValue());
it.remove();
}
clearResources();
return this;
} | java | @CheckReturnValue
public MessageAction clearFiles(BiConsumer<String, InputStream> finalizer)
{
Checks.notNull(finalizer, "Finalizer");
for (Iterator<Map.Entry<String, InputStream>> it = files.entrySet().iterator(); it.hasNext();)
{
Map.Entry<String, InputStream> entry = it.next();
finalizer.accept(entry.getKey(), entry.getValue());
it.remove();
}
clearResources();
return this;
} | [
"@",
"CheckReturnValue",
"public",
"MessageAction",
"clearFiles",
"(",
"BiConsumer",
"<",
"String",
",",
"InputStream",
">",
"finalizer",
")",
"{",
"Checks",
".",
"notNull",
"(",
"finalizer",
",",
"\"Finalizer\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"Map",
... | Clears all previously added files
@param finalizer
BiConsumer useful to <b>close</b> remaining resources,
the consumer will receive the name as a string parameter and the resource as {@code InputStream}.
@return Updated MessageAction for chaining convenience
@see java.io.Closeable | [
"Clears",
"all",
"previously",
"added",
"files"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/MessageAction.java#L516-L528 |
31,027 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/events/self/SelfUpdateAvatarEvent.java | SelfUpdateAvatarEvent.getOldAvatarUrl | public String getOldAvatarUrl()
{
return previous == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), previous, previous.startsWith("a_") ? ".gif" : ".png");
} | java | public String getOldAvatarUrl()
{
return previous == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), previous, previous.startsWith("a_") ? ".gif" : ".png");
} | [
"public",
"String",
"getOldAvatarUrl",
"(",
")",
"{",
"return",
"previous",
"==",
"null",
"?",
"null",
":",
"String",
".",
"format",
"(",
"AVATAR_URL",
",",
"getSelfUser",
"(",
")",
".",
"getId",
"(",
")",
",",
"previous",
",",
"previous",
".",
"startsWi... | The old avatar url
@return The old avatar url | [
"The",
"old",
"avatar",
"url"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/events/self/SelfUpdateAvatarEvent.java#L53-L56 |
31,028 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/events/self/SelfUpdateAvatarEvent.java | SelfUpdateAvatarEvent.getNewAvatarUrl | public String getNewAvatarUrl()
{
return next == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), next, next.startsWith("a_") ? ".gif" : ".png");
} | java | public String getNewAvatarUrl()
{
return next == null ? null : String.format(AVATAR_URL, getSelfUser().getId(), next, next.startsWith("a_") ? ".gif" : ".png");
} | [
"public",
"String",
"getNewAvatarUrl",
"(",
")",
"{",
"return",
"next",
"==",
"null",
"?",
"null",
":",
"String",
".",
"format",
"(",
"AVATAR_URL",
",",
"getSelfUser",
"(",
")",
".",
"getId",
"(",
")",
",",
"next",
",",
"next",
".",
"startsWith",
"(",
... | The new avatar url
@return The new avatar url | [
"The",
"new",
"avatar",
"url"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/events/self/SelfUpdateAvatarEvent.java#L73-L76 |
31,029 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.isEmpty | public boolean isEmpty()
{
return title == null
&& description.length() == 0
&& timestamp == null
//&& color == null color alone is not enough to send
&& thumbnail == null
&& author == null
&& footer == null
&& image == null
&& fields.isEmpty();
} | java | public boolean isEmpty()
{
return title == null
&& description.length() == 0
&& timestamp == null
//&& color == null color alone is not enough to send
&& thumbnail == null
&& author == null
&& footer == null
&& image == null
&& fields.isEmpty();
} | [
"public",
"boolean",
"isEmpty",
"(",
")",
"{",
"return",
"title",
"==",
"null",
"&&",
"description",
".",
"length",
"(",
")",
"==",
"0",
"&&",
"timestamp",
"==",
"null",
"//&& color == null color alone is not enough to send",
"&&",
"thumbnail",
"==",
"null",
"&&... | Checks if the given embed is empty. Empty embeds will throw an exception if built
@return true if the embed is empty and cannot be built | [
"Checks",
"if",
"the",
"given",
"embed",
"is",
"empty",
".",
"Empty",
"embeds",
"will",
"throw",
"an",
"exception",
"if",
"built"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L149-L160 |
31,030 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setDescription | public final EmbedBuilder setDescription(CharSequence description)
{
this.description.setLength(0);
if (description != null && description.length() >= 1)
appendDescription(description);
return this;
} | java | public final EmbedBuilder setDescription(CharSequence description)
{
this.description.setLength(0);
if (description != null && description.length() >= 1)
appendDescription(description);
return this;
} | [
"public",
"final",
"EmbedBuilder",
"setDescription",
"(",
"CharSequence",
"description",
")",
"{",
"this",
".",
"description",
".",
"setLength",
"(",
"0",
")",
";",
"if",
"(",
"description",
"!=",
"null",
"&&",
"description",
".",
"length",
"(",
")",
">=",
... | Sets the Description of the embed. This is where the main chunk of text for an embed is typically placed.
<p><b><a href="http://i.imgur.com/lbchtwk.png">Example</a></b>
@param description
the description of the embed, {@code null} to reset
@throws java.lang.IllegalArgumentException
If the length of {@code description} is greater than {@link net.dv8tion.jda.core.entities.MessageEmbed#TEXT_MAX_LENGTH}
@return the builder after the description has been set | [
"Sets",
"the",
"Description",
"of",
"the",
"embed",
".",
"This",
"is",
"where",
"the",
"main",
"chunk",
"of",
"text",
"for",
"an",
"embed",
"is",
"typically",
"placed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L303-L309 |
31,031 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.appendDescription | public EmbedBuilder appendDescription(CharSequence description)
{
Checks.notNull(description, "description");
Checks.check(this.description.length() + description.length() <= MessageEmbed.TEXT_MAX_LENGTH,
"Description cannot be longer than %d characters.", MessageEmbed.TEXT_MAX_LENGTH);
this.description.append(description);
return this;
} | java | public EmbedBuilder appendDescription(CharSequence description)
{
Checks.notNull(description, "description");
Checks.check(this.description.length() + description.length() <= MessageEmbed.TEXT_MAX_LENGTH,
"Description cannot be longer than %d characters.", MessageEmbed.TEXT_MAX_LENGTH);
this.description.append(description);
return this;
} | [
"public",
"EmbedBuilder",
"appendDescription",
"(",
"CharSequence",
"description",
")",
"{",
"Checks",
".",
"notNull",
"(",
"description",
",",
"\"description\"",
")",
";",
"Checks",
".",
"check",
"(",
"this",
".",
"description",
".",
"length",
"(",
")",
"+",
... | Appends to the description of the embed. This is where the main chunk of text for an embed is typically placed.
<p><b><a href="http://i.imgur.com/lbchtwk.png">Example</a></b>
@param description
the string to append to the description of the embed
@throws java.lang.IllegalArgumentException
<ul>
<li>If the provided {@code description} String is null</li>
<li>If the length of {@code description} is greater than {@link net.dv8tion.jda.core.entities.MessageEmbed#TEXT_MAX_LENGTH}.</li>
</ul>
@return the builder after the description has been set | [
"Appends",
"to",
"the",
"description",
"of",
"the",
"embed",
".",
"This",
"is",
"where",
"the",
"main",
"chunk",
"of",
"text",
"for",
"an",
"embed",
"is",
"typically",
"placed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L327-L334 |
31,032 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setTimestamp | public EmbedBuilder setTimestamp(TemporalAccessor temporal)
{
if (temporal == null)
{
this.timestamp = null;
}
else if (temporal instanceof OffsetDateTime)
{
this.timestamp = (OffsetDateTime) temporal;
}
else
{
ZoneOffset offset;
try
{
offset = ZoneOffset.from(temporal);
}
catch (DateTimeException ignore)
{
offset = ZoneOffset.UTC;
}
try
{
LocalDateTime ldt = LocalDateTime.from(temporal);
this.timestamp = OffsetDateTime.of(ldt, offset);
}
catch (DateTimeException ignore)
{
try
{
Instant instant = Instant.from(temporal);
this.timestamp = OffsetDateTime.ofInstant(instant, offset);
}
catch (DateTimeException ex)
{
throw new DateTimeException("Unable to obtain OffsetDateTime from TemporalAccessor: " +
temporal + " of type " + temporal.getClass().getName(), ex);
}
}
}
return this;
} | java | public EmbedBuilder setTimestamp(TemporalAccessor temporal)
{
if (temporal == null)
{
this.timestamp = null;
}
else if (temporal instanceof OffsetDateTime)
{
this.timestamp = (OffsetDateTime) temporal;
}
else
{
ZoneOffset offset;
try
{
offset = ZoneOffset.from(temporal);
}
catch (DateTimeException ignore)
{
offset = ZoneOffset.UTC;
}
try
{
LocalDateTime ldt = LocalDateTime.from(temporal);
this.timestamp = OffsetDateTime.of(ldt, offset);
}
catch (DateTimeException ignore)
{
try
{
Instant instant = Instant.from(temporal);
this.timestamp = OffsetDateTime.ofInstant(instant, offset);
}
catch (DateTimeException ex)
{
throw new DateTimeException("Unable to obtain OffsetDateTime from TemporalAccessor: " +
temporal + " of type " + temporal.getClass().getName(), ex);
}
}
}
return this;
} | [
"public",
"EmbedBuilder",
"setTimestamp",
"(",
"TemporalAccessor",
"temporal",
")",
"{",
"if",
"(",
"temporal",
"==",
"null",
")",
"{",
"this",
".",
"timestamp",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"temporal",
"instanceof",
"OffsetDateTime",
")",
"{",
... | Sets the Timestamp of the embed.
<p><b><a href="http://i.imgur.com/YP4NiER.png">Example</a></b>
<p><b>Hint:</b> You can get the current time using {@link java.time.Instant#now() Instant.now()} or convert time from a
millisecond representation by using {@link java.time.Instant#ofEpochMilli(long) Instant.ofEpochMilli(long)};
@param temporal
the temporal accessor of the timestamp
@return the builder after the timestamp has been set | [
"Sets",
"the",
"Timestamp",
"of",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L349-L390 |
31,033 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setColor | public EmbedBuilder setColor(Color color)
{
this.color = color == null ? Role.DEFAULT_COLOR_RAW : color.getRGB();
return this;
} | java | public EmbedBuilder setColor(Color color)
{
this.color = color == null ? Role.DEFAULT_COLOR_RAW : color.getRGB();
return this;
} | [
"public",
"EmbedBuilder",
"setColor",
"(",
"Color",
"color",
")",
"{",
"this",
".",
"color",
"=",
"color",
"==",
"null",
"?",
"Role",
".",
"DEFAULT_COLOR_RAW",
":",
"color",
".",
"getRGB",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Sets the Color of the embed.
<a href="http://i.imgur.com/2YnxnRM.png" target="_blank">Example</a>
@param color
The {@link java.awt.Color Color} of the embed
or {@code null} to use no color
@return the builder after the color has been set
@see #setColor(int) | [
"Sets",
"the",
"Color",
"of",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L405-L409 |
31,034 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setThumbnail | public EmbedBuilder setThumbnail(String url)
{
if (url == null)
{
this.thumbnail = null;
}
else
{
urlCheck(url);
this.thumbnail = new MessageEmbed.Thumbnail(url, null, 0, 0);
}
return this;
} | java | public EmbedBuilder setThumbnail(String url)
{
if (url == null)
{
this.thumbnail = null;
}
else
{
urlCheck(url);
this.thumbnail = new MessageEmbed.Thumbnail(url, null, 0, 0);
}
return this;
} | [
"public",
"EmbedBuilder",
"setThumbnail",
"(",
"String",
"url",
")",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"this",
".",
"thumbnail",
"=",
"null",
";",
"}",
"else",
"{",
"urlCheck",
"(",
"url",
")",
";",
"this",
".",
"thumbnail",
"=",
"new",
... | Sets the Thumbnail of the embed.
<p><b><a href="http://i.imgur.com/Zc3qwqB.png">Example</a></b>
<p><b>Uploading images with Embeds</b>
<br>When uploading an <u>image</u>
(using {@link net.dv8tion.jda.core.entities.MessageChannel#sendFile(java.io.File, net.dv8tion.jda.core.entities.Message) MessageChannel.sendFile(...)})
you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
<p><u>Example</u>
<pre><code>
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
InputStream file = new URL("https://http.cat/500").openStream();
embed.setThumbnail("attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
</code></pre>
@param url
the url of the thumbnail of the embed
@throws java.lang.IllegalArgumentException
<ul>
<li>If the length of {@code url} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code url} is not a properly formatted http or https url.</li>
</ul>
@return the builder after the thumbnail has been set | [
"Sets",
"the",
"Thumbnail",
"of",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L462-L474 |
31,035 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setImage | public EmbedBuilder setImage(String url)
{
if (url == null)
{
this.image = null;
}
else
{
urlCheck(url);
this.image = new MessageEmbed.ImageInfo(url, null, 0, 0);
}
return this;
} | java | public EmbedBuilder setImage(String url)
{
if (url == null)
{
this.image = null;
}
else
{
urlCheck(url);
this.image = new MessageEmbed.ImageInfo(url, null, 0, 0);
}
return this;
} | [
"public",
"EmbedBuilder",
"setImage",
"(",
"String",
"url",
")",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"this",
".",
"image",
"=",
"null",
";",
"}",
"else",
"{",
"urlCheck",
"(",
"url",
")",
";",
"this",
".",
"image",
"=",
"new",
"MessageEm... | Sets the Image of the embed.
<p><b><a href="http://i.imgur.com/2hzuHFJ.png">Example</a></b>
<p><b>Uploading images with Embeds</b>
<br>When uploading an <u>image</u>
(using {@link net.dv8tion.jda.core.entities.MessageChannel#sendFile(java.io.File, net.dv8tion.jda.core.entities.Message) MessageChannel.sendFile(...)})
you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
<p><u>Example</u>
<pre><code>
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
InputStream file = new URL("https://http.cat/500").openStream();
embed.setImage("attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
</code></pre>
@param url
the url of the image of the embed
@throws java.lang.IllegalArgumentException
<ul>
<li>If the length of {@code url} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code url} is not a properly formatted http or https url.</li>
</ul>
@return the builder after the image has been set
@see net.dv8tion.jda.core.entities.MessageChannel#sendFile(java.io.File, String, net.dv8tion.jda.core.entities.Message) MessageChannel.sendFile(...) | [
"Sets",
"the",
"Image",
"of",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L511-L523 |
31,036 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setAuthor | public EmbedBuilder setAuthor(String name, String url)
{
return setAuthor(name, url, null);
} | java | public EmbedBuilder setAuthor(String name, String url)
{
return setAuthor(name, url, null);
} | [
"public",
"EmbedBuilder",
"setAuthor",
"(",
"String",
"name",
",",
"String",
"url",
")",
"{",
"return",
"setAuthor",
"(",
"name",
",",
"url",
",",
"null",
")",
";",
"}"
] | Sets the Author of the embed. The author appears in the top left of the embed and can have a small
image beside it along with the author's name being made clickable by way of providing a url.
This convenience method just sets the name and the url.
<p><b><a href="http://i.imgur.com/JgZtxIM.png">Example</a></b>
@param name
the name of the author of the embed. If this is not set, the author will not appear in the embed
@param url
the url of the author of the embed
@throws java.lang.IllegalArgumentException
<ul>
<li>If the length of {@code url} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code url} is not a properly formatted http or https url.</li>
</ul>
@return the builder after the author has been set | [
"Sets",
"the",
"Author",
"of",
"the",
"embed",
".",
"The",
"author",
"appears",
"in",
"the",
"top",
"left",
"of",
"the",
"embed",
"and",
"can",
"have",
"a",
"small",
"image",
"beside",
"it",
"along",
"with",
"the",
"author",
"s",
"name",
"being",
"made... | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L562-L565 |
31,037 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setAuthor | public EmbedBuilder setAuthor(String name, String url, String iconUrl)
{
//We only check if the name is null because its presence is what determines if the
// the author will appear in the embed.
if (name == null)
{
this.author = null;
}
else
{
urlCheck(url);
urlCheck(iconUrl);
this.author = new MessageEmbed.AuthorInfo(name, url, iconUrl, null);
}
return this;
} | java | public EmbedBuilder setAuthor(String name, String url, String iconUrl)
{
//We only check if the name is null because its presence is what determines if the
// the author will appear in the embed.
if (name == null)
{
this.author = null;
}
else
{
urlCheck(url);
urlCheck(iconUrl);
this.author = new MessageEmbed.AuthorInfo(name, url, iconUrl, null);
}
return this;
} | [
"public",
"EmbedBuilder",
"setAuthor",
"(",
"String",
"name",
",",
"String",
"url",
",",
"String",
"iconUrl",
")",
"{",
"//We only check if the name is null because its presence is what determines if the",
"// the author will appear in the embed.",
"if",
"(",
"name",
"==",
"n... | Sets the Author of the embed. The author appears in the top left of the embed and can have a small
image beside it along with the author's name being made clickable by way of providing a url.
<p><b><a href="http://i.imgur.com/JgZtxIM.png">Example</a></b>
<p><b>Uploading images with Embeds</b>
<br>When uploading an <u>image</u>
(using {@link net.dv8tion.jda.core.entities.MessageChannel#sendFile(java.io.File, net.dv8tion.jda.core.entities.Message) MessageChannel.sendFile(...)})
you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
<p><u>Example</u>
<pre><code>
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
InputStream file = new URL("https://http.cat/500").openStream();
embed.setAuthor("Minn", null, "attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
</code></pre>
@param name
the name of the author of the embed. If this is not set, the author will not appear in the embed
@param url
the url of the author of the embed
@param iconUrl
the url of the icon for the author
@throws java.lang.IllegalArgumentException
<ul>
<li>If the length of {@code url} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code url} is not a properly formatted http or https url.</li>
<li>If the length of {@code iconUrl} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code iconUrl} is not a properly formatted http or https url.</li>
</ul>
@return the builder after the author has been set | [
"Sets",
"the",
"Author",
"of",
"the",
"embed",
".",
"The",
"author",
"appears",
"in",
"the",
"top",
"left",
"of",
"the",
"embed",
"and",
"can",
"have",
"a",
"small",
"image",
"beside",
"it",
"along",
"with",
"the",
"author",
"s",
"name",
"being",
"made... | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L607-L622 |
31,038 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.setFooter | public EmbedBuilder setFooter(String text, String iconUrl)
{
//We only check if the text is null because its presence is what determines if the
// footer will appear in the embed.
if (text == null)
{
this.footer = null;
}
else
{
Checks.check(text.length() <= MessageEmbed.TEXT_MAX_LENGTH, "Text cannot be longer than %d characters.", MessageEmbed.TEXT_MAX_LENGTH);
urlCheck(iconUrl);
this.footer = new MessageEmbed.Footer(text, iconUrl, null);
}
return this;
} | java | public EmbedBuilder setFooter(String text, String iconUrl)
{
//We only check if the text is null because its presence is what determines if the
// footer will appear in the embed.
if (text == null)
{
this.footer = null;
}
else
{
Checks.check(text.length() <= MessageEmbed.TEXT_MAX_LENGTH, "Text cannot be longer than %d characters.", MessageEmbed.TEXT_MAX_LENGTH);
urlCheck(iconUrl);
this.footer = new MessageEmbed.Footer(text, iconUrl, null);
}
return this;
} | [
"public",
"EmbedBuilder",
"setFooter",
"(",
"String",
"text",
",",
"String",
"iconUrl",
")",
"{",
"//We only check if the text is null because its presence is what determines if the",
"// footer will appear in the embed.",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"this",
... | Sets the Footer of the embed.
<p><b><a href="http://i.imgur.com/jdf4sbi.png">Example</a></b>
<p><b>Uploading images with Embeds</b>
<br>When uploading an <u>image</u>
(using {@link net.dv8tion.jda.core.entities.MessageChannel#sendFile(java.io.File, net.dv8tion.jda.core.entities.Message) MessageChannel.sendFile(...)})
you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
<p><u>Example</u>
<pre><code>
MessageChannel channel; // = reference of a MessageChannel
MessageBuilder message = new MessageBuilder();
EmbedBuilder embed = new EmbedBuilder();
InputStream file = new URL("https://http.cat/500").openStream();
embed.setFooter("Cool footer!", "attachment://cat.png") // we specify this in sendFile as "cat.png"
.setDescription("This is a cute cat :3");
message.setEmbed(embed.build());
channel.sendFile(file, "cat.png", message.build()).queue();
</code></pre>
@param text
the text of the footer of the embed. If this is not set, the footer will not appear in the embed.
@param iconUrl
the url of the icon for the footer
@throws java.lang.IllegalArgumentException
<ul>
<li>If the length of {@code text} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#TEXT_MAX_LENGTH}.</li>
<li>If the length of {@code iconUrl} is longer than {@link net.dv8tion.jda.core.entities.MessageEmbed#URL_MAX_LENGTH}.</li>
<li>If the provided {@code iconUrl} is not a properly formatted http or https url.</li>
</ul>
@return the builder after the footer has been set | [
"Sets",
"the",
"Footer",
"of",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L660-L675 |
31,039 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/EmbedBuilder.java | EmbedBuilder.addField | public EmbedBuilder addField(String name, String value, boolean inline)
{
if (name == null && value == null)
return this;
this.fields.add(new MessageEmbed.Field(name, value, inline));
return this;
} | java | public EmbedBuilder addField(String name, String value, boolean inline)
{
if (name == null && value == null)
return this;
this.fields.add(new MessageEmbed.Field(name, value, inline));
return this;
} | [
"public",
"EmbedBuilder",
"addField",
"(",
"String",
"name",
",",
"String",
"value",
",",
"boolean",
"inline",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"&&",
"value",
"==",
"null",
")",
"return",
"this",
";",
"this",
".",
"fields",
".",
"add",
"(",
... | Adds a Field to the embed.
<p>Note: If a blank string is provided to either {@code name} or {@code value}, the blank string is replaced
with {@link net.dv8tion.jda.core.EmbedBuilder#ZERO_WIDTH_SPACE}.
<p><b><a href="http://i.imgur.com/gnjzCoo.png">Example of Inline</a></b>
<p><b><a href="http://i.imgur.com/Ky0KlsT.png">Example if Non-inline</a></b>
@param name
the name of the Field, displayed in bold above the {@code value}.
@param value
the contents of the field.
@param inline
whether or not this field should display inline.
@throws java.lang.IllegalArgumentException
<ul>
<li>If only {@code name} or {@code value} is set. Both must be set.</li>
<li>If the length of {@code name} is greater than {@link net.dv8tion.jda.core.entities.MessageEmbed#TITLE_MAX_LENGTH}.</li>
<li>If the length of {@code value} is greater than {@link net.dv8tion.jda.core.entities.MessageEmbed#VALUE_MAX_LENGTH}.</li>
</ul>
@return the builder after the field has been added | [
"Adds",
"a",
"Field",
"to",
"the",
"embed",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/EmbedBuilder.java#L716-L722 |
31,040 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java | WebhookMessageBuilder.reset | public WebhookMessageBuilder reset()
{
content.setLength(0);
embeds.clear();
resetFiles();
username = null;
avatarUrl = null;
isTTS = false;
return this;
} | java | public WebhookMessageBuilder reset()
{
content.setLength(0);
embeds.clear();
resetFiles();
username = null;
avatarUrl = null;
isTTS = false;
return this;
} | [
"public",
"WebhookMessageBuilder",
"reset",
"(",
")",
"{",
"content",
".",
"setLength",
"(",
"0",
")",
";",
"embeds",
".",
"clear",
"(",
")",
";",
"resetFiles",
"(",
")",
";",
"username",
"=",
"null",
";",
"avatarUrl",
"=",
"null",
";",
"isTTS",
"=",
... | Resets this builder to default settings.
@return The current WebhookMessageBuilder for chaining convenience | [
"Resets",
"this",
"builder",
"to",
"default",
"settings",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java#L101-L110 |
31,041 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java | WebhookMessageBuilder.append | public WebhookMessageBuilder append(String content)
{
Checks.notNull(content, "Content");
Checks.check(this.content.length() + content.length() <= 2000,
"Content may not exceed 2000 characters!");
this.content.append(content);
return this;
} | java | public WebhookMessageBuilder append(String content)
{
Checks.notNull(content, "Content");
Checks.check(this.content.length() + content.length() <= 2000,
"Content may not exceed 2000 characters!");
this.content.append(content);
return this;
} | [
"public",
"WebhookMessageBuilder",
"append",
"(",
"String",
"content",
")",
"{",
"Checks",
".",
"notNull",
"(",
"content",
",",
"\"Content\"",
")",
";",
"Checks",
".",
"check",
"(",
"this",
".",
"content",
".",
"length",
"(",
")",
"+",
"content",
".",
"l... | Appends to the currently set content of the resulting message.
@param content
The content to append
@throws java.lang.IllegalArgumentException
If the provided content is {@code null} or
the resulting content would exceed {@code 2000} characters in length
@return The current WebhookMessageBuilder for chaining convenience | [
"Appends",
"to",
"the",
"currently",
"set",
"content",
"of",
"the",
"resulting",
"message",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java#L228-L235 |
31,042 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/managers/AccountManager.java | AccountManager.setName | @CheckReturnValue
public AccountManager setName(String name, String currentPassword)
{
Checks.notBlank(name, "Name");
Checks.check(name.length() >= 2 && name.length() <= 32, "Name must be between 2-32 characters long");
this.currentPassword = currentPassword;
this.name = name;
set |= NAME;
return this;
} | java | @CheckReturnValue
public AccountManager setName(String name, String currentPassword)
{
Checks.notBlank(name, "Name");
Checks.check(name.length() >= 2 && name.length() <= 32, "Name must be between 2-32 characters long");
this.currentPassword = currentPassword;
this.name = name;
set |= NAME;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"AccountManager",
"setName",
"(",
"String",
"name",
",",
"String",
"currentPassword",
")",
"{",
"Checks",
".",
"notBlank",
"(",
"name",
",",
"\"Name\"",
")",
";",
"Checks",
".",
"check",
"(",
"name",
".",
"length",
"(",
"... | Sets the username for the currently logged in account
@param name
The new username
@param currentPassword
The current password for the represented account,
this is only required for {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}
@throws IllegalArgumentException
If this is action is performed on an account with the type {@link net.dv8tion.jda.core.AccountType#CLIENT CLIENT}
and the provided password is {@code null} or empty
<br>If the provided name is:
<ul>
<li>Equal to {@code null}</li>
<li>Less than 2 or more than 32 characters in length</li>
</ul>
@return AccountManager for chaining convenience | [
"Sets",
"the",
"username",
"for",
"the",
"currently",
"logged",
"in",
"account"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/managers/AccountManager.java#L206-L215 |
31,043 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/managers/AccountManager.java | AccountManager.setAvatar | @CheckReturnValue
public AccountManager setAvatar(Icon avatar, String currentPassword)
{
this.currentPassword = currentPassword;
this.avatar = avatar;
set |= AVATAR;
return this;
} | java | @CheckReturnValue
public AccountManager setAvatar(Icon avatar, String currentPassword)
{
this.currentPassword = currentPassword;
this.avatar = avatar;
set |= AVATAR;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"AccountManager",
"setAvatar",
"(",
"Icon",
"avatar",
",",
"String",
"currentPassword",
")",
"{",
"this",
".",
"currentPassword",
"=",
"currentPassword",
";",
"this",
".",
"avatar",
"=",
"avatar",
";",
"set",
"|=",
"AVATAR",
... | Sets the avatar for the currently logged in account
@param avatar
An {@link net.dv8tion.jda.core.entities.Icon Icon} instance representing
the new Avatar for the current account, {@code null} to reset the avatar to the default avatar.
@param currentPassword
The current password for the represented account,
this is only required for {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}
@throws IllegalArgumentException
If the provided {@code currentPassword} is {@code null} or empty and the currently
logged in account is from {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}
@return AccountManager for chaining convenience | [
"Sets",
"the",
"avatar",
"for",
"the",
"currently",
"logged",
"in",
"account"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/managers/AccountManager.java#L251-L258 |
31,044 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/managers/AccountManager.java | AccountManager.setEmail | @CheckReturnValue
public AccountManager setEmail(String email, String currentPassword)
{
Checks.notNull(email, "email");
this.currentPassword = currentPassword;
this.email = email;
set |= EMAIL;
return this;
} | java | @CheckReturnValue
public AccountManager setEmail(String email, String currentPassword)
{
Checks.notNull(email, "email");
this.currentPassword = currentPassword;
this.email = email;
set |= EMAIL;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"AccountManager",
"setEmail",
"(",
"String",
"email",
",",
"String",
"currentPassword",
")",
"{",
"Checks",
".",
"notNull",
"(",
"email",
",",
"\"email\"",
")",
";",
"this",
".",
"currentPassword",
"=",
"currentPassword",
";",
... | Sets the email for the currently logged in client account.
@param email
The new email
@param currentPassword
The <b>valid</b> current password for the represented account
@throws net.dv8tion.jda.core.exceptions.AccountTypeException
If the currently logged in account is not from {@link net.dv8tion.jda.core.AccountType#CLIENT}
@throws IllegalArgumentException
<ul>
<li>If the provided {@code currentPassword} or the provided {@code email} is {@code null} or empty
<li>If the provided {@code email} is not valid.</li>
</ul>
@return AccountManager for chaining convenience | [
"Sets",
"the",
"email",
"for",
"the",
"currently",
"logged",
"in",
"client",
"account",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/managers/AccountManager.java#L278-L286 |
31,045 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/order/OrderAction.java | OrderAction.swapPosition | @SuppressWarnings("unchecked")
public M swapPosition(int swapPosition)
{
Checks.notNegative(swapPosition, "Provided swapPosition");
Checks.check(swapPosition < orderList.size(), "Provided swapPosition is too big and is out of bounds. swapPosition: "
+ swapPosition);
T selectedItem = orderList.get(selectedPosition);
T swapItem = orderList.get(swapPosition);
orderList.set(swapPosition, selectedItem);
orderList.set(selectedPosition, swapItem);
return (M) this;
} | java | @SuppressWarnings("unchecked")
public M swapPosition(int swapPosition)
{
Checks.notNegative(swapPosition, "Provided swapPosition");
Checks.check(swapPosition < orderList.size(), "Provided swapPosition is too big and is out of bounds. swapPosition: "
+ swapPosition);
T selectedItem = orderList.get(selectedPosition);
T swapItem = orderList.get(swapPosition);
orderList.set(swapPosition, selectedItem);
orderList.set(selectedPosition, swapItem);
return (M) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"M",
"swapPosition",
"(",
"int",
"swapPosition",
")",
"{",
"Checks",
".",
"notNegative",
"(",
"swapPosition",
",",
"\"Provided swapPosition\"",
")",
";",
"Checks",
".",
"check",
"(",
"swapPosition",
"... | Swaps the currently selected entity with the entity located
at the specified position. No other entities are affected by this operation.
@param swapPosition
0 based index of target position
@throws java.lang.IllegalStateException
If no entity has been selected yet
@throws java.lang.IllegalArgumentException
If the specified position is out-of-bounds
@return The current OrderAction sub-implementation instance | [
"Swaps",
"the",
"currently",
"selected",
"entity",
"with",
"the",
"entity",
"located",
"at",
"the",
"specified",
"position",
".",
"No",
"other",
"entities",
"are",
"affected",
"by",
"this",
"operation",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/order/OrderAction.java#L310-L323 |
31,046 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/order/OrderAction.java | OrderAction.swapPosition | @SuppressWarnings("unchecked")
public M swapPosition(T swapEntity)
{
Checks.notNull(swapEntity, "Provided swapEntity");
validateInput(swapEntity);
return swapPosition(orderList.indexOf(swapEntity));
} | java | @SuppressWarnings("unchecked")
public M swapPosition(T swapEntity)
{
Checks.notNull(swapEntity, "Provided swapEntity");
validateInput(swapEntity);
return swapPosition(orderList.indexOf(swapEntity));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"M",
"swapPosition",
"(",
"T",
"swapEntity",
")",
"{",
"Checks",
".",
"notNull",
"(",
"swapEntity",
",",
"\"Provided swapEntity\"",
")",
";",
"validateInput",
"(",
"swapEntity",
")",
";",
"return",
... | Swaps the currently selected entity with the specified entity.
No other entities are affected by this operation.
@param swapEntity
Target entity to switch positions with
@throws java.lang.IllegalStateException
If no entity has been selected yet
@throws java.lang.IllegalArgumentException
If the specified position is out-of-bounds,
or if the target entity is {@code null} or not
available in this order action implementation
@return The current OrderAction sub-implementation instance
@see #swapPosition(int) | [
"Swaps",
"the",
"currently",
"selected",
"entity",
"with",
"the",
"specified",
"entity",
".",
"No",
"other",
"entities",
"are",
"affected",
"by",
"this",
"operation",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/order/OrderAction.java#L343-L350 |
31,047 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/MessageBuilder.java | MessageBuilder.replace | public MessageBuilder replace(String target, String replacement)
{
int index = builder.indexOf(target);
while (index != -1)
{
builder.replace(index, index + target.length(), replacement);
index = builder.indexOf(target, index + replacement.length());
}
return this;
} | java | public MessageBuilder replace(String target, String replacement)
{
int index = builder.indexOf(target);
while (index != -1)
{
builder.replace(index, index + target.length(), replacement);
index = builder.indexOf(target, index + replacement.length());
}
return this;
} | [
"public",
"MessageBuilder",
"replace",
"(",
"String",
"target",
",",
"String",
"replacement",
")",
"{",
"int",
"index",
"=",
"builder",
".",
"indexOf",
"(",
"target",
")",
";",
"while",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"builder",
".",
"replace",
... | Replaces each substring that matches the target string with the specified replacement string.
The replacement proceeds from the beginning of the string to the end, for example, replacing
"aa" with "b" in the message "aaa" will result in "ba" rather than "ab".
@param target
the sequence of char values to be replaced
@param replacement
the replacement sequence of char values
@return The MessageBuilder instance. Useful for chaining. | [
"Replaces",
"each",
"substring",
"that",
"matches",
"the",
"target",
"string",
"with",
"the",
"specified",
"replacement",
"string",
".",
"The",
"replacement",
"proceeds",
"from",
"the",
"beginning",
"of",
"the",
"string",
"to",
"the",
"end",
"for",
"example",
... | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L389-L398 |
31,048 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/MessageBuilder.java | MessageBuilder.replaceFirst | public MessageBuilder replaceFirst(String target, String replacement)
{
int index = builder.indexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | java | public MessageBuilder replaceFirst(String target, String replacement)
{
int index = builder.indexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | [
"public",
"MessageBuilder",
"replaceFirst",
"(",
"String",
"target",
",",
"String",
"replacement",
")",
"{",
"int",
"index",
"=",
"builder",
".",
"indexOf",
"(",
"target",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"builder",
".",
"replace",... | Replaces the first substring that matches the target string with the specified replacement string.
@param target
the sequence of char values to be replaced
@param replacement
the replacement sequence of char values
@return The MessageBuilder instance. Useful for chaining. | [
"Replaces",
"the",
"first",
"substring",
"that",
"matches",
"the",
"target",
"string",
"with",
"the",
"specified",
"replacement",
"string",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L410-L418 |
31,049 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/MessageBuilder.java | MessageBuilder.replaceLast | public MessageBuilder replaceLast(String target, String replacement)
{
int index = builder.lastIndexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | java | public MessageBuilder replaceLast(String target, String replacement)
{
int index = builder.lastIndexOf(target);
if (index != -1)
{
builder.replace(index, index + target.length(), replacement);
}
return this;
} | [
"public",
"MessageBuilder",
"replaceLast",
"(",
"String",
"target",
",",
"String",
"replacement",
")",
"{",
"int",
"index",
"=",
"builder",
".",
"lastIndexOf",
"(",
"target",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"builder",
".",
"replac... | Replaces the last substring that matches the target string with the specified replacement string.
@param target
the sequence of char values to be replaced
@param replacement
the replacement sequence of char values
@return The MessageBuilder instance. Useful for chaining. | [
"Replaces",
"the",
"last",
"substring",
"that",
"matches",
"the",
"target",
"string",
"with",
"the",
"specified",
"replacement",
"string",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L430-L438 |
31,050 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/MessageBuilder.java | MessageBuilder.indexOf | public int indexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromIndex > length())
throw new IndexOutOfBoundsException("fromIndex > length()");
if (fromIndex > endIndex)
throw new IndexOutOfBoundsException("fromIndex > endIndex");
if (endIndex >= builder.length())
{
endIndex = builder.length() - 1;
}
int targetCount = target.length();
if (targetCount == 0)
{
return fromIndex;
}
char strFirstChar = target.charAt(0);
int max = endIndex + targetCount - 1;
lastCharSearch:
for (int i = fromIndex; i <= max; i++)
{
if (builder.charAt(i) == strFirstChar)
{
for (int j = 1; j < targetCount; j++)
{
if (builder.charAt(i + j) != target.charAt(j))
{
continue lastCharSearch;
}
}
return i;
}
}
return -1;
} | java | public int indexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromIndex > length())
throw new IndexOutOfBoundsException("fromIndex > length()");
if (fromIndex > endIndex)
throw new IndexOutOfBoundsException("fromIndex > endIndex");
if (endIndex >= builder.length())
{
endIndex = builder.length() - 1;
}
int targetCount = target.length();
if (targetCount == 0)
{
return fromIndex;
}
char strFirstChar = target.charAt(0);
int max = endIndex + targetCount - 1;
lastCharSearch:
for (int i = fromIndex; i <= max; i++)
{
if (builder.charAt(i) == strFirstChar)
{
for (int j = 1; j < targetCount; j++)
{
if (builder.charAt(i + j) != target.charAt(j))
{
continue lastCharSearch;
}
}
return i;
}
}
return -1;
} | [
"public",
"int",
"indexOf",
"(",
"CharSequence",
"target",
",",
"int",
"fromIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"fromIndex",
"<",
"0",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"index out of range: \"",
"+",
"fromIndex",
")",
";... | Returns the index within this string of the first occurrence of the
specified substring between the specified indices.
<p>If no such value of {@code target} exists, then {@code -1} is returned.
@param target
the substring to search for.
@param fromIndex
the index from which to start the search.
@param endIndex
the index at which to end the search.
@throws java.lang.IndexOutOfBoundsException
<ul>
<li>If the {@code fromIndex} is outside of the range of {@code 0} to {@link #length()}</li>
<li>If the {@code endIndex} is outside of the range of {@code 0} to {@link #length()}</li>
<li>If the {@code fromIndex} is greater than {@code endIndex}</li>
</ul>
@return the index of the first occurrence of the specified substring between
the specified indices or {@code -1} if there is no such occurrence. | [
"Returns",
"the",
"index",
"within",
"this",
"string",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"specified",
"substring",
"between",
"the",
"specified",
"indices",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L652-L693 |
31,051 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/MessageBuilder.java | MessageBuilder.lastIndexOf | public int lastIndexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromIndex > length())
throw new IndexOutOfBoundsException("fromIndex > length()");
if (fromIndex > endIndex)
throw new IndexOutOfBoundsException("fromIndex > endIndex");
if (endIndex >= builder.length())
{
endIndex = builder.length() - 1;
}
int targetCount = target.length();
if (targetCount == 0)
{
return endIndex;
}
int rightIndex = endIndex - targetCount;
if (fromIndex > rightIndex)
{
fromIndex = rightIndex;
}
int strLastIndex = targetCount - 1;
char strLastChar = target.charAt(strLastIndex);
int min = fromIndex + targetCount - 1;
lastCharSearch:
for (int i = endIndex; i >= min; i--)
{
if (builder.charAt(i) == strLastChar)
{
for (int j = strLastIndex - 1, k = 1; j >= 0; j--, k++)
{
if (builder.charAt(i - k) != target.charAt(j))
{
continue lastCharSearch;
}
}
return i - target.length() + 1;
}
}
return -1;
} | java | public int lastIndexOf(CharSequence target, int fromIndex, int endIndex)
{
if (fromIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
if (endIndex < 0)
throw new IndexOutOfBoundsException("index out of range: " + endIndex);
if (fromIndex > length())
throw new IndexOutOfBoundsException("fromIndex > length()");
if (fromIndex > endIndex)
throw new IndexOutOfBoundsException("fromIndex > endIndex");
if (endIndex >= builder.length())
{
endIndex = builder.length() - 1;
}
int targetCount = target.length();
if (targetCount == 0)
{
return endIndex;
}
int rightIndex = endIndex - targetCount;
if (fromIndex > rightIndex)
{
fromIndex = rightIndex;
}
int strLastIndex = targetCount - 1;
char strLastChar = target.charAt(strLastIndex);
int min = fromIndex + targetCount - 1;
lastCharSearch:
for (int i = endIndex; i >= min; i--)
{
if (builder.charAt(i) == strLastChar)
{
for (int j = strLastIndex - 1, k = 1; j >= 0; j--, k++)
{
if (builder.charAt(i - k) != target.charAt(j))
{
continue lastCharSearch;
}
}
return i - target.length() + 1;
}
}
return -1;
} | [
"public",
"int",
"lastIndexOf",
"(",
"CharSequence",
"target",
",",
"int",
"fromIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"fromIndex",
"<",
"0",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"index out of range: \"",
"+",
"fromIndex",
")",
... | Returns the index within this string of the last occurrence of the
specified substring between the specified indices.
If no such value of {@code target} exists, then {@code -1} is returned.
@param target
the substring to search for.
@param fromIndex
the index from which to start the search.
@param endIndex
the index at which to end the search.
@throws java.lang.IndexOutOfBoundsException
<ul>
<li>If the {@code fromIndex} is outside of the range of {@code 0} to {@link #length()}</li>
<li>If the {@code endIndex} is outside of the range of {@code 0} to {@link #length()}</li>
<li>If the {@code fromIndex} is greater than {@code endIndex}</li>
</ul>
@return the index of the last occurrence of the specified substring between
the specified indices or {@code -1} if there is no such occurrence. | [
"Returns",
"the",
"index",
"within",
"this",
"string",
"of",
"the",
"last",
"occurrence",
"of",
"the",
"specified",
"substring",
"between",
"the",
"specified",
"indices",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/MessageBuilder.java#L718-L768 |
31,052 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setName | @CheckReturnValue
public ChannelAction setName(String name)
{
Checks.notNull(name, "Channel name");
if (name.length() < 1 || name.length() > 100)
throw new IllegalArgumentException("Provided channel name must be 1 to 100 characters in length");
this.name = name;
return this;
} | java | @CheckReturnValue
public ChannelAction setName(String name)
{
Checks.notNull(name, "Channel name");
if (name.length() < 1 || name.length() > 100)
throw new IllegalArgumentException("Provided channel name must be 1 to 100 characters in length");
this.name = name;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setName",
"(",
"String",
"name",
")",
"{",
"Checks",
".",
"notNull",
"(",
"name",
",",
"\"Channel name\"",
")",
";",
"if",
"(",
"name",
".",
"length",
"(",
")",
"<",
"1",
"||",
"name",
".",
"length",
... | Sets the name for the new Channel
@param name
The not-null name for the new Channel (1-100 chars long)
@throws java.lang.IllegalArgumentException
If the provided name is null or not between 1-100 chars long
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"name",
"for",
"the",
"new",
"Channel"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L98-L107 |
31,053 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setTopic | @CheckReturnValue
public ChannelAction setTopic(String topic)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set the topic for a TextChannel!");
if (topic != null && topic.length() > 1024)
throw new IllegalArgumentException("Channel Topic must not be greater than 1024 in length!");
this.topic = topic;
return this;
} | java | @CheckReturnValue
public ChannelAction setTopic(String topic)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set the topic for a TextChannel!");
if (topic != null && topic.length() > 1024)
throw new IllegalArgumentException("Channel Topic must not be greater than 1024 in length!");
this.topic = topic;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setTopic",
"(",
"String",
"topic",
")",
"{",
"if",
"(",
"type",
"!=",
"ChannelType",
".",
"TEXT",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Can only set the topic for a TextChannel!\"",
")",
";",... | Sets the topic for the new TextChannel
@param topic
The topic for the new Channel (max 1024 chars)
@throws UnsupportedOperationException
If this ChannelAction is not for a TextChannel
@throws IllegalArgumentException
If the provided topic is longer than 1024 chars
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"topic",
"for",
"the",
"new",
"TextChannel"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L171-L180 |
31,054 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setNSFW | @CheckReturnValue
public ChannelAction setNSFW(boolean nsfw)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set nsfw for a TextChannel!");
this.nsfw = nsfw;
return this;
} | java | @CheckReturnValue
public ChannelAction setNSFW(boolean nsfw)
{
if (type != ChannelType.TEXT)
throw new UnsupportedOperationException("Can only set nsfw for a TextChannel!");
this.nsfw = nsfw;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setNSFW",
"(",
"boolean",
"nsfw",
")",
"{",
"if",
"(",
"type",
"!=",
"ChannelType",
".",
"TEXT",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Can only set nsfw for a TextChannel!\"",
")",
";",
"th... | Sets the NSFW flag for the new TextChannel
@param nsfw
The NSFW flag for the new Channel
@throws UnsupportedOperationException
If this ChannelAction is not for a TextChannel
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"NSFW",
"flag",
"for",
"the",
"new",
"TextChannel"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L193-L200 |
31,055 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setSlowmode | @CheckReturnValue
public ChannelAction setSlowmode(int slowmode)
{
Checks.check(slowmode <= 120 && slowmode >= 0, "Slowmode must be between 0 and 120 (seconds)!");
this.slowmode = slowmode;
return this;
} | java | @CheckReturnValue
public ChannelAction setSlowmode(int slowmode)
{
Checks.check(slowmode <= 120 && slowmode >= 0, "Slowmode must be between 0 and 120 (seconds)!");
this.slowmode = slowmode;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setSlowmode",
"(",
"int",
"slowmode",
")",
"{",
"Checks",
".",
"check",
"(",
"slowmode",
"<=",
"120",
"&&",
"slowmode",
">=",
"0",
",",
"\"Slowmode must be between 0 and 120 (seconds)!\"",
")",
";",
"this",
".",... | Sets the slowmode value, which limits the amount of time that individual users must wait
between sending messages in the new TextChannel. This is measured in seconds.
<p>Note that only {@link net.dv8tion.jda.core.AccountType#CLIENT CLIENT} type accounts are
affected by slowmode, and that {@link net.dv8tion.jda.core.AccountType#BOT BOT} accounts
are immune to the restrictions.
<br>Having {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
{@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
grants immunity to slowmode.
@param slowmode
The number of seconds required to wait between sending messages in the channel.
@throws IllegalArgumentException
If the {@code slowmode} is greater than 120, or less than 0
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"slowmode",
"value",
"which",
"limits",
"the",
"amount",
"of",
"time",
"that",
"individual",
"users",
"must",
"wait",
"between",
"sending",
"messages",
"in",
"the",
"new",
"TextChannel",
".",
"This",
"is",
"measured",
"in",
"seconds",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L221-L227 |
31,056 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setBitrate | @CheckReturnValue
public ChannelAction setBitrate(Integer bitrate)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the bitrate for a VoiceChannel!");
if (bitrate != null)
{
int maxBitrate = guild.getFeatures().contains("VIP_REGIONS") ? 128000 : 96000;
if (bitrate < 8000)
throw new IllegalArgumentException("Bitrate must be greater than 8000.");
else if (bitrate > maxBitrate)
throw new IllegalArgumentException("Bitrate must be less than " + maxBitrate);
}
this.bitrate = bitrate;
return this;
} | java | @CheckReturnValue
public ChannelAction setBitrate(Integer bitrate)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the bitrate for a VoiceChannel!");
if (bitrate != null)
{
int maxBitrate = guild.getFeatures().contains("VIP_REGIONS") ? 128000 : 96000;
if (bitrate < 8000)
throw new IllegalArgumentException("Bitrate must be greater than 8000.");
else if (bitrate > maxBitrate)
throw new IllegalArgumentException("Bitrate must be less than " + maxBitrate);
}
this.bitrate = bitrate;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setBitrate",
"(",
"Integer",
"bitrate",
")",
"{",
"if",
"(",
"type",
"!=",
"ChannelType",
".",
"VOICE",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Can only set the bitrate for a VoiceChannel!\"",
")... | Sets the bitrate for the new VoiceChannel
@param bitrate
The bitrate for the new Channel (min {@code 8000}; max {@code 96000}/{@code 128000}
(for {@link net.dv8tion.jda.core.entities.Guild#getFeatures() VIP Guilds})) or null to use default ({@code 64000})
@throws UnsupportedOperationException
If this ChannelAction is not for a VoiceChannel
@throws IllegalArgumentException
If the provided bitrate is less than 8000 or greater than 128000
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"bitrate",
"for",
"the",
"new",
"VoiceChannel"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L340-L356 |
31,057 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java | ChannelAction.setUserlimit | @CheckReturnValue
public ChannelAction setUserlimit(Integer userlimit)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the userlimit for a VoiceChannel!");
if (userlimit != null && (userlimit < 0 || userlimit > 99))
throw new IllegalArgumentException("Userlimit must be between 0-99!");
this.userlimit = userlimit;
return this;
} | java | @CheckReturnValue
public ChannelAction setUserlimit(Integer userlimit)
{
if (type != ChannelType.VOICE)
throw new UnsupportedOperationException("Can only set the userlimit for a VoiceChannel!");
if (userlimit != null && (userlimit < 0 || userlimit > 99))
throw new IllegalArgumentException("Userlimit must be between 0-99!");
this.userlimit = userlimit;
return this;
} | [
"@",
"CheckReturnValue",
"public",
"ChannelAction",
"setUserlimit",
"(",
"Integer",
"userlimit",
")",
"{",
"if",
"(",
"type",
"!=",
"ChannelType",
".",
"VOICE",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Can only set the userlimit for a VoiceChannel!\""... | Sets the userlimit for the new VoiceChannel
@param userlimit
The userlimit for the new VoiceChannel or {@code null}/{@code 0} to use no limit,
@throws UnsupportedOperationException
If this ChannelAction is not for a VoiceChannel
@throws IllegalArgumentException
If the provided userlimit is negative or above {@code 99}
@return The current ChannelAction, for chaining convenience | [
"Sets",
"the",
"userlimit",
"for",
"the",
"new",
"VoiceChannel"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/ChannelAction.java#L371-L380 |
31,058 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/WebSocketSendingThread.java | WebSocketSendingThread.send | private boolean send(String request)
{
needRateLimit = !client.send(request, false);
attemptedToSend = true;
return !needRateLimit;
} | java | private boolean send(String request)
{
needRateLimit = !client.send(request, false);
attemptedToSend = true;
return !needRateLimit;
} | [
"private",
"boolean",
"send",
"(",
"String",
"request",
")",
"{",
"needRateLimit",
"=",
"!",
"client",
".",
"send",
"(",
"request",
",",
"false",
")",
";",
"attemptedToSend",
"=",
"true",
";",
"return",
"!",
"needRateLimit",
";",
"}"
] | returns true if send was successful | [
"returns",
"true",
"if",
"send",
"was",
"successful"
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/WebSocketSendingThread.java#L202-L207 |
31,059 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/utils/IOUtil.java | IOUtil.readFully | public static byte[] readFully(File file) throws IOException
{
Checks.notNull(file, "File");
Checks.check(file.exists(), "Provided file does not exist!");
try (InputStream is = new FileInputStream(file))
{
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE)
{
throw new IOException("Cannot read the file into memory completely due to it being too large!");
// File is too large
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
{
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length)
{
throw new IOException("Could not completely read file " + file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
}
} | java | public static byte[] readFully(File file) throws IOException
{
Checks.notNull(file, "File");
Checks.check(file.exists(), "Provided file does not exist!");
try (InputStream is = new FileInputStream(file))
{
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE)
{
throw new IOException("Cannot read the file into memory completely due to it being too large!");
// File is too large
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
{
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length)
{
throw new IOException("Could not completely read file " + file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
}
} | [
"public",
"static",
"byte",
"[",
"]",
"readFully",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"Checks",
".",
"notNull",
"(",
"file",
",",
"\"File\"",
")",
";",
"Checks",
".",
"check",
"(",
"file",
".",
"exists",
"(",
")",
",",
"\"Provided ... | Used as an alternate to Java's nio Files.readAllBytes.
<p>This customized version for File is provide (instead of just using {@link #readFully(java.io.InputStream)} with a FileInputStream)
because with a File we can determine the total size of the array and do not need to have a buffer.
This results in a memory footprint that is half the size of {@link #readFully(java.io.InputStream)}
<p>Code provided from <a href="http://stackoverflow.com/a/6276139">Stackoverflow</a>
@param file
The file from which we should retrieve the bytes from
@throws java.io.IOException
Thrown if there is a problem while reading the file.
@return A byte[] containing all of the file's data | [
"Used",
"as",
"an",
"alternate",
"to",
"Java",
"s",
"nio",
"Files",
".",
"readAllBytes",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/utils/IOUtil.java#L41-L82 |
31,060 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/utils/WidgetUtil.java | WidgetUtil.getPremadeWidgetHtml | public static String getPremadeWidgetHtml(Guild guild, WidgetTheme theme, int width, int height)
{
Checks.notNull(guild, "Guild");
return getPremadeWidgetHtml(guild.getId(), theme, width, height);
} | java | public static String getPremadeWidgetHtml(Guild guild, WidgetTheme theme, int width, int height)
{
Checks.notNull(guild, "Guild");
return getPremadeWidgetHtml(guild.getId(), theme, width, height);
} | [
"public",
"static",
"String",
"getPremadeWidgetHtml",
"(",
"Guild",
"guild",
",",
"WidgetTheme",
"theme",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"Checks",
".",
"notNull",
"(",
"guild",
",",
"\"Guild\"",
")",
";",
"return",
"getPremadeWidgetHtml",... | Gets the pre-made HTML Widget for the specified guild using the specified
settings. The widget will only display correctly if the guild in question
has the Widget enabled.
@param guild
the guild
@param theme
the theme, light or dark
@param width
the width of the widget
@param height
the height of the widget
@return a String containing the pre-made widget with the supplied settings | [
"Gets",
"the",
"pre",
"-",
"made",
"HTML",
"Widget",
"for",
"the",
"specified",
"guild",
"using",
"the",
"specified",
"settings",
".",
"The",
"widget",
"will",
"only",
"display",
"correctly",
"if",
"the",
"guild",
"in",
"question",
"has",
"the",
"Widget",
... | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/utils/WidgetUtil.java#L106-L110 |
31,061 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/utils/WidgetUtil.java | WidgetUtil.getPremadeWidgetHtml | public static String getPremadeWidgetHtml(String guildId, WidgetTheme theme, int width, int height)
{
Checks.notNull(guildId, "GuildId");
Checks.notNull(theme, "WidgetTheme");
Checks.notNegative(width, "Width");
Checks.notNegative(height, "Height");
return String.format(WIDGET_HTML, guildId, theme.name().toLowerCase(), width, height);
} | java | public static String getPremadeWidgetHtml(String guildId, WidgetTheme theme, int width, int height)
{
Checks.notNull(guildId, "GuildId");
Checks.notNull(theme, "WidgetTheme");
Checks.notNegative(width, "Width");
Checks.notNegative(height, "Height");
return String.format(WIDGET_HTML, guildId, theme.name().toLowerCase(), width, height);
} | [
"public",
"static",
"String",
"getPremadeWidgetHtml",
"(",
"String",
"guildId",
",",
"WidgetTheme",
"theme",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"Checks",
".",
"notNull",
"(",
"guildId",
",",
"\"GuildId\"",
")",
";",
"Checks",
".",
"notNull"... | Gets the pre-made HTML Widget for the specified guild using the specified
settings. The widget will only display correctly if the guild in question
has the Widget enabled. Additionally, this method can be used independently
of being on the guild in question.
@param guildId
the guild ID
@param theme
the theme, light or dark
@param width
the width of the widget
@param height
the height of the widget
@return a String containing the pre-made widget with the supplied settings | [
"Gets",
"the",
"pre",
"-",
"made",
"HTML",
"Widget",
"for",
"the",
"specified",
"guild",
"using",
"the",
"specified",
"settings",
".",
"The",
"widget",
"will",
"only",
"display",
"correctly",
"if",
"the",
"guild",
"in",
"question",
"has",
"the",
"Widget",
... | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/utils/WidgetUtil.java#L129-L136 |
31,062 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/utils/MiscUtil.java | MiscUtil.appendTo | public static void appendTo(Formatter formatter, int width, int precision, boolean leftJustified, String out)
{
try
{
Appendable appendable = formatter.out();
if (precision > -1 && out.length() > precision)
{
appendable.append(Helpers.truncate(out, precision));
return;
}
if (leftJustified)
appendable.append(Helpers.rightPad(out, width));
else
appendable.append(Helpers.leftPad(out, width));
}
catch (IOException e)
{
throw new AssertionError(e);
}
} | java | public static void appendTo(Formatter formatter, int width, int precision, boolean leftJustified, String out)
{
try
{
Appendable appendable = formatter.out();
if (precision > -1 && out.length() > precision)
{
appendable.append(Helpers.truncate(out, precision));
return;
}
if (leftJustified)
appendable.append(Helpers.rightPad(out, width));
else
appendable.append(Helpers.leftPad(out, width));
}
catch (IOException e)
{
throw new AssertionError(e);
}
} | [
"public",
"static",
"void",
"appendTo",
"(",
"Formatter",
"formatter",
",",
"int",
"width",
",",
"int",
"precision",
",",
"boolean",
"leftJustified",
",",
"String",
"out",
")",
"{",
"try",
"{",
"Appendable",
"appendable",
"=",
"formatter",
".",
"out",
"(",
... | Can be used to append a String to a formatter.
@param formatter
The {@link java.util.Formatter Formatter}
@param width
Minimum width to meet, filled with space if needed
@param precision
Maximum amount of characters to append
@param leftJustified
Whether or not to left-justify the value
@param out
The String to append | [
"Can",
"be",
"used",
"to",
"append",
"a",
"String",
"to",
"a",
"formatter",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/utils/MiscUtil.java#L267-L287 |
31,063 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/webhook/WebhookClient.java | WebhookClient.send | public RequestFuture<?> send(String content)
{
Checks.notBlank(content, "Content");
Checks.check(content.length() <= 2000, "Content may not exceed 2000 characters!");
return execute(newBody(new JSONObject().put("content", content).toString()));
} | java | public RequestFuture<?> send(String content)
{
Checks.notBlank(content, "Content");
Checks.check(content.length() <= 2000, "Content may not exceed 2000 characters!");
return execute(newBody(new JSONObject().put("content", content).toString()));
} | [
"public",
"RequestFuture",
"<",
"?",
">",
"send",
"(",
"String",
"content",
")",
"{",
"Checks",
".",
"notBlank",
"(",
"content",
",",
"\"Content\"",
")",
";",
"Checks",
".",
"check",
"(",
"content",
".",
"length",
"(",
")",
"<=",
"2000",
",",
"\"Conten... | Sends the provided text message to this webhook.
@param content
The text message to send
@throws java.lang.IllegalArgumentException
If any of the provided message is {@code null}, blank or exceeds 2000 characters in length
@throws java.util.concurrent.RejectedExecutionException
If this client was closed
@return {@link net.dv8tion.jda.core.requests.RequestFuture RequestFuture} representing the execution task,
this will be completed once the message was sent. | [
"Sends",
"the",
"provided",
"text",
"message",
"to",
"this",
"webhook",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/webhook/WebhookClient.java#L334-L339 |
31,064 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/RoleAction.java | RoleAction.setColor | @CheckReturnValue
public RoleAction setColor(Color color)
{
return this.setColor(color != null ? color.getRGB() : null);
} | java | @CheckReturnValue
public RoleAction setColor(Color color)
{
return this.setColor(color != null ? color.getRGB() : null);
} | [
"@",
"CheckReturnValue",
"public",
"RoleAction",
"setColor",
"(",
"Color",
"color",
")",
"{",
"return",
"this",
".",
"setColor",
"(",
"color",
"!=",
"null",
"?",
"color",
".",
"getRGB",
"(",
")",
":",
"null",
")",
";",
"}"
] | Sets the color which the new role should be displayed with.
@param color
An {@link java.awt.Color Color} for the new role, null to use default white/black
@return The current RoleAction, for chaining convenience | [
"Sets",
"the",
"color",
"which",
"the",
"new",
"role",
"should",
"be",
"displayed",
"with",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/RoleAction.java#L128-L132 |
31,065 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/entities/Game.java | Game.of | public static Game of(GameType type, String name)
{
return of(type, name, null);
} | java | public static Game of(GameType type, String name)
{
return of(type, name, null);
} | [
"public",
"static",
"Game",
"of",
"(",
"GameType",
"type",
",",
"String",
"name",
")",
"{",
"return",
"of",
"(",
"type",
",",
"name",
",",
"null",
")",
";",
"}"
] | Creates a new Game instance with the specified name and url.
@param type
The {@link net.dv8tion.jda.core.entities.Game.GameType GameType} to use
@param name
The not-null name of the newly created game
@throws IllegalArgumentException
If the specified name is null or empty
@return A valid Game instance with the provided name and url | [
"Creates",
"a",
"new",
"Game",
"instance",
"with",
"the",
"specified",
"name",
"and",
"url",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/entities/Game.java#L254-L257 |
31,066 | DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/restaction/pagination/PaginationAction.java | PaginationAction.limit | @SuppressWarnings("unchecked")
public M limit(final int limit)
{
Checks.check(maxLimit == 0 || limit <= maxLimit, "Limit must not exceed %d!", maxLimit);
Checks.check(minLimit == 0 || limit >= minLimit, "Limit must be greater or equal to %d", minLimit);
synchronized (this.limit)
{
this.limit.set(limit);
}
return (M) this;
} | java | @SuppressWarnings("unchecked")
public M limit(final int limit)
{
Checks.check(maxLimit == 0 || limit <= maxLimit, "Limit must not exceed %d!", maxLimit);
Checks.check(minLimit == 0 || limit >= minLimit, "Limit must be greater or equal to %d", minLimit);
synchronized (this.limit)
{
this.limit.set(limit);
}
return (M) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"M",
"limit",
"(",
"final",
"int",
"limit",
")",
"{",
"Checks",
".",
"check",
"(",
"maxLimit",
"==",
"0",
"||",
"limit",
"<=",
"maxLimit",
",",
"\"Limit must not exceed %d!\"",
",",
"maxLimit",
")... | Sets the limit that should be used in the next RestAction completion
call.
<p>The specified limit may not be below the {@link #getMinLimit() Minimum Limit} nor above
the {@link #getMaxLimit() Maximum Limit}. Unless these limits are specifically omitted. (See documentation of methods)
<p><b>This limit represents how many entities will be retrieved per request and
<u>NOT</u> the maximum amount of entities that should be retrieved for iteration/sequencing.</b>
<br>{@code action.limit(50).complete()}
<br>is not the same as
<br>{@code action.stream().limit(50).collect(collector)}
@param limit
The limit to use
@throws java.lang.IllegalArgumentException
If the provided limit is out of range
@return The current PaginationAction implementation instance | [
"Sets",
"the",
"limit",
"that",
"should",
"be",
"used",
"in",
"the",
"next",
"RestAction",
"completion",
"call",
"."
] | 8ecbbe354d03f6bf448411bba573d0d4c268b560 | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/restaction/pagination/PaginationAction.java#L228-L239 |
31,067 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/BubbleChartRenderer.java | BubbleChartRenderer.processBubble | private float processBubble(BubbleValue bubbleValue, PointF point) {
final float rawX = computator.computeRawX(bubbleValue.getX());
final float rawY = computator.computeRawY(bubbleValue.getY());
float radius = (float) Math.sqrt(Math.abs(bubbleValue.getZ()) / Math.PI);
float rawRadius;
if (isBubbleScaledByX) {
radius *= bubbleScaleX;
rawRadius = computator.computeRawDistanceX(radius);
} else {
radius *= bubbleScaleY;
rawRadius = computator.computeRawDistanceY(radius);
}
if (rawRadius < minRawRadius + touchAdditional) {
rawRadius = minRawRadius + touchAdditional;
}
bubbleCenter.set(rawX, rawY);
if (ValueShape.SQUARE.equals(bubbleValue.getShape())) {
bubbleRect.set(rawX - rawRadius, rawY - rawRadius, rawX + rawRadius, rawY + rawRadius);
}
return rawRadius;
} | java | private float processBubble(BubbleValue bubbleValue, PointF point) {
final float rawX = computator.computeRawX(bubbleValue.getX());
final float rawY = computator.computeRawY(bubbleValue.getY());
float radius = (float) Math.sqrt(Math.abs(bubbleValue.getZ()) / Math.PI);
float rawRadius;
if (isBubbleScaledByX) {
radius *= bubbleScaleX;
rawRadius = computator.computeRawDistanceX(radius);
} else {
radius *= bubbleScaleY;
rawRadius = computator.computeRawDistanceY(radius);
}
if (rawRadius < minRawRadius + touchAdditional) {
rawRadius = minRawRadius + touchAdditional;
}
bubbleCenter.set(rawX, rawY);
if (ValueShape.SQUARE.equals(bubbleValue.getShape())) {
bubbleRect.set(rawX - rawRadius, rawY - rawRadius, rawX + rawRadius, rawY + rawRadius);
}
return rawRadius;
} | [
"private",
"float",
"processBubble",
"(",
"BubbleValue",
"bubbleValue",
",",
"PointF",
"point",
")",
"{",
"final",
"float",
"rawX",
"=",
"computator",
".",
"computeRawX",
"(",
"bubbleValue",
".",
"getX",
"(",
")",
")",
";",
"final",
"float",
"rawY",
"=",
"... | Calculate bubble radius and center x and y coordinates. Center x and x will be stored in point parameter, radius
will be returned as float value. | [
"Calculate",
"bubble",
"radius",
"and",
"center",
"x",
"and",
"y",
"coordinates",
".",
"Center",
"x",
"and",
"x",
"will",
"be",
"stored",
"in",
"point",
"parameter",
"radius",
"will",
"be",
"returned",
"as",
"float",
"value",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/BubbleChartRenderer.java#L240-L262 |
31,068 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java | FloatUtils.nextUpF | public static float nextUpF(float f) {
if (Float.isNaN(f) || f == Float.POSITIVE_INFINITY) {
return f;
} else {
f += 0.0f;
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1));
}
} | java | public static float nextUpF(float f) {
if (Float.isNaN(f) || f == Float.POSITIVE_INFINITY) {
return f;
} else {
f += 0.0f;
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1));
}
} | [
"public",
"static",
"float",
"nextUpF",
"(",
"float",
"f",
")",
"{",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"f",
")",
"||",
"f",
"==",
"Float",
".",
"POSITIVE_INFINITY",
")",
"{",
"return",
"f",
";",
"}",
"else",
"{",
"f",
"+=",
"0.0f",
";",
"ret... | Returns next bigger float value considering precision of the argument. | [
"Returns",
"next",
"bigger",
"float",
"value",
"considering",
"precision",
"of",
"the",
"argument",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java#L9-L16 |
31,069 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java | FloatUtils.nextDownF | public static float nextDownF(float f) {
if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
return f;
} else {
if (f == 0.0f) {
return -Float.MIN_VALUE;
} else {
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f > 0.0f) ? -1 : +1));
}
}
} | java | public static float nextDownF(float f) {
if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
return f;
} else {
if (f == 0.0f) {
return -Float.MIN_VALUE;
} else {
return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f > 0.0f) ? -1 : +1));
}
}
} | [
"public",
"static",
"float",
"nextDownF",
"(",
"float",
"f",
")",
"{",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"f",
")",
"||",
"f",
"==",
"Float",
".",
"NEGATIVE_INFINITY",
")",
"{",
"return",
"f",
";",
"}",
"else",
"{",
"if",
"(",
"f",
"==",
"0.0... | Returns next smaller float value considering precision of the argument. | [
"Returns",
"next",
"smaller",
"float",
"value",
"considering",
"precision",
"of",
"the",
"argument",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java#L21-L31 |
31,070 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java | FloatUtils.nextUp | public static double nextUp(double d) {
if (Double.isNaN(d) || d == Double.POSITIVE_INFINITY) {
return d;
} else {
d += 0.0;
return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0) ? +1 : -1));
}
} | java | public static double nextUp(double d) {
if (Double.isNaN(d) || d == Double.POSITIVE_INFINITY) {
return d;
} else {
d += 0.0;
return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0) ? +1 : -1));
}
} | [
"public",
"static",
"double",
"nextUp",
"(",
"double",
"d",
")",
"{",
"if",
"(",
"Double",
".",
"isNaN",
"(",
"d",
")",
"||",
"d",
"==",
"Double",
".",
"POSITIVE_INFINITY",
")",
"{",
"return",
"d",
";",
"}",
"else",
"{",
"d",
"+=",
"0.0",
";",
"r... | Returns next bigger double value considering precision of the argument. | [
"Returns",
"next",
"bigger",
"double",
"value",
"considering",
"precision",
"of",
"the",
"argument",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java#L36-L43 |
31,071 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java | FloatUtils.almostEqual | public static boolean almostEqual(float a, float b, float absoluteDiff, float relativeDiff) {
float diff = Math.abs(a - b);
if (diff <= absoluteDiff) {
return true;
}
a = Math.abs(a);
b = Math.abs(b);
float largest = (a > b) ? a : b;
if (diff <= largest * relativeDiff) {
return true;
}
return false;
} | java | public static boolean almostEqual(float a, float b, float absoluteDiff, float relativeDiff) {
float diff = Math.abs(a - b);
if (diff <= absoluteDiff) {
return true;
}
a = Math.abs(a);
b = Math.abs(b);
float largest = (a > b) ? a : b;
if (diff <= largest * relativeDiff) {
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"almostEqual",
"(",
"float",
"a",
",",
"float",
"b",
",",
"float",
"absoluteDiff",
",",
"float",
"relativeDiff",
")",
"{",
"float",
"diff",
"=",
"Math",
".",
"abs",
"(",
"a",
"-",
"b",
")",
";",
"if",
"(",
"diff",
"<=",... | Method checks if two float numbers are similar. | [
"Method",
"checks",
"if",
"two",
"float",
"numbers",
"are",
"similar",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java#L63-L78 |
31,072 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java | FloatUtils.computeAutoGeneratedAxisValues | public static void computeAutoGeneratedAxisValues(float start, float stop, int steps, AxisAutoValues outValues) {
double range = stop - start;
if (steps == 0 || range <= 0) {
outValues.values = new float[]{};
outValues.valuesNumber = 0;
return;
}
double rawInterval = range / steps;
double interval = roundToOneSignificantFigure(rawInterval);
double intervalMagnitude = Math.pow(10, (int) Math.log10(interval));
int intervalSigDigit = (int) (interval / intervalMagnitude);
if (intervalSigDigit > 5) {
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
interval = Math.floor(10 * intervalMagnitude);
}
double first = Math.ceil(start / interval) * interval;
double last = nextUp(Math.floor(stop / interval) * interval);
double intervalValue;
int valueIndex;
int valuesNum = 0;
for (intervalValue = first; intervalValue <= last; intervalValue += interval) {
++valuesNum;
}
outValues.valuesNumber = valuesNum;
if (outValues.values.length < valuesNum) {
// Ensure stops contains at least numStops elements.
outValues.values = new float[valuesNum];
}
for (intervalValue = first, valueIndex = 0; valueIndex < valuesNum; intervalValue += interval, ++valueIndex) {
outValues.values[valueIndex] = (float) intervalValue;
}
if (interval < 1) {
outValues.decimals = (int) Math.ceil(-Math.log10(interval));
} else {
outValues.decimals = 0;
}
} | java | public static void computeAutoGeneratedAxisValues(float start, float stop, int steps, AxisAutoValues outValues) {
double range = stop - start;
if (steps == 0 || range <= 0) {
outValues.values = new float[]{};
outValues.valuesNumber = 0;
return;
}
double rawInterval = range / steps;
double interval = roundToOneSignificantFigure(rawInterval);
double intervalMagnitude = Math.pow(10, (int) Math.log10(interval));
int intervalSigDigit = (int) (interval / intervalMagnitude);
if (intervalSigDigit > 5) {
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
interval = Math.floor(10 * intervalMagnitude);
}
double first = Math.ceil(start / interval) * interval;
double last = nextUp(Math.floor(stop / interval) * interval);
double intervalValue;
int valueIndex;
int valuesNum = 0;
for (intervalValue = first; intervalValue <= last; intervalValue += interval) {
++valuesNum;
}
outValues.valuesNumber = valuesNum;
if (outValues.values.length < valuesNum) {
// Ensure stops contains at least numStops elements.
outValues.values = new float[valuesNum];
}
for (intervalValue = first, valueIndex = 0; valueIndex < valuesNum; intervalValue += interval, ++valueIndex) {
outValues.values[valueIndex] = (float) intervalValue;
}
if (interval < 1) {
outValues.decimals = (int) Math.ceil(-Math.log10(interval));
} else {
outValues.decimals = 0;
}
} | [
"public",
"static",
"void",
"computeAutoGeneratedAxisValues",
"(",
"float",
"start",
",",
"float",
"stop",
",",
"int",
"steps",
",",
"AxisAutoValues",
"outValues",
")",
"{",
"double",
"range",
"=",
"stop",
"-",
"start",
";",
"if",
"(",
"steps",
"==",
"0",
... | Computes the set of axis labels to show given start and stop boundaries and an ideal number of stops between
these boundaries.
@param start The minimum extreme (e.g. the left edge) for the axis.
@param stop The maximum extreme (e.g. the right edge) for the axis.
@param steps The ideal number of stops to create. This should be based on available screen space; the more
space
there is, the more stops should be shown.
@param outValues The destination {@link AxisAutoValues} object to populate. | [
"Computes",
"the",
"set",
"of",
"axis",
"labels",
"to",
"show",
"given",
"start",
"and",
"stop",
"boundaries",
"and",
"an",
"ideal",
"number",
"of",
"stops",
"between",
"these",
"boundaries",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/util/FloatUtils.java#L152-L195 |
31,073 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.setContentRect | public void setContentRect(int width, int height, int paddingLeft, int paddingTop, int paddingRight,
int paddingBottom) {
chartWidth = width;
chartHeight = height;
maxContentRect.set(paddingLeft, paddingTop, width - paddingRight, height - paddingBottom);
contentRectMinusAxesMargins.set(maxContentRect);
contentRectMinusAllMargins.set(maxContentRect);
} | java | public void setContentRect(int width, int height, int paddingLeft, int paddingTop, int paddingRight,
int paddingBottom) {
chartWidth = width;
chartHeight = height;
maxContentRect.set(paddingLeft, paddingTop, width - paddingRight, height - paddingBottom);
contentRectMinusAxesMargins.set(maxContentRect);
contentRectMinusAllMargins.set(maxContentRect);
} | [
"public",
"void",
"setContentRect",
"(",
"int",
"width",
",",
"int",
"height",
",",
"int",
"paddingLeft",
",",
"int",
"paddingTop",
",",
"int",
"paddingRight",
",",
"int",
"paddingBottom",
")",
"{",
"chartWidth",
"=",
"width",
";",
"chartHeight",
"=",
"heigh... | Calculates available width and height. Should be called when chart dimensions change. ContentRect is relative to
chart view not the device's screen. | [
"Calculates",
"available",
"width",
"and",
"height",
".",
"Should",
"be",
"called",
"when",
"chart",
"dimensions",
"change",
".",
"ContentRect",
"is",
"relative",
"to",
"chart",
"view",
"not",
"the",
"device",
"s",
"screen",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L46-L53 |
31,074 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.constrainViewport | public void constrainViewport(float left, float top, float right, float bottom) {
if (right - left < minViewportWidth) {
// Minimum width - constrain horizontal zoom!
right = left + minViewportWidth;
if (left < maxViewport.left) {
left = maxViewport.left;
right = left + minViewportWidth;
} else if (right > maxViewport.right) {
right = maxViewport.right;
left = right - minViewportWidth;
}
}
if (top - bottom < minViewportHeight) {
// Minimum height - constrain vertical zoom!
bottom = top - minViewportHeight;
if (top > maxViewport.top) {
top = maxViewport.top;
bottom = top - minViewportHeight;
} else if (bottom < maxViewport.bottom) {
bottom = maxViewport.bottom;
top = bottom + minViewportHeight;
}
}
currentViewport.left = Math.max(maxViewport.left, left);
currentViewport.top = Math.min(maxViewport.top, top);
currentViewport.right = Math.min(maxViewport.right, right);
currentViewport.bottom = Math.max(maxViewport.bottom, bottom);
viewportChangeListener.onViewportChanged(currentViewport);
} | java | public void constrainViewport(float left, float top, float right, float bottom) {
if (right - left < minViewportWidth) {
// Minimum width - constrain horizontal zoom!
right = left + minViewportWidth;
if (left < maxViewport.left) {
left = maxViewport.left;
right = left + minViewportWidth;
} else if (right > maxViewport.right) {
right = maxViewport.right;
left = right - minViewportWidth;
}
}
if (top - bottom < minViewportHeight) {
// Minimum height - constrain vertical zoom!
bottom = top - minViewportHeight;
if (top > maxViewport.top) {
top = maxViewport.top;
bottom = top - minViewportHeight;
} else if (bottom < maxViewport.bottom) {
bottom = maxViewport.bottom;
top = bottom + minViewportHeight;
}
}
currentViewport.left = Math.max(maxViewport.left, left);
currentViewport.top = Math.min(maxViewport.top, top);
currentViewport.right = Math.min(maxViewport.right, right);
currentViewport.bottom = Math.max(maxViewport.bottom, bottom);
viewportChangeListener.onViewportChanged(currentViewport);
} | [
"public",
"void",
"constrainViewport",
"(",
"float",
"left",
",",
"float",
"top",
",",
"float",
"right",
",",
"float",
"bottom",
")",
"{",
"if",
"(",
"right",
"-",
"left",
"<",
"minViewportWidth",
")",
"{",
"// Minimum width - constrain horizontal zoom!",
"right... | Checks if new viewport doesn't exceed max available viewport. | [
"Checks",
"if",
"new",
"viewport",
"doesn",
"t",
"exceed",
"max",
"available",
"viewport",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L79-L111 |
31,075 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.computeRawX | public float computeRawX(float valueX) {
// TODO: (contentRectMinusAllMargins.width() / currentViewport.width()) can be recalculated only when viewport
// change.
final float pixelOffset = (valueX - currentViewport.left) * (contentRectMinusAllMargins.width() /
currentViewport.width());
return contentRectMinusAllMargins.left + pixelOffset;
} | java | public float computeRawX(float valueX) {
// TODO: (contentRectMinusAllMargins.width() / currentViewport.width()) can be recalculated only when viewport
// change.
final float pixelOffset = (valueX - currentViewport.left) * (contentRectMinusAllMargins.width() /
currentViewport.width());
return contentRectMinusAllMargins.left + pixelOffset;
} | [
"public",
"float",
"computeRawX",
"(",
"float",
"valueX",
")",
"{",
"// TODO: (contentRectMinusAllMargins.width() / currentViewport.width()) can be recalculated only when viewport",
"// change.",
"final",
"float",
"pixelOffset",
"=",
"(",
"valueX",
"-",
"currentViewport",
".",
... | Translates chart value into raw pixel value. Returned value is absolute pixel X coordinate. If this method
return
0 that means left most pixel of the screen. | [
"Translates",
"chart",
"value",
"into",
"raw",
"pixel",
"value",
".",
"Returned",
"value",
"is",
"absolute",
"pixel",
"X",
"coordinate",
".",
"If",
"this",
"method",
"return",
"0",
"that",
"means",
"left",
"most",
"pixel",
"of",
"the",
"screen",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L137-L143 |
31,076 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.computeRawY | public float computeRawY(float valueY) {
final float pixelOffset = (valueY - currentViewport.bottom) * (contentRectMinusAllMargins.height() /
currentViewport.height());
return contentRectMinusAllMargins.bottom - pixelOffset;
} | java | public float computeRawY(float valueY) {
final float pixelOffset = (valueY - currentViewport.bottom) * (contentRectMinusAllMargins.height() /
currentViewport.height());
return contentRectMinusAllMargins.bottom - pixelOffset;
} | [
"public",
"float",
"computeRawY",
"(",
"float",
"valueY",
")",
"{",
"final",
"float",
"pixelOffset",
"=",
"(",
"valueY",
"-",
"currentViewport",
".",
"bottom",
")",
"*",
"(",
"contentRectMinusAllMargins",
".",
"height",
"(",
")",
"/",
"currentViewport",
".",
... | Translates chart value into raw pixel value. Returned value is absolute pixel Y coordinate. If this method
return
0 that means top most pixel of the screen. | [
"Translates",
"chart",
"value",
"into",
"raw",
"pixel",
"value",
".",
"Returned",
"value",
"is",
"absolute",
"pixel",
"Y",
"coordinate",
".",
"If",
"this",
"method",
"return",
"0",
"that",
"means",
"top",
"most",
"pixel",
"of",
"the",
"screen",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L150-L154 |
31,077 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.isWithinContentRect | public boolean isWithinContentRect(float x, float y, float precision) {
if (x >= contentRectMinusAllMargins.left - precision && x <= contentRectMinusAllMargins.right + precision) {
if (y <= contentRectMinusAllMargins.bottom + precision && y >= contentRectMinusAllMargins.top -
precision) {
return true;
}
}
return false;
} | java | public boolean isWithinContentRect(float x, float y, float precision) {
if (x >= contentRectMinusAllMargins.left - precision && x <= contentRectMinusAllMargins.right + precision) {
if (y <= contentRectMinusAllMargins.bottom + precision && y >= contentRectMinusAllMargins.top -
precision) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"isWithinContentRect",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"precision",
")",
"{",
"if",
"(",
"x",
">=",
"contentRectMinusAllMargins",
".",
"left",
"-",
"precision",
"&&",
"x",
"<=",
"contentRectMinusAllMargins",
".",
"right... | Check if given coordinates lies inside contentRectMinusAllMargins. | [
"Check",
"if",
"given",
"coordinates",
"lies",
"inside",
"contentRectMinusAllMargins",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L203-L211 |
31,078 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.setCurrentViewport | public void setCurrentViewport(Viewport viewport) {
constrainViewport(viewport.left, viewport.top, viewport.right, viewport.bottom);
} | java | public void setCurrentViewport(Viewport viewport) {
constrainViewport(viewport.left, viewport.top, viewport.right, viewport.bottom);
} | [
"public",
"void",
"setCurrentViewport",
"(",
"Viewport",
"viewport",
")",
"{",
"constrainViewport",
"(",
"viewport",
".",
"left",
",",
"viewport",
".",
"top",
",",
"viewport",
".",
"right",
",",
"viewport",
".",
"bottom",
")",
";",
"}"
] | Set current viewport to the same values as viewport passed in parameter. This method use deep copy so parameter
can be safely modified later. Current viewport must be equal or smaller than maximum viewport.
@param viewport | [
"Set",
"current",
"viewport",
"to",
"the",
"same",
"values",
"as",
"viewport",
"passed",
"in",
"parameter",
".",
"This",
"method",
"use",
"deep",
"copy",
"so",
"parameter",
"can",
"be",
"safely",
"modified",
"later",
".",
"Current",
"viewport",
"must",
"be",... | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L248-L250 |
31,079 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.setCurrentViewport | public void setCurrentViewport(float left, float top, float right, float bottom) {
constrainViewport(left, top, right, bottom);
} | java | public void setCurrentViewport(float left, float top, float right, float bottom) {
constrainViewport(left, top, right, bottom);
} | [
"public",
"void",
"setCurrentViewport",
"(",
"float",
"left",
",",
"float",
"top",
",",
"float",
"right",
",",
"float",
"bottom",
")",
"{",
"constrainViewport",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"}"
] | Set new values for curent viewport, that will change what part of chart is visible. Current viewport must be
equal or smaller than maximum viewport. | [
"Set",
"new",
"values",
"for",
"curent",
"viewport",
"that",
"will",
"change",
"what",
"part",
"of",
"chart",
"is",
"visible",
".",
"Current",
"viewport",
"must",
"be",
"equal",
"or",
"smaller",
"than",
"maximum",
"viewport",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L256-L258 |
31,080 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.setMaxViewport | public void setMaxViewport(Viewport maxViewport) {
setMaxViewport(maxViewport.left, maxViewport.top, maxViewport.right, maxViewport.bottom);
} | java | public void setMaxViewport(Viewport maxViewport) {
setMaxViewport(maxViewport.left, maxViewport.top, maxViewport.right, maxViewport.bottom);
} | [
"public",
"void",
"setMaxViewport",
"(",
"Viewport",
"maxViewport",
")",
"{",
"setMaxViewport",
"(",
"maxViewport",
".",
"left",
",",
"maxViewport",
".",
"top",
",",
"maxViewport",
".",
"right",
",",
"maxViewport",
".",
"bottom",
")",
";",
"}"
] | Set maximum viewport to the same values as viewport passed in parameter. This method use deep copy so parameter
can be safely modified later.
@param maxViewport | [
"Set",
"maximum",
"viewport",
"to",
"the",
"same",
"values",
"as",
"viewport",
"passed",
"in",
"parameter",
".",
"This",
"method",
"use",
"deep",
"copy",
"so",
"parameter",
"can",
"be",
"safely",
"modified",
"later",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L273-L275 |
31,081 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java | ChartComputator.setMaxViewport | public void setMaxViewport(float left, float top, float right, float bottom) {
this.maxViewport.set(left, top, right, bottom);
computeMinimumWidthAndHeight();
} | java | public void setMaxViewport(float left, float top, float right, float bottom) {
this.maxViewport.set(left, top, right, bottom);
computeMinimumWidthAndHeight();
} | [
"public",
"void",
"setMaxViewport",
"(",
"float",
"left",
",",
"float",
"top",
",",
"float",
"right",
",",
"float",
"bottom",
")",
"{",
"this",
".",
"maxViewport",
".",
"set",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"computeMini... | Set new values for maximum viewport, that will change what part of chart is visible. | [
"Set",
"new",
"values",
"for",
"maximum",
"viewport",
"that",
"will",
"change",
"what",
"part",
"of",
"chart",
"is",
"visible",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/computator/ChartComputator.java#L280-L283 |
31,082 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/gesture/ZoomerCompat.java | ZoomerCompat.computeZoom | public boolean computeZoom() {
if (mFinished) {
return false;
}
long tRTC = SystemClock.elapsedRealtime() - mStartRTC;
if (tRTC >= mAnimationDurationMillis) {
mFinished = true;
mCurrentZoom = mEndZoom;
return false;
}
float t = tRTC * 1f / mAnimationDurationMillis;
mCurrentZoom = mEndZoom * mInterpolator.getInterpolation(t);
return true;
} | java | public boolean computeZoom() {
if (mFinished) {
return false;
}
long tRTC = SystemClock.elapsedRealtime() - mStartRTC;
if (tRTC >= mAnimationDurationMillis) {
mFinished = true;
mCurrentZoom = mEndZoom;
return false;
}
float t = tRTC * 1f / mAnimationDurationMillis;
mCurrentZoom = mEndZoom * mInterpolator.getInterpolation(t);
return true;
} | [
"public",
"boolean",
"computeZoom",
"(",
")",
"{",
"if",
"(",
"mFinished",
")",
"{",
"return",
"false",
";",
"}",
"long",
"tRTC",
"=",
"SystemClock",
".",
"elapsedRealtime",
"(",
")",
"-",
"mStartRTC",
";",
"if",
"(",
"tRTC",
">=",
"mAnimationDurationMilli... | Computes the current zoom level, returning true if the zoom is still active and false if the zoom has finished.
@see android.widget.Scroller#computeScrollOffset() | [
"Computes",
"the",
"current",
"zoom",
"level",
"returning",
"true",
"if",
"the",
"zoom",
"is",
"still",
"active",
"and",
"false",
"if",
"the",
"zoom",
"has",
"finished",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/gesture/ZoomerCompat.java#L103-L118 |
31,083 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java | Axis.generateAxisFromRange | public static Axis generateAxisFromRange(float start, float stop, float step) {
List<AxisValue> values = new ArrayList<AxisValue>();
for (float value = start; value <= stop; value += step) {
AxisValue axisValue = new AxisValue(value);
values.add(axisValue);
}
Axis axis = new Axis(values);
return axis;
} | java | public static Axis generateAxisFromRange(float start, float stop, float step) {
List<AxisValue> values = new ArrayList<AxisValue>();
for (float value = start; value <= stop; value += step) {
AxisValue axisValue = new AxisValue(value);
values.add(axisValue);
}
Axis axis = new Axis(values);
return axis;
} | [
"public",
"static",
"Axis",
"generateAxisFromRange",
"(",
"float",
"start",
",",
"float",
"stop",
",",
"float",
"step",
")",
"{",
"List",
"<",
"AxisValue",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"AxisValue",
">",
"(",
")",
";",
"for",
"(",
"float",... | Generates Axis with values from start to stop inclusive. | [
"Generates",
"Axis",
"with",
"values",
"from",
"start",
"to",
"stop",
"inclusive",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java#L112-L122 |
31,084 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java | Axis.generateAxisFromCollection | public static Axis generateAxisFromCollection(List<Float> axisValues) {
List<AxisValue> values = new ArrayList<AxisValue>();
int index = 0;
for (float value : axisValues) {
AxisValue axisValue = new AxisValue(value);
values.add(axisValue);
++index;
}
Axis axis = new Axis(values);
return axis;
} | java | public static Axis generateAxisFromCollection(List<Float> axisValues) {
List<AxisValue> values = new ArrayList<AxisValue>();
int index = 0;
for (float value : axisValues) {
AxisValue axisValue = new AxisValue(value);
values.add(axisValue);
++index;
}
Axis axis = new Axis(values);
return axis;
} | [
"public",
"static",
"Axis",
"generateAxisFromCollection",
"(",
"List",
"<",
"Float",
">",
"axisValues",
")",
"{",
"List",
"<",
"AxisValue",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"AxisValue",
">",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"for"... | Generates Axis with values from given list. | [
"Generates",
"Axis",
"with",
"values",
"from",
"given",
"list",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java#L127-L138 |
31,085 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java | Axis.generateAxisFromCollection | public static Axis generateAxisFromCollection(List<Float> axisValues, List<String> axisValuesLabels) {
if (axisValues.size() != axisValuesLabels.size()) {
throw new IllegalArgumentException("Values and labels lists must have the same size!");
}
List<AxisValue> values = new ArrayList<AxisValue>();
int index = 0;
for (float value : axisValues) {
AxisValue axisValue = new AxisValue(value).setLabel(axisValuesLabels.get(index));
values.add(axisValue);
++index;
}
Axis axis = new Axis(values);
return axis;
} | java | public static Axis generateAxisFromCollection(List<Float> axisValues, List<String> axisValuesLabels) {
if (axisValues.size() != axisValuesLabels.size()) {
throw new IllegalArgumentException("Values and labels lists must have the same size!");
}
List<AxisValue> values = new ArrayList<AxisValue>();
int index = 0;
for (float value : axisValues) {
AxisValue axisValue = new AxisValue(value).setLabel(axisValuesLabels.get(index));
values.add(axisValue);
++index;
}
Axis axis = new Axis(values);
return axis;
} | [
"public",
"static",
"Axis",
"generateAxisFromCollection",
"(",
"List",
"<",
"Float",
">",
"axisValues",
",",
"List",
"<",
"String",
">",
"axisValuesLabels",
")",
"{",
"if",
"(",
"axisValues",
".",
"size",
"(",
")",
"!=",
"axisValuesLabels",
".",
"size",
"(",... | Generates Axis with values and labels from given lists, both lists must have the same size. | [
"Generates",
"Axis",
"with",
"values",
"and",
"labels",
"from",
"given",
"lists",
"both",
"lists",
"must",
"have",
"the",
"same",
"size",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/model/Axis.java#L143-L158 |
31,086 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/AbstractChartRenderer.java | AbstractChartRenderer.drawLabelTextAndBackground | protected void drawLabelTextAndBackground(Canvas canvas, char[] labelBuffer, int startIndex, int numChars,
int autoBackgroundColor) {
final float textX;
final float textY;
if (isValueLabelBackgroundEnabled) {
if (isValueLabelBackgroundAuto) {
labelBackgroundPaint.setColor(autoBackgroundColor);
}
canvas.drawRect(labelBackgroundRect, labelBackgroundPaint);
textX = labelBackgroundRect.left + labelMargin;
textY = labelBackgroundRect.bottom - labelMargin;
} else {
textX = labelBackgroundRect.left;
textY = labelBackgroundRect.bottom;
}
canvas.drawText(labelBuffer, startIndex, numChars, textX, textY, labelPaint);
} | java | protected void drawLabelTextAndBackground(Canvas canvas, char[] labelBuffer, int startIndex, int numChars,
int autoBackgroundColor) {
final float textX;
final float textY;
if (isValueLabelBackgroundEnabled) {
if (isValueLabelBackgroundAuto) {
labelBackgroundPaint.setColor(autoBackgroundColor);
}
canvas.drawRect(labelBackgroundRect, labelBackgroundPaint);
textX = labelBackgroundRect.left + labelMargin;
textY = labelBackgroundRect.bottom - labelMargin;
} else {
textX = labelBackgroundRect.left;
textY = labelBackgroundRect.bottom;
}
canvas.drawText(labelBuffer, startIndex, numChars, textX, textY, labelPaint);
} | [
"protected",
"void",
"drawLabelTextAndBackground",
"(",
"Canvas",
"canvas",
",",
"char",
"[",
"]",
"labelBuffer",
",",
"int",
"startIndex",
",",
"int",
"numChars",
",",
"int",
"autoBackgroundColor",
")",
"{",
"final",
"float",
"textX",
";",
"final",
"float",
"... | Draws label text and label background if isValueLabelBackgroundEnabled is true. | [
"Draws",
"label",
"text",
"and",
"label",
"background",
"if",
"isValueLabelBackgroundEnabled",
"is",
"true",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/AbstractChartRenderer.java#L104-L125 |
31,087 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/model/Viewport.java | Viewport.set | public void set(Viewport src) {
this.left = src.left;
this.top = src.top;
this.right = src.right;
this.bottom = src.bottom;
} | java | public void set(Viewport src) {
this.left = src.left;
this.top = src.top;
this.right = src.right;
this.bottom = src.bottom;
} | [
"public",
"void",
"set",
"(",
"Viewport",
"src",
")",
"{",
"this",
".",
"left",
"=",
"src",
".",
"left",
";",
"this",
".",
"top",
"=",
"src",
".",
"top",
";",
"this",
".",
"right",
"=",
"src",
".",
"right",
";",
"this",
".",
"bottom",
"=",
"src... | Copy the coordinates from src into this viewport.
@param src The viewport whose coordinates are copied into this viewport. | [
"Copy",
"the",
"coordinates",
"from",
"src",
"into",
"this",
"viewport",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/model/Viewport.java#L162-L167 |
31,088 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/model/Viewport.java | Viewport.contains | public boolean contains(Viewport v) {
// check for empty first
return this.left < this.right && this.bottom < this.top
// now check for containment
&& left <= v.left && top >= v.top && right >= v.right && bottom <= v.bottom;
} | java | public boolean contains(Viewport v) {
// check for empty first
return this.left < this.right && this.bottom < this.top
// now check for containment
&& left <= v.left && top >= v.top && right >= v.right && bottom <= v.bottom;
} | [
"public",
"boolean",
"contains",
"(",
"Viewport",
"v",
")",
"{",
"// check for empty first",
"return",
"this",
".",
"left",
"<",
"this",
".",
"right",
"&&",
"this",
".",
"bottom",
"<",
"this",
".",
"top",
"// now check for containment",
"&&",
"left",
"<=",
"... | Returns true iff the specified viewport r is inside or equal to this viewport. An empty viewport never contains
another viewport.
@param v The viewport being tested for containment.
@return true iff the specified viewport r is inside or equal to this viewport | [
"Returns",
"true",
"iff",
"the",
"specified",
"viewport",
"r",
"is",
"inside",
"or",
"equal",
"to",
"this",
"viewport",
".",
"An",
"empty",
"viewport",
"never",
"contains",
"another",
"viewport",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/model/Viewport.java#L250-L255 |
31,089 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/AxesRenderer.java | AxesRenderer.drawInForeground | public void drawInForeground(Canvas canvas) {
Axis axis = chart.getChartData().getAxisYLeft();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, LEFT);
}
axis = chart.getChartData().getAxisYRight();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, RIGHT);
}
axis = chart.getChartData().getAxisXBottom();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, BOTTOM);
}
axis = chart.getChartData().getAxisXTop();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, TOP);
}
} | java | public void drawInForeground(Canvas canvas) {
Axis axis = chart.getChartData().getAxisYLeft();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, LEFT);
}
axis = chart.getChartData().getAxisYRight();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, RIGHT);
}
axis = chart.getChartData().getAxisXBottom();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, BOTTOM);
}
axis = chart.getChartData().getAxisXTop();
if (null != axis) {
drawAxisLabelsAndName(canvas, axis, TOP);
}
} | [
"public",
"void",
"drawInForeground",
"(",
"Canvas",
"canvas",
")",
"{",
"Axis",
"axis",
"=",
"chart",
".",
"getChartData",
"(",
")",
".",
"getAxisYLeft",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"axis",
")",
"{",
"drawAxisLabelsAndName",
"(",
"canvas",
"... | Draw axes labels and names in the foreground.
@param canvas | [
"Draw",
"axes",
"labels",
"and",
"names",
"in",
"the",
"foreground",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/AxesRenderer.java#L375-L395 |
31,090 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/LineChartRenderer.java | LineChartRenderer.drawPoints | private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) {
pointPaint.setColor(line.getPointColor());
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (computator.isWithinContentRect(rawX, rawY, checkPrecision)) {
// Draw points only if they are within contentRectMinusAllMargins, using contentRectMinusAllMargins
// instead of viewport to avoid some
// float rounding problems.
if (MODE_DRAW == mode) {
drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius);
if (line.hasLabels()) {
drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset);
}
} else if (MODE_HIGHLIGHT == mode) {
highlightPoint(canvas, line, pointValue, rawX, rawY, lineIndex, valueIndex);
} else {
throw new IllegalStateException("Cannot process points in mode: " + mode);
}
}
++valueIndex;
}
} | java | private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) {
pointPaint.setColor(line.getPointColor());
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (computator.isWithinContentRect(rawX, rawY, checkPrecision)) {
// Draw points only if they are within contentRectMinusAllMargins, using contentRectMinusAllMargins
// instead of viewport to avoid some
// float rounding problems.
if (MODE_DRAW == mode) {
drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius);
if (line.hasLabels()) {
drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset);
}
} else if (MODE_HIGHLIGHT == mode) {
highlightPoint(canvas, line, pointValue, rawX, rawY, lineIndex, valueIndex);
} else {
throw new IllegalStateException("Cannot process points in mode: " + mode);
}
}
++valueIndex;
}
} | [
"private",
"void",
"drawPoints",
"(",
"Canvas",
"canvas",
",",
"Line",
"line",
",",
"int",
"lineIndex",
",",
"int",
"mode",
")",
"{",
"pointPaint",
".",
"setColor",
"(",
"line",
".",
"getPointColor",
"(",
")",
")",
";",
"int",
"valueIndex",
"=",
"0",
"... | implementing point styles. | [
"implementing",
"point",
"styles",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/LineChartRenderer.java#L371-L395 |
31,091 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/view/AbstractChartView.java | AbstractChartView.canScrollHorizontally | @Override
public boolean canScrollHorizontally(int direction) {
if (getZoomLevel() <= 1.0) {
return false;
}
final Viewport currentViewport = getCurrentViewport();
final Viewport maximumViewport = getMaximumViewport();
if (direction < 0) {
return currentViewport.left > maximumViewport.left;
} else {
return currentViewport.right < maximumViewport.right;
}
} | java | @Override
public boolean canScrollHorizontally(int direction) {
if (getZoomLevel() <= 1.0) {
return false;
}
final Viewport currentViewport = getCurrentViewport();
final Viewport maximumViewport = getMaximumViewport();
if (direction < 0) {
return currentViewport.left > maximumViewport.left;
} else {
return currentViewport.right < maximumViewport.right;
}
} | [
"@",
"Override",
"public",
"boolean",
"canScrollHorizontally",
"(",
"int",
"direction",
")",
"{",
"if",
"(",
"getZoomLevel",
"(",
")",
"<=",
"1.0",
")",
"{",
"return",
"false",
";",
"}",
"final",
"Viewport",
"currentViewport",
"=",
"getCurrentViewport",
"(",
... | When embedded in a ViewPager, this will be called in order to know if we can scroll.
If this returns true, the ViewPager will ignore the drag so that we can scroll our content.
If this return false, the ViewPager will assume we won't be able to scroll and will consume the drag
@param direction Amount of pixels being scrolled (x axis)
@return true if the chart can be scrolled (ie. zoomed and not against the edge of the chart) | [
"When",
"embedded",
"in",
"a",
"ViewPager",
"this",
"will",
"be",
"called",
"in",
"order",
"to",
"know",
"if",
"we",
"can",
"scroll",
".",
"If",
"this",
"returns",
"true",
"the",
"ViewPager",
"will",
"ignore",
"the",
"drag",
"so",
"that",
"we",
"can",
... | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/view/AbstractChartView.java#L494-L506 |
31,092 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/PieChartRenderer.java | PieChartRenderer.pointToAngle | private float pointToAngle(float x, float y, float centerX, float centerY) {
double diffX = x - centerX;
double diffY = y - centerY;
// Pass -diffX to get clockwise degrees order.
double radian = Math.atan2(-diffX, diffY);
float angle = ((float) Math.toDegrees(radian) + 360) % 360;
// Add 90 because atan2 returns 0 degrees at 6 o'clock.
angle += 90f;
return angle;
} | java | private float pointToAngle(float x, float y, float centerX, float centerY) {
double diffX = x - centerX;
double diffY = y - centerY;
// Pass -diffX to get clockwise degrees order.
double radian = Math.atan2(-diffX, diffY);
float angle = ((float) Math.toDegrees(radian) + 360) % 360;
// Add 90 because atan2 returns 0 degrees at 6 o'clock.
angle += 90f;
return angle;
} | [
"private",
"float",
"pointToAngle",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"centerX",
",",
"float",
"centerY",
")",
"{",
"double",
"diffX",
"=",
"x",
"-",
"centerX",
";",
"double",
"diffY",
"=",
"y",
"-",
"centerY",
";",
"// Pass -diffX to g... | Calculates angle of touched point. | [
"Calculates",
"angle",
"of",
"touched",
"point",
"."
] | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/PieChartRenderer.java#L410-L420 |
31,093 | lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/PieChartRenderer.java | PieChartRenderer.calculateMaxViewport | private void calculateMaxViewport() {
tempMaximumViewport.set(0, MAX_WIDTH_HEIGHT, MAX_WIDTH_HEIGHT, 0);
maxSum = 0.0f;
for (SliceValue sliceValue : dataProvider.getPieChartData().getValues()) {
maxSum += Math.abs(sliceValue.getValue());
}
} | java | private void calculateMaxViewport() {
tempMaximumViewport.set(0, MAX_WIDTH_HEIGHT, MAX_WIDTH_HEIGHT, 0);
maxSum = 0.0f;
for (SliceValue sliceValue : dataProvider.getPieChartData().getValues()) {
maxSum += Math.abs(sliceValue.getValue());
}
} | [
"private",
"void",
"calculateMaxViewport",
"(",
")",
"{",
"tempMaximumViewport",
".",
"set",
"(",
"0",
",",
"MAX_WIDTH_HEIGHT",
",",
"MAX_WIDTH_HEIGHT",
",",
"0",
")",
";",
"maxSum",
"=",
"0.0f",
";",
"for",
"(",
"SliceValue",
"sliceValue",
":",
"dataProvider"... | Viewport is not really important for PieChart, this kind of chart doesn't relay on viewport but uses pixels
coordinates instead. This method also calculates sum of all SliceValues. | [
"Viewport",
"is",
"not",
"really",
"important",
"for",
"PieChart",
"this",
"kind",
"of",
"chart",
"doesn",
"t",
"relay",
"on",
"viewport",
"but",
"uses",
"pixels",
"coordinates",
"instead",
".",
"This",
"method",
"also",
"calculates",
"sum",
"of",
"all",
"Sl... | c41419c9afa097452dee823c7eba0e5136aa96bd | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/PieChartRenderer.java#L443-L449 |
31,094 | openwms/org.openwms | org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java | AbstractWebController.translate | protected String translate(String key, Object... objects) {
return messageSource.getMessage(key, objects, null);
} | java | protected String translate(String key, Object... objects) {
return messageSource.getMessage(key, objects, null);
} | [
"protected",
"String",
"translate",
"(",
"String",
"key",
",",
"Object",
"...",
"objects",
")",
"{",
"return",
"messageSource",
".",
"getMessage",
"(",
"key",
",",
"objects",
",",
"null",
")",
";",
"}"
] | Get the messageSource.
@param key The error code to search message text for
@param objects Any arguments that are passed into the message text
@return the messageSource. | [
"Get",
"the",
"messageSource",
"."
] | b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e | https://github.com/openwms/org.openwms/blob/b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e/org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java#L131-L133 |
31,095 | openwms/org.openwms | org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java | AbstractWebController.buildOKResponse | protected <T extends AbstractBase> ResponseEntity<Response<T>> buildOKResponse(T... params) {
return buildResponse(HttpStatus.OK, "", "", params);
} | java | protected <T extends AbstractBase> ResponseEntity<Response<T>> buildOKResponse(T... params) {
return buildResponse(HttpStatus.OK, "", "", params);
} | [
"protected",
"<",
"T",
"extends",
"AbstractBase",
">",
"ResponseEntity",
"<",
"Response",
"<",
"T",
">",
">",
"buildOKResponse",
"(",
"T",
"...",
"params",
")",
"{",
"return",
"buildResponse",
"(",
"HttpStatus",
".",
"OK",
",",
"\"\"",
",",
"\"\"",
",",
... | Build an response object that signals a success response to the caller.
@param <T> Some type extending the AbstractBase entity
@param params A set of Serializable objects that are passed to the caller
@return A ResponseEntity with status {@link HttpStatus#OK} | [
"Build",
"an",
"response",
"object",
"that",
"signals",
"a",
"success",
"response",
"to",
"the",
"caller",
"."
] | b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e | https://github.com/openwms/org.openwms/blob/b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e/org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java#L173-L175 |
31,096 | openwms/org.openwms | org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java | AbstractWebController.getLocationForCreatedResource | protected String getLocationForCreatedResource(HttpServletRequest req, String objId) {
StringBuffer url = req.getRequestURL();
UriTemplate template = new UriTemplate(url.append("/{objId}/").toString());
return template.expand(objId).toASCIIString();
} | java | protected String getLocationForCreatedResource(HttpServletRequest req, String objId) {
StringBuffer url = req.getRequestURL();
UriTemplate template = new UriTemplate(url.append("/{objId}/").toString());
return template.expand(objId).toASCIIString();
} | [
"protected",
"String",
"getLocationForCreatedResource",
"(",
"HttpServletRequest",
"req",
",",
"String",
"objId",
")",
"{",
"StringBuffer",
"url",
"=",
"req",
".",
"getRequestURL",
"(",
")",
";",
"UriTemplate",
"template",
"=",
"new",
"UriTemplate",
"(",
"url",
... | Append the ID of the object that was created to the original request URL and return it.
@param req The HttpServletRequest object
@param objId The ID to append
@return The complete appended URL | [
"Append",
"the",
"ID",
"of",
"the",
"object",
"that",
"was",
"created",
"to",
"the",
"original",
"request",
"URL",
"and",
"return",
"it",
"."
] | b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e | https://github.com/openwms/org.openwms/blob/b24a95c5d09a7ec3c723d7e107d1cb0039d06a7e/org.openwms.core.util/src/main/java/org/openwms/core/http/AbstractWebController.java#L211-L215 |
31,097 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java | DefaultDockerClientConfig.overrideDockerPropertiesWithSystemProperties | private static Properties overrideDockerPropertiesWithSystemProperties(Properties p, Properties systemProperties) {
Properties overriddenProperties = new Properties();
overriddenProperties.putAll(p);
for (String key : CONFIG_KEYS) {
if (systemProperties.containsKey(key)) {
overriddenProperties.setProperty(key, systemProperties.getProperty(key));
}
}
return overriddenProperties;
} | java | private static Properties overrideDockerPropertiesWithSystemProperties(Properties p, Properties systemProperties) {
Properties overriddenProperties = new Properties();
overriddenProperties.putAll(p);
for (String key : CONFIG_KEYS) {
if (systemProperties.containsKey(key)) {
overriddenProperties.setProperty(key, systemProperties.getProperty(key));
}
}
return overriddenProperties;
} | [
"private",
"static",
"Properties",
"overrideDockerPropertiesWithSystemProperties",
"(",
"Properties",
"p",
",",
"Properties",
"systemProperties",
")",
"{",
"Properties",
"overriddenProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"overriddenProperties",
".",
"putAll"... | Creates a new Properties object containing values overridden from the System properties
@param p
The original set of properties to override
@return A copy of the original Properties with overridden values | [
"Creates",
"a",
"new",
"Properties",
"object",
"containing",
"values",
"overridden",
"from",
"the",
"System",
"properties"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java#L179-L189 |
31,098 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java | DefaultDockerClientConfig.createDefaultConfigBuilder | static Builder createDefaultConfigBuilder(Map<String, String> env, Properties systemProperties) {
Properties properties = loadIncludedDockerProperties(systemProperties);
properties = overrideDockerPropertiesWithSettingsFromUserHome(properties, systemProperties);
properties = overrideDockerPropertiesWithEnv(properties, env);
properties = overrideDockerPropertiesWithSystemProperties(properties, systemProperties);
return new Builder().withProperties(properties);
} | java | static Builder createDefaultConfigBuilder(Map<String, String> env, Properties systemProperties) {
Properties properties = loadIncludedDockerProperties(systemProperties);
properties = overrideDockerPropertiesWithSettingsFromUserHome(properties, systemProperties);
properties = overrideDockerPropertiesWithEnv(properties, env);
properties = overrideDockerPropertiesWithSystemProperties(properties, systemProperties);
return new Builder().withProperties(properties);
} | [
"static",
"Builder",
"createDefaultConfigBuilder",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"env",
",",
"Properties",
"systemProperties",
")",
"{",
"Properties",
"properties",
"=",
"loadIncludedDockerProperties",
"(",
"systemProperties",
")",
";",
"properties",
... | Allows you to build the config without system environment interfering for more robust testing | [
"Allows",
"you",
"to",
"build",
"the",
"config",
"without",
"system",
"environment",
"interfering",
"for",
"more",
"robust",
"testing"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java#L198-L204 |
31,099 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/KeystoreSSLConfig.java | KeystoreSSLConfig.getSSLContext | @Override
public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
NoSuchAlgorithmException, KeyStoreException {
final SSLContext context = SSLContext.getInstance("TLS");
String httpProtocols = System.getProperty("https.protocols");
System.setProperty("https.protocols", "TLSv1");
if (httpProtocols != null) {
System.setProperty("https.protocols", httpProtocols);
}
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
.getDefaultAlgorithm());
keyManagerFactory.init(keystore, keystorePassword.toCharArray());
context.init(keyManagerFactory.getKeyManagers(), new TrustManager[] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
@Override
public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) {
}
@Override
public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) {
}
}
}, new SecureRandom());
return context;
} | java | @Override
public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
NoSuchAlgorithmException, KeyStoreException {
final SSLContext context = SSLContext.getInstance("TLS");
String httpProtocols = System.getProperty("https.protocols");
System.setProperty("https.protocols", "TLSv1");
if (httpProtocols != null) {
System.setProperty("https.protocols", httpProtocols);
}
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
.getDefaultAlgorithm());
keyManagerFactory.init(keystore, keystorePassword.toCharArray());
context.init(keyManagerFactory.getKeyManagers(), new TrustManager[] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
@Override
public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) {
}
@Override
public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) {
}
}
}, new SecureRandom());
return context;
} | [
"@",
"Override",
"public",
"SSLContext",
"getSSLContext",
"(",
")",
"throws",
"KeyManagementException",
",",
"UnrecoverableKeyException",
",",
"NoSuchAlgorithmException",
",",
"KeyStoreException",
"{",
"final",
"SSLContext",
"context",
"=",
"SSLContext",
".",
"getInstance... | Get the SSL Context out of the keystore.
@return java SSLContext
@throws KeyManagementException
@throws UnrecoverableKeyException
@throws NoSuchAlgorithmException
@throws KeyStoreException | [
"Get",
"the",
"SSL",
"Context",
"out",
"of",
"the",
"keystore",
"."
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/KeystoreSSLConfig.java#L75-L111 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.