_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q159100 | IntInterval.fromTo | train | public static IntInterval fromTo(int from, int to)
{
if (from <= to)
{
return IntInterval.fromToBy(from, to, 1);
}
return IntInterval.fromToBy(from, to, -1);
} | java | {
"resource": ""
} |
q159101 | IntInterval.evensFromTo | train | public static IntInterval evensFromTo(int from, int to)
{
if (from % 2 != 0)
{
if (from < to)
{
from++;
}
else
{
from--;
}
}
if (to % 2 != 0)
{
if (to > from)
... | java | {
"resource": ""
} |
q159102 | IntInterval.oddsFromTo | train | public static IntInterval oddsFromTo(int from, int to)
{
if (from % 2 == 0)
{
if (from < to)
{
from++;
}
else
{
from--;
}
}
if (to % 2 == 0)
{
if (to > from)
... | java | {
"resource": ""
} |
q159103 | IntInterval.fromToBy | train | public static IntInterval fromToBy(int from, int to, int stepBy)
{
if (stepBy == 0)
{
throw new IllegalArgumentException("Cannot use a step by of 0");
}
if (from > to && stepBy > 0 || from < to && stepBy < 0)
{
throw new IllegalArgumentException("Step ... | java | {
"resource": ""
} |
q159104 | ConcurrentHashMapUnsafe.putIfAbsentGetIfPresent | train | public <P1, P2> V putIfAbsentGetIfPresent(K key, Function2<K, V, K> keyTransformer, Function3<P1, P2, K, V> factory, P1 param1, P2 param2)
{
int hash = this.hash(key);
Object[] currentArray = this.table;
V newValue = null;
boolean createdValue = false;
while (true)
{
... | java | {
"resource": ""
} |
q159105 | UnmodifiableRichIterable.of | train | public static <E, RI extends RichIterable<E>> UnmodifiableRichIterable<E> of(RI iterable)
{
if (iterable == null)
{
throw new IllegalArgumentException("cannot create a UnmodifiableRichIterable for null");
}
return new UnmodifiableRichIterable<E>(iterable);
} | java | {
"resource": ""
} |
q159106 | Predicates.equal | train | public static Predicates<Object> equal(Object object)
{
if (object == null)
{
return Predicates.isNull();
}
return new EqualPredicate(object);
} | java | {
"resource": ""
} |
q159107 | Predicates.betweenInclusive | train | public static <T extends Comparable<? super T>> Predicates<T> betweenInclusive(T from, T to)
{
Predicates.failIfDifferentTypes(from, to);
return new BetweenInclusive<T>(from, to);
} | java | {
"resource": ""
} |
q159108 | Predicates.betweenExclusive | train | public static <T extends Comparable<? super T>> Predicates<T> betweenExclusive(T from, T to)
{
Predicates.failIfDifferentTypes(from, to);
return new BetweenExclusive<T>(from, to);
} | java | {
"resource": ""
} |
q159109 | Predicates.betweenInclusiveFrom | train | public static <T extends Comparable<? super T>> Predicates<T> betweenInclusiveFrom(T from, T to)
{
Predicates.failIfDifferentTypes(from, to);
return new BetweenInclusiveFrom<T>(from, to);
} | java | {
"resource": ""
} |
q159110 | Predicates.betweenInclusiveTo | train | public static <T extends Comparable<? super T>> Predicates<T> betweenInclusiveTo(T from, T to)
{
Predicates.failIfDifferentTypes(from, to);
return new BetweenInclusiveTo<T>(from, to);
} | java | {
"resource": ""
} |
q159111 | Predicates.in | train | public static Predicates<Object> in(Iterable<?> iterable)
{
if (iterable instanceof SetIterable<?>)
{
return new InSetIterablePredicate((SetIterable<?>) iterable);
}
if (iterable instanceof Set<?>)
{
return new InSetPredicate((Set<?>) iterable);
... | java | {
"resource": ""
} |
q159112 | Predicates.attributeIn | train | public static <T> Predicates<T> attributeIn(
Function<? super T, ?> function,
Iterable<?> iterable)
{
return new AttributePredicate<T, Object>(function, Predicates.in(iterable));
} | java | {
"resource": ""
} |
q159113 | Predicates.notIn | train | public static Predicates<Object> notIn(Iterable<?> iterable)
{
if (iterable instanceof SetIterable<?>)
{
return new NotInSetIterablePredicate((SetIterable<?>) iterable);
}
if (iterable instanceof Set<?>)
{
return new NotInSetPredicate((Set<?>) iterable... | java | {
"resource": ""
} |
q159114 | Predicates.attributeNotIn | train | public static <T> Predicates<T> attributeNotIn(
Function<? super T, ?> function,
Iterable<?> iterable)
{
return new AttributePredicate<T, Object>(function, Predicates.notIn(iterable));
} | java | {
"resource": ""
} |
q159115 | LazyIterate.adapt | train | public static <T> LazyIterable<T> adapt(Iterable<T> iterable)
{
return new LazyIterableAdapter<T>(iterable);
} | java | {
"resource": ""
} |
q159116 | LazyIterate.select | train | public static <T> LazyIterable<T> select(Iterable<T> iterable, Predicate<? super T> predicate)
{
return new SelectIterable<T>(iterable, predicate);
} | java | {
"resource": ""
} |
q159117 | LazyIterate.reject | train | public static <T> LazyIterable<T> reject(Iterable<T> iterable, Predicate<? super T> predicate)
{
return new RejectIterable<T>(iterable, predicate);
} | java | {
"resource": ""
} |
q159118 | LazyIterate.collect | train | public static <T, V> LazyIterable<V> collect(
Iterable<T> iterable,
Function<? super T, ? extends V> function)
{
return new CollectIterable<T, V>(iterable, function);
} | java | {
"resource": ""
} |
q159119 | LazyIterate.flatCollect | train | public static <T, V> LazyIterable<V> flatCollect(
Iterable<T> iterable,
Function<? super T, ? extends Iterable<V>> function)
{
return new FlatCollectIterable<T, V>(iterable, function);
} | java | {
"resource": ""
} |
q159120 | LazyIterate.collectIf | train | public static <T, V> LazyIterable<V> collectIf(
Iterable<T> iterable,
Predicate<? super T> predicate,
Function<? super T, ? extends V> function)
{
return LazyIterate.select(iterable, predicate).collect(function);
} | java | {
"resource": ""
} |
q159121 | LazyIterate.take | train | public static <T> LazyIterable<T> take(Iterable<T> iterable, int count)
{
return new TakeIterable<T>(iterable, count);
} | java | {
"resource": ""
} |
q159122 | LazyIterate.drop | train | public static <T> LazyIterable<T> drop(Iterable<T> iterable, int count)
{
return new DropIterable<T>(iterable, count);
} | java | {
"resource": ""
} |
q159123 | LazyIterate.distinct | train | public static <T> LazyIterable<T> distinct(Iterable<T> iterable)
{
return new DistinctIterable<T>(iterable);
} | java | {
"resource": ""
} |
q159124 | LazyIterate.concatenate | train | public static <T> LazyIterable<T> concatenate(Iterable<T>... iterables)
{
return CompositeIterable.with(iterables);
} | java | {
"resource": ""
} |
q159125 | LazyIterate.tap | train | public static <T> LazyIterable<T> tap(Iterable<T> iterable, Procedure<? super T> procedure)
{
return new TapIterable<T>(iterable, procedure);
} | java | {
"resource": ""
} |
q159126 | UnmodifiableMutableList.of | train | public static <E, L extends List<E>> UnmodifiableMutableList<E> of(L list)
{
if (list == null)
{
throw new IllegalArgumentException("cannot create an UnmodifiableMutableList for null");
}
if (list instanceof RandomAccess)
{
return new RandomAccessUnmod... | java | {
"resource": ""
} |
q159127 | SynchronizedStack.of | train | public static <T, S extends MutableStack<T>> SynchronizedStack<T> of(S stack)
{
return new SynchronizedStack<T>(stack);
} | java | {
"resource": ""
} |
q159128 | ThreadLocalPrintStream.getPrintStream | train | PrintStream getPrintStream() {
PrintStream result = (PrintStream) streams.get();
return ((result == null) ? defaultPrintStream : result);
} | java | {
"resource": ""
} |
q159129 | NGServer.getOrCreateStatsFor | train | private NailStats getOrCreateStatsFor(Class nailClass) {
NailStats result;
synchronized (allNailStats) {
String nailClassName = nailClass.getName();
result = allNailStats.get(nailClassName);
if (result == null) {
result = new NailStats(nailClassName);
allNailStats.put(nailClass... | java | {
"resource": ""
} |
q159130 | NGServer.shutdown | train | public void shutdown() {
if (shutdown.getAndSet(true)) {
return;
}
// NGServer main thread might be blocking on socket in `accept()`, so we close the socket
// here to unblock it and finish gracefully
try {
serversocket.close();
} catch (Throwable ex) {
LOG.log(Level.WARNING, ... | java | {
"resource": ""
} |
q159131 | NGServer.run | train | public void run() {
originalSecurityManager = System.getSecurityManager();
System.setSecurityManager(new NGSecurityManager(originalSecurityManager));
if (!(System.in instanceof ThreadLocalInputStream)) {
System.setIn(new ThreadLocalInputStream(in));
}
if (!(System.out instanceof ThreadLocalPr... | java | {
"resource": ""
} |
q159132 | AliasManager.getAliases | train | public Set getAliases() {
Set result = new java.util.TreeSet();
synchronized (aliases) {
result.addAll(aliases.values());
}
return (result);
} | java | {
"resource": ""
} |
q159133 | NGConstants.getVersion | train | private static String getVersion() {
Properties props = new Properties();
try (InputStream is =
NGConstants.class.getResourceAsStream(
"/META-INF/maven/com.facebook/nailgun-server/pom.properties")) {
props.load(is);
} catch (Throwable e) {
// In static initialization context,... | java | {
"resource": ""
} |
q159134 | ThreadLocalInputStream.getInputStream | train | InputStream getInputStream() {
InputStream result = (InputStream) streams.get();
return ((result == null) ? defaultInputStream : result);
} | java | {
"resource": ""
} |
q159135 | Hash.getCryptoImpls | train | private static Set getCryptoImpls(String serviceType) {
Set result = new TreeSet();
// All all providers
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
// Get services provided by each provider
Set keys = providers[i].keySet();
for (Object... | java | {
"resource": ""
} |
q159136 | NGSessionPool.take | train | NGSession take() {
synchronized (lock) {
if (done) {
throw new UnsupportedOperationException("NGSession pool is shutting down");
}
NGSession session = idlePool.poll();
if (session == null) {
session = instanceCreator.get();
session.start();
}
workingPool.a... | java | {
"resource": ""
} |
q159137 | NGSessionPool.give | train | void give(NGSession session) {
synchronized (lock) {
if (done) {
// session is already signalled shutdown and removed from all collections
return;
}
workingPool.remove(session);
if (idlePool.size() < maxIdleSessions) {
idlePool.add(session);
return;
}
... | java | {
"resource": ""
} |
q159138 | NGSessionPool.shutdown | train | void shutdown() throws InterruptedException {
List<NGSession> allSessions;
synchronized (lock) {
done = true;
allSessions =
Stream.concat(workingPool.stream(), idlePool.stream()).collect(Collectors.toList());
idlePool.clear();
workingPool.clear();
}
for (NGSession sessi... | java | {
"resource": ""
} |
q159139 | NGCommunicator.readCommandContext | train | CommandContext readCommandContext() throws IOException {
// client info - command line arguments and environment
List<String> remoteArgs = new ArrayList();
Properties remoteEnv = new Properties();
String cwd = null; // working directory
String command = null; // alias or class name
// read every... | java | {
"resource": ""
} |
q159140 | NGCommunicator.startBackgroundReceive | train | private void startBackgroundReceive() {
// Read timeout, including heartbeats, should be handled by socket.
// However Java Socket/Stream API does not enforce that. To stay on safer side,
// use timeout on a future
// let socket timeout first, set rough timeout to 110% of original
long futureTimeou... | java | {
"resource": ""
} |
q159141 | NGCommunicator.exit | train | void exit(int exitCode) {
if (isExited) {
return;
}
// First, stop reading from the socket. If we won't do that then client receives an exit code
// and terminates
// the socket on its end, causing readExecutor to throw
try {
stopIn();
} catch (IOException ex) {
LOG.log(
... | java | {
"resource": ""
} |
q159142 | NGCommunicator.stopIn | train | private void stopIn() throws IOException {
if (inClosed) {
return;
}
inClosed = true;
LOG.log(Level.FINE, "Shutting down socket for input");
// unblock all waiting readers
setEof();
// signal orchestrator thread it is ok to quit now as there will be no more input
synchronized (o... | java | {
"resource": ""
} |
q159143 | NGCommunicator.stopOut | train | private void stopOut() throws IOException {
if (outClosed) {
return;
}
outClosed = true;
LOG.log(Level.FINE, "Shutting down socket for output");
// close socket for output - that will initiate normal socket close procedure; in case of TCP
// socket this is
// a buffer flush and TCP t... | java | {
"resource": ""
} |
q159144 | NGCommunicator.close | train | public void close() throws IOException {
if (closed) {
return;
}
closed = true;
stopIn();
stopOut();
// socket streams and socket itself should be already closed with stopIn() and stopOut()
// but because it is idempotent, let's be good citizens and close corresponding streams as wel... | java | {
"resource": ""
} |
q159145 | NGCommunicator.readChunk | train | private byte readChunk() throws IOException {
try {
return readChunkImpl();
} catch (SocketException ex) {
// Some stream implementations may throw SocketException and not EOFException when socket is
// terminated by
// application
// By common agreement, rethrow it as EOFException... | java | {
"resource": ""
} |
q159146 | NGCommunicator.receive | train | int receive(byte[] b, int offset, int length) throws IOException, InterruptedException {
synchronized (readLock) {
if (remaining > 0) {
int bytesToRead = Math.min(remaining, length);
int result = stdin.read(b, offset, bytesToRead);
remaining -= result;
return result;
}
... | java | {
"resource": ""
} |
q159147 | NGCommunicator.send | train | void send(byte streamCode, byte[] b, int offset, int len) throws IOException {
synchronized (writeLock) {
out.writeInt(len);
out.writeByte(streamCode);
out.write(b, offset, len);
}
out.flush();
} | java | {
"resource": ""
} |
q159148 | NGCommunicator.notifyHeartbeat | train | private void notifyHeartbeat() {
ArrayList<NGHeartbeatListener> listeners;
synchronized (heartbeatListeners) {
if (heartbeatListeners.isEmpty()) {
return;
}
// copy collection to avoid executing callbacks under lock
listeners = new ArrayList<>(heartbeatListeners);
}
for ... | java | {
"resource": ""
} |
q159149 | NGSession.run | train | public void run(Socket socket) {
synchronized (lock) {
nextSocket = socket;
lock.notify();
}
Thread.yield();
} | java | {
"resource": ""
} |
q159150 | NGSession.nextSocket | train | private Socket nextSocket() {
Socket result;
synchronized (lock) {
result = nextSocket;
while (!done && result == null) {
try {
lock.wait();
} catch (InterruptedException e) {
done = true;
}
result = nextSocket;
}
nextSocket = null;
... | java | {
"resource": ""
} |
q159151 | NGSession.run | train | public void run() {
updateThreadName(null);
LOG.log(Level.FINE, "NGSession {0} is waiting for first client to connect", instanceNumber);
Socket socket = nextSocket();
while (socket != null) {
LOG.log(Level.FINE, "NGSession {0} accepted new connection", instanceNumber);
try (NGCommunicator ... | java | {
"resource": ""
} |
q159152 | BlurDialogEngine.onResume | train | public void onResume(boolean retainedInstance) {
if (mBlurredBackgroundView == null || retainedInstance) {
if (mHoldingActivity.getWindow().getDecorView().isShown()) {
mBluringTask = new BlurAsyncTask();
mBluringTask.execute();
} else {
mHo... | java | {
"resource": ""
} |
q159153 | BlurDialogEngine.getActionBarHeight | train | private int getActionBarHeight() {
int actionBarHeight = 0;
try {
if (mToolbar != null) {
actionBarHeight = mToolbar.getHeight();
} else if (mHoldingActivity instanceof ActionBarActivity) {
ActionBar supportActionBar
= ((Action... | java | {
"resource": ""
} |
q159154 | BlurDialogEngine.getStatusBarHeight | train | private int getStatusBarHeight() {
int result = 0;
int resourceId = mHoldingActivity.getResources()
.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = mHoldingActivity.getResources().getDimensionPixelSize(resourceId);
}
... | java | {
"resource": ""
} |
q159155 | BlurDialogEngine.getNavigationBarOffset | train | private int getNavigationBarOffset() {
int result = 0;
Resources resources = mHoldingActivity.getResources();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId... | java | {
"resource": ""
} |
q159156 | BlurDialogEngine.isStatusBarTranslucent | train | @TargetApi(Build.VERSION_CODES.KITKAT)
private boolean isStatusBarTranslucent() {
TypedValue typedValue = new TypedValue();
int[] attribute = new int[]{android.R.attr.windowTranslucentStatus};
TypedArray array = mHoldingActivity.obtainStyledAttributes(typedValue.resourceId, attribute);
... | java | {
"resource": ""
} |
q159157 | BlurDialogEngine.removeBlurredView | train | private void removeBlurredView() {
if (mBlurredBackgroundView != null) {
ViewGroup parent = (ViewGroup) mBlurredBackgroundView.getParent();
if (parent != null) {
parent.removeView(mBlurredBackgroundView);
}
mBlurredBackgroundView = null;
}
... | java | {
"resource": ""
} |
q159158 | RenderScriptBlurHelper.doBlur | train | public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap, Context context) {
Bitmap bitmap;
if (canReuseInBitmap) {
bitmap = sentBitmap;
} else {
bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
}
if (bitmap.getConfig() ... | java | {
"resource": ""
} |
q159159 | SampleActivity.setUpView | train | private void setUpView() {
mBlurRadiusSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mBlurRadiusTextView.setText(mBlurPrefix + progress);
}
... | java | {
"resource": ""
} |
q159160 | EventDispatcherBase.checkRunningListenersAndStartIfPossible | train | private void checkRunningListenersAndStartIfPossible(DispatchQueueSelector queueSelector) {
synchronized (queuedListenerTasks) {
// if either
// - running for object-independent tasks or
// - running for object-dependent tasks, but queue is empty or not present
Qu... | java | {
"resource": ""
} |
q159161 | EventDispatcherBase.getThreadType | train | private String getThreadType(DispatchQueueSelector queueSelector) {
String threadType;
if (queueSelector instanceof DiscordApi) {
threadType = "a global listener thread";
} else if (queueSelector == null) {
threadType = "a connection listener thread";
} else {
... | java | {
"resource": ""
} |
q159162 | ServerUpdater.setNickname | train | public ServerUpdater setNickname(User user, String nickname) {
delegate.setNickname(user, nickname);
return this;
} | java | {
"resource": ""
} |
q159163 | ServerUpdater.setVoiceChannel | train | public ServerUpdater setVoiceChannel(User user, ServerVoiceChannel channel) {
delegate.setVoiceChannel(user, channel);
return this;
} | java | {
"resource": ""
} |
q159164 | ServerUpdater.addRoleToUser | train | public ServerUpdater addRoleToUser(User user, Role role) {
delegate.addRoleToUser(user, role);
return this;
} | java | {
"resource": ""
} |
q159165 | ServerUpdater.addRolesToUser | train | public ServerUpdater addRolesToUser(User user, Collection<Role> roles) {
delegate.addRolesToUser(user, roles);
return this;
} | java | {
"resource": ""
} |
q159166 | ServerUpdater.removeRoleFromUser | train | public ServerUpdater removeRoleFromUser(User user, Role role) {
delegate.removeRoleFromUser(user, role);
return this;
} | java | {
"resource": ""
} |
q159167 | ServerUpdater.removeRolesFromUser | train | public ServerUpdater removeRolesFromUser(User user, Collection<Role> roles) {
delegate.removeRolesFromUser(user, roles);
return this;
} | java | {
"resource": ""
} |
q159168 | ServerChannelUpdaterDelegateImpl.populatePermissionOverwrites | train | private void populatePermissionOverwrites() {
if (overwrittenUserPermissions == null) {
overwrittenUserPermissions = new HashMap<>();
overwrittenUserPermissions.putAll(((ServerChannelImpl) channel).getInternalOverwrittenUserPermissions());
}
if (overwrittenRolePermissions... | java | {
"resource": ""
} |
q159169 | UserImpl.setChannel | train | public void setChannel(PrivateChannel channel) {
if (this.channel != channel) {
if (this.channel != null) {
((Cleanupable) this.channel).cleanup();
}
this.channel = channel;
}
} | java | {
"resource": ""
} |
q159170 | UserImpl.getOrCreateChannel | train | public PrivateChannel getOrCreateChannel(JsonNode data) {
synchronized (this) {
if (channel != null) {
return channel;
}
return new PrivateChannelImpl(api, data);
}
} | java | {
"resource": ""
} |
q159171 | UserImpl.getAvatar | train | public static Icon getAvatar(DiscordApi api, String avatarHash, String discriminator, long userId) {
StringBuilder url = new StringBuilder("https://cdn.discordapp.com/");
if (avatarHash == null) {
url.append("embed/avatars/")
.append(Integer.parseInt(discriminator) % 5)
... | java | {
"resource": ""
} |
q159172 | MessageSetImpl.getMessages | train | private static CompletableFuture<MessageSet> getMessages(TextChannel channel, int limit, long before, long after) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
// get the initial ... | java | {
"resource": ""
} |
q159173 | MessageSetImpl.getMessagesAsStream | train | private static Stream<Message> getMessagesAsStream(TextChannel channel, long before, long after) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new Iterator<Message>() {
private final DiscordApiImpl api = ((DiscordApiImpl) channel.getApi());
// before was set or both w... | java | {
"resource": ""
} |
q159174 | MessageSetImpl.getMessagesBefore | train | public static CompletableFuture<MessageSet> getMessagesBefore(TextChannel channel, int limit, long before) {
return getMessages(channel, limit, before, -1);
} | java | {
"resource": ""
} |
q159175 | MessageSetImpl.getMessagesBeforeUntil | train | public static CompletableFuture<MessageSet> getMessagesBeforeUntil(
TextChannel channel, Predicate<Message> condition, long before) {
return getMessagesUntil(channel, condition, before, -1);
} | java | {
"resource": ""
} |
q159176 | MessageSetImpl.getMessagesBeforeWhile | train | public static CompletableFuture<MessageSet> getMessagesBeforeWhile(
TextChannel channel, Predicate<Message> condition, long before) {
return getMessagesWhile(channel, condition, before, -1);
} | java | {
"resource": ""
} |
q159177 | MessageSetImpl.getMessagesAfter | train | public static CompletableFuture<MessageSet> getMessagesAfter(TextChannel channel, int limit, long after) {
return getMessages(channel, limit, -1, after);
} | java | {
"resource": ""
} |
q159178 | MessageSetImpl.getMessagesAround | train | public static CompletableFuture<MessageSet> getMessagesAround(TextChannel channel, int limit, long around) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
// calculate the half limi... | java | {
"resource": ""
} |
q159179 | MessageSetImpl.getMessagesAroundUntil | train | public static CompletableFuture<MessageSet> getMessagesAroundUntil(
TextChannel channel, Predicate<Message> condition, long around) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
... | java | {
"resource": ""
} |
q159180 | MessageSetImpl.getMessagesAroundWhile | train | public static CompletableFuture<MessageSet> getMessagesAroundWhile(
TextChannel channel, Predicate<Message> condition, long around) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
... | java | {
"resource": ""
} |
q159181 | MessageSetImpl.getMessagesBetween | train | public static CompletableFuture<MessageSet> getMessagesBetween(TextChannel channel, long from, long to) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
future.complete(new MessageSe... | java | {
"resource": ""
} |
q159182 | MessageSetImpl.getMessagesBetweenAsStream | train | public static Stream<Message> getMessagesBetweenAsStream(TextChannel channel, long from, long to) {
long before = Math.max(from, to);
long after = Math.min(from, to);
Stream<Message> messages = getMessagesAsStream(channel, -1, after).filter(message -> message.getId() < before);
return (f... | java | {
"resource": ""
} |
q159183 | MessageSetImpl.requestAsSortedJsonNodes | train | private static List<JsonNode> requestAsSortedJsonNodes(
TextChannel channel, int limit, long before, long after, boolean reversed) {
List<JsonNode> messageJsonNodes = requestAsJsonNodes(channel, limit, before, after);
Comparator<JsonNode> idComparator = Comparator.comparingLong(jsonNode -> j... | java | {
"resource": ""
} |
q159184 | TrustAllTrustManager.createSslSocketFactory | train | public SSLSocketFactory createSslSocketFactory() {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{this}, null);
return sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException | KeyManagementException e) {... | java | {
"resource": ""
} |
q159185 | DiscordApiBuilderDelegateImpl.prepareListeners | train | @SuppressWarnings("unchecked")
private void prepareListeners() {
if (preparedListeners != null && preparedUnspecifiedListeners != null) {
// Already created, skip
return;
}
preparedListeners = new ConcurrentHashMap<>();
Stream<Class<? extends GloballyAttachabl... | java | {
"resource": ""
} |
q159186 | ServerChangeSplashEventImpl.getSplash | train | private Optional<Icon> getSplash(String splashHash) {
if (splashHash == null) {
return Optional.empty();
}
try {
return Optional.of(new IconImpl(getApi(),
new URL("https://cdn.discordapp.com/splashs/" + getServer().getIdAsString... | java | {
"resource": ""
} |
q159187 | ThreadPoolImpl.shutdown | train | public void shutdown() {
executorService.shutdown();
scheduler.shutdown();
daemonScheduler.shutdown();
executorServiceSingleThreads.values().forEach(ExecutorService::shutdown);
} | java | {
"resource": ""
} |
q159188 | MessageBuilder.fromMessage | train | public static MessageBuilder fromMessage(Message message) {
MessageBuilder builder = new MessageBuilder();
builder.getStringBuilder().append(message.getContent());
if (!message.getEmbeds().isEmpty()) {
builder.setEmbed(message.getEmbeds().get(0).toBuilder());
}
for (M... | java | {
"resource": ""
} |
q159189 | MessageBuilder.appendCode | train | public MessageBuilder appendCode(String language, String code) {
delegate.appendCode(language, code);
return this;
} | java | {
"resource": ""
} |
q159190 | MessageBuilder.append | train | public MessageBuilder append(String message, MessageDecoration... decorations) {
delegate.append(message, decorations);
return this;
} | java | {
"resource": ""
} |
q159191 | MessageBuilder.addAttachment | train | public MessageBuilder addAttachment(BufferedImage image, String fileName) {
delegate.addAttachment(image, fileName);
return this;
} | java | {
"resource": ""
} |
q159192 | MessageBuilder.addAttachmentAsSpoiler | train | public MessageBuilder addAttachmentAsSpoiler(InputStream stream, String fileName) {
delegate.addAttachment(stream, "SPOILER_" + fileName);
return this;
} | java | {
"resource": ""
} |
q159193 | MessageImpl.addReaction | train | public void addReaction(Emoji emoji, boolean you) {
Optional<Reaction> reaction = reactions.stream().filter(r -> emoji.equalsEmoji(r.getEmoji())).findAny();
reaction.ifPresent(r -> ((ReactionImpl) r).incrementCount(you));
if (!reaction.isPresent()) {
reactions.add(new ReactionImpl(th... | java | {
"resource": ""
} |
q159194 | MessageImpl.removeReaction | train | public void removeReaction(Emoji emoji, boolean you) {
Optional<Reaction> reaction = reactions.stream().filter(r -> emoji.equalsEmoji(r.getEmoji())).findAny();
reaction.ifPresent(r -> ((ReactionImpl) r).decrementCount(you));
reactions.removeIf(r -> r.getCount() <= 0);
} | java | {
"resource": ""
} |
q159195 | ClassHelper.getInterfaces | train | public static List<Class<?>> getInterfaces(Class<?> clazz) {
return getInterfacesAsStream(clazz).collect(Collectors.toList());
} | java | {
"resource": ""
} |
q159196 | ClassHelper.getInterfacesAsStream | train | public static Stream<Class<?>> getInterfacesAsStream(Class<?> clazz) {
return getSuperclassesAsStream(clazz, true)
.flatMap(superClass -> Stream.concat(
superClass.isInterface() ? Stream.of(superClass) : Stream.empty(),
Arrays.stream(superClass.get... | java | {
"resource": ""
} |
q159197 | ClassHelper.getSuperclasses | train | public static List<Class<?>> getSuperclasses(Class<?> clazz) {
return getSuperclassesAsStream(clazz).collect(Collectors.toList());
} | java | {
"resource": ""
} |
q159198 | MessageCacheImpl.clean | train | public void clean() {
Instant minAge = Instant.now().minus(storageTimeInSeconds, ChronoUnit.SECONDS);
synchronized (messages) {
messages.removeIf(messageRef -> Optional.ofNullable(messageRef.get())
.map(message -> !message.isCachedForever() && message.getCreationTimestamp... | java | {
"resource": ""
} |
q159199 | EmbedBuilderDelegateImpl.getRequiredAttachments | train | public List<FileContainer> getRequiredAttachments() {
List<FileContainer> requiredAttachments = new ArrayList<>();
if (footerIconContainer != null) {
requiredAttachments.add(footerIconContainer);
}
if (imageContainer != null) {
requiredAttachments.add(imageContain... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.