repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java
EagerFutureStreamFunctions.firstOf
@SafeVarargs public static <U> SimpleReactStream<U> firstOf(final SimpleReactStream<U>... futureStreams) { final List<Tuple2<SimpleReactStream<U>, QueueReader>> racers = Stream.of(futureStreams) .map(s -> Tuple.tuple(s, new Queue.QueueReader( s.toQueue(), null))) .collect(Collectors.toList()); while (true) { for (final Tuple2<SimpleReactStream<U>, Queue.QueueReader> q : racers) { if (q._2().notEmpty()) { EagerFutureStreamFunctions.closeOthers(q._2().getQueue(), racers.stream() .map(t -> t._2().getQueue()) .collect(Collectors.toList())); closeOthers(q._1(), racers.stream() .map(t -> t._1()) .collect(Collectors.toList())); return q._1().fromStream(q._2().getQueue() .stream(q._1().getSubscription())); } } LockSupport.parkNanos(1l); } }
java
@SafeVarargs public static <U> SimpleReactStream<U> firstOf(final SimpleReactStream<U>... futureStreams) { final List<Tuple2<SimpleReactStream<U>, QueueReader>> racers = Stream.of(futureStreams) .map(s -> Tuple.tuple(s, new Queue.QueueReader( s.toQueue(), null))) .collect(Collectors.toList()); while (true) { for (final Tuple2<SimpleReactStream<U>, Queue.QueueReader> q : racers) { if (q._2().notEmpty()) { EagerFutureStreamFunctions.closeOthers(q._2().getQueue(), racers.stream() .map(t -> t._2().getQueue()) .collect(Collectors.toList())); closeOthers(q._1(), racers.stream() .map(t -> t._1()) .collect(Collectors.toList())); return q._1().fromStream(q._2().getQueue() .stream(q._1().getSubscription())); } } LockSupport.parkNanos(1l); } }
[ "@", "SafeVarargs", "public", "static", "<", "U", ">", "SimpleReactStream", "<", "U", ">", "firstOf", "(", "final", "SimpleReactStream", "<", "U", ">", "...", "futureStreams", ")", "{", "final", "List", "<", "Tuple2", "<", "SimpleReactStream", "<", "U", ">...
Return first Stream out of provided Streams that starts emitted results @param futureStreams Streams to race @return First Stream to skip emitting values
[ "Return", "first", "Stream", "out", "of", "provided", "Streams", "that", "starts", "emitted", "results" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java#L59-L82
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java
StreamSource.ofMultiple
public static <T> MultipleStreamSource<T> ofMultiple(final QueueFactory<?> q) { Objects.requireNonNull(q); return new MultipleStreamSource<T>( StreamSource.of(q) .createQueue()); }
java
public static <T> MultipleStreamSource<T> ofMultiple(final QueueFactory<?> q) { Objects.requireNonNull(q); return new MultipleStreamSource<T>( StreamSource.of(q) .createQueue()); }
[ "public", "static", "<", "T", ">", "MultipleStreamSource", "<", "T", ">", "ofMultiple", "(", "final", "QueueFactory", "<", "?", ">", "q", ")", "{", "Objects", ".", "requireNonNull", "(", "q", ")", ";", "return", "new", "MultipleStreamSource", "<", "T", "...
Construct a StreamSource that supports multiple readers of the same data backed by a Queue created from the supplied QueueFactory @see QueueFactories for Factory creation options and various backpressure strategies <pre> {@code MultipleStreamSource<Integer> multi = StreamSource .ofMultiple(QueueFactories.boundedQueue(100)); FutureStream<Integer> pushable = multi.futureStream(new LazyReact()); ReactiveSeq<Integer> seq = multi.reactiveSeq(); multi.getInput().offer(100); multi.getInput().close(); pushable.collect(CyclopsCollectors.toList()); //[100] seq.collect(CyclopsCollectors.toList()); //[100] } </pre> @param q QueueFactory used to create the Adapter to back the pushable StreamSource @return a builder that will use Topics to allow multiple Streams from the same data
[ "Construct", "a", "StreamSource", "that", "supports", "multiple", "readers", "of", "the", "same", "data", "backed", "by", "a", "Queue", "created", "from", "the", "supplied", "QueueFactory" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java#L281-L286
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java
StreamSource.futureStream
public <T> PushableFutureStream<T> futureStream(final LazyReact s) { final Queue<T> q = createQueue(); return new PushableFutureStream<T>( q, s.fromStream(q.stream())); }
java
public <T> PushableFutureStream<T> futureStream(final LazyReact s) { final Queue<T> q = createQueue(); return new PushableFutureStream<T>( q, s.fromStream(q.stream())); }
[ "public", "<", "T", ">", "PushableFutureStream", "<", "T", ">", "futureStream", "(", "final", "LazyReact", "s", ")", "{", "final", "Queue", "<", "T", ">", "q", "=", "createQueue", "(", ")", ";", "return", "new", "PushableFutureStream", "<", "T", ">", "...
Create a pushable FutureStream using the supplied ReactPool <pre> {@code PushableFutureStream<Integer> pushable = StreamSource.ofUnbounded() .futureStream(new LazyReact()); pushable.getInput().add(100); pushable.getInput().close(); assertThat(pushable.getStream().collect(CyclopsCollectors.toList()), hasItem(100)); }</pre> @param s ReactPool to use to create the Stream @return a Tuple2 with a Queue&lt;T&gt; and LazyFutureStream&lt;T&gt; - add data to the Queue to push it to the Stream
[ "Create", "a", "pushable", "FutureStream", "using", "the", "supplied", "ReactPool" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java#L438-L444
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java
StreamSource.stream
public <T> PushableStream<T> stream() { final Queue<T> q = createQueue(); return new PushableStream<T>( q, q.jdkStream()); }
java
public <T> PushableStream<T> stream() { final Queue<T> q = createQueue(); return new PushableStream<T>( q, q.jdkStream()); }
[ "public", "<", "T", ">", "PushableStream", "<", "T", ">", "stream", "(", ")", "{", "final", "Queue", "<", "T", ">", "q", "=", "createQueue", "(", ")", ";", "return", "new", "PushableStream", "<", "T", ">", "(", "q", ",", "q", ".", "jdkStream", "(...
Create a pushable JDK 8 Stream <pre> {@code PushableStream<Integer> pushable = StreamSource.ofUnbounded() .stream(); pushable.getInput() .add(10); pushable.getInput() .close(); pushable.getStream().collect(CyclopsCollectors.toList()) //[10] } </pre> @return PushableStream that can accept data to push into a Java 8 Stream to push it to the Stream
[ "Create", "a", "pushable", "JDK", "8", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/stream/StreamSource.java#L495-L500
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.softenRunnable
public static Runnable softenRunnable(final CheckedRunnable s) { return () -> { try { s.run(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
java
public static Runnable softenRunnable(final CheckedRunnable s) { return () -> { try { s.run(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
[ "public", "static", "Runnable", "softenRunnable", "(", "final", "CheckedRunnable", "s", ")", "{", "return", "(", ")", "->", "{", "try", "{", "s", ".", "run", "(", ")", ";", "}", "catch", "(", "final", "Throwable", "e", ")", "{", "throw", "throwSoftened...
Soften a Runnable that throws a ChecekdException into a plain old Runnable <pre> {@code Runnable runnable = ExceptionSoftener.softenRunnable(this::run); runnable.run() //thows IOException but doesn't need to declare it private void run() throws IOException{ throw new IOException(); } ExceptionSoftener.softenRunnable(()->Thread.sleep(1000)); } </pre> @param s Supplier with CheckedException @return Supplier that throws the same exception, but doesn't need to declare it as a checked Exception
[ "Soften", "a", "Runnable", "that", "throws", "a", "ChecekdException", "into", "a", "plain", "old", "Runnable" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L79-L87
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.softenSupplier
public static <T> Supplier<T> softenSupplier(final CheckedSupplier<T> s) { return () -> { try { return s.get(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
java
public static <T> Supplier<T> softenSupplier(final CheckedSupplier<T> s) { return () -> { try { return s.get(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
[ "public", "static", "<", "T", ">", "Supplier", "<", "T", ">", "softenSupplier", "(", "final", "CheckedSupplier", "<", "T", ">", "s", ")", "{", "return", "(", ")", "->", "{", "try", "{", "return", "s", ".", "get", "(", ")", ";", "}", "catch", "(",...
Soften a Supplier that throws a ChecekdException into a plain old Supplier <pre> {@code Supplier<String> supplier = ExceptionSoftener.softenSupplier(this::getValue); supplier.getValue(); //thows IOException but doesn't need to declare it private String getValue() throws IOException{ return "hello"; } } </pre> @param s Supplier with CheckedException @return Supplier that throws the same exception, but doesn't need to declare it as a checked Exception
[ "Soften", "a", "Supplier", "that", "throws", "a", "ChecekdException", "into", "a", "plain", "old", "Supplier" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L110-L118
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.softenCallable
public static <T> Supplier<T> softenCallable(final Callable<T> s) { return () -> { try { return s.call(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
java
public static <T> Supplier<T> softenCallable(final Callable<T> s) { return () -> { try { return s.call(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
[ "public", "static", "<", "T", ">", "Supplier", "<", "T", ">", "softenCallable", "(", "final", "Callable", "<", "T", ">", "s", ")", "{", "return", "(", ")", "->", "{", "try", "{", "return", "s", ".", "call", "(", ")", ";", "}", "catch", "(", "fi...
Soften a Callable that throws a ChecekdException into a Supplier <pre> {@code Supplier<String> supplier = ExceptionSoftener.softenCallable(this); supplier.getValue(); //thows IOException but doesn't need to declare it public String call() throws IOException{ return "hello"; } } </pre> @param s Callable with CheckedException @return Supplier that throws the same exception, but doesn't need to declare it as a checked Exception
[ "Soften", "a", "Callable", "that", "throws", "a", "ChecekdException", "into", "a", "Supplier" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L141-L149
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.softenBooleanSupplier
public static BooleanSupplier softenBooleanSupplier(final CheckedBooleanSupplier s) { return () -> { try { return s.getAsBoolean(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
java
public static BooleanSupplier softenBooleanSupplier(final CheckedBooleanSupplier s) { return () -> { try { return s.getAsBoolean(); } catch (final Throwable e) { throw throwSoftenedException(e); } }; }
[ "public", "static", "BooleanSupplier", "softenBooleanSupplier", "(", "final", "CheckedBooleanSupplier", "s", ")", "{", "return", "(", ")", "->", "{", "try", "{", "return", "s", ".", "getAsBoolean", "(", ")", ";", "}", "catch", "(", "final", "Throwable", "e",...
Soften a BooleanSuppler that throws a checked exception into one that still throws the exception, but doesn't need to declare it. <pre> {@code assertThat(ExceptionSoftener.softenBooleanSupplier(()->true).getAsBoolean(),equalTo(true)); BooleanSupplier supplier = ExceptionSoftener.softenBooleanSupplier(()->{throw new IOException();}); supplier.getValue() //throws IOException but doesn't need to declare it } </pre> @param s CheckedBooleanSupplier to soften @return Plain old BooleanSupplier
[ "Soften", "a", "BooleanSuppler", "that", "throws", "a", "checked", "exception", "into", "one", "that", "still", "throws", "the", "exception", "but", "doesn", "t", "need", "to", "declare", "it", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L170-L178
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.throwIf
public static <X extends Throwable> void throwIf(final X e, final Predicate<X> p) { if (p.test(e)) throw ExceptionSoftener.<RuntimeException> uncheck(e); }
java
public static <X extends Throwable> void throwIf(final X e, final Predicate<X> p) { if (p.test(e)) throw ExceptionSoftener.<RuntimeException> uncheck(e); }
[ "public", "static", "<", "X", "extends", "Throwable", ">", "void", "throwIf", "(", "final", "X", "e", ",", "final", "Predicate", "<", "X", ">", "p", ")", "{", "if", "(", "p", ".", "test", "(", "e", ")", ")", "throw", "ExceptionSoftener", ".", "<", ...
Throw the exception as upwards if the predicate holds, otherwise do nothing @param e Exception @param p Predicate to check exception should be thrown or not
[ "Throw", "the", "exception", "as", "upwards", "if", "the", "predicate", "holds", "otherwise", "do", "nothing" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L680-L683
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java
ExceptionSoftener.throwOrHandle
public static <X extends Throwable> void throwOrHandle(final X e, final Predicate<X> p, final Consumer<X> handler) { if (p.test(e)) throw ExceptionSoftener.<RuntimeException> uncheck(e); else handler.accept(e); }
java
public static <X extends Throwable> void throwOrHandle(final X e, final Predicate<X> p, final Consumer<X> handler) { if (p.test(e)) throw ExceptionSoftener.<RuntimeException> uncheck(e); else handler.accept(e); }
[ "public", "static", "<", "X", "extends", "Throwable", ">", "void", "throwOrHandle", "(", "final", "X", "e", ",", "final", "Predicate", "<", "X", ">", "p", ",", "final", "Consumer", "<", "X", ">", "handler", ")", "{", "if", "(", "p", ".", "test", "(...
Throw the exception as upwards if the predicate holds, otherwise pass to the handler @param e Exception @param p Predicate to check exception should be thrown or not @param handler Handles exceptions that should not be thrown
[ "Throw", "the", "exception", "as", "upwards", "if", "the", "predicate", "holds", "otherwise", "pass", "to", "the", "handler" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/ExceptionSoftener.java#L692-L697
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Optionals.java
Optionals.forEach2
public static <T, R1, R> Optional<R> forEach2(Optional<? extends T> value1, Function<? super T, Optional<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { return value1.flatMap(in -> { Optional<R1> a = value2.apply(in); return a.map(in2 -> yieldingFunction.apply(in, in2)); }); }
java
public static <T, R1, R> Optional<R> forEach2(Optional<? extends T> value1, Function<? super T, Optional<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { return value1.flatMap(in -> { Optional<R1> a = value2.apply(in); return a.map(in2 -> yieldingFunction.apply(in, in2)); }); }
[ "public", "static", "<", "T", ",", "R1", ",", "R", ">", "Optional", "<", "R", ">", "forEach2", "(", "Optional", "<", "?", "extends", "T", ">", "value1", ",", "Function", "<", "?", "super", "T", ",", "Optional", "<", "R1", ">", ">", "value2", ",",...
Perform a For Comprehension over a Optional, accepting a generating function. This results in a two level nested internal iteration over the provided Optionals. <pre> {@code import static com.oath.cyclops.reactor.Optionals.forEach; forEach(Optional.just(1), a-> Optional.just(a+1), Tuple::tuple) } </pre> @param value1 top level Optional @param value2 Nested Optional @param yieldingFunction Generates a result per combination @return Optional with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "Optional", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "Optionals", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Optionals.java#L267-L278
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/async/adapters/Topic.java
Topic.disconnect
@Synchronized("lock") public void disconnect(final ReactiveSeq<T> stream) { Option<Queue<T>> o = streamToQueue.get(stream); distributor.removeQueue(streamToQueue.getOrElse(stream, new Queue<>())); this.streamToQueue = streamToQueue.remove(stream); this.index--; }
java
@Synchronized("lock") public void disconnect(final ReactiveSeq<T> stream) { Option<Queue<T>> o = streamToQueue.get(stream); distributor.removeQueue(streamToQueue.getOrElse(stream, new Queue<>())); this.streamToQueue = streamToQueue.remove(stream); this.index--; }
[ "@", "Synchronized", "(", "\"lock\"", ")", "public", "void", "disconnect", "(", "final", "ReactiveSeq", "<", "T", ">", "stream", ")", "{", "Option", "<", "Queue", "<", "T", ">>", "o", "=", "streamToQueue", ".", "get", "(", "stream", ")", ";", "distribu...
Topic will maintain a queue for each Subscribing Stream If a Stream is finished with a Topic it is good practice to disconnect from the Topic so messages will no longer be stored for that Stream @param stream
[ "Topic", "will", "maintain", "a", "queue", "for", "each", "Subscribing", "Stream", "If", "a", "Stream", "is", "finished", "with", "a", "Topic", "it", "is", "good", "practice", "to", "disconnect", "from", "the", "Topic", "so", "messages", "will", "no", "lon...
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/async/adapters/Topic.java#L71-L79
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.narrowK
public static <T> Future<T> narrowK(final Higher<future, T> future) { return (Future<T>)future; }
java
public static <T> Future<T> narrowK(final Higher<future, T> future) { return (Future<T>)future; }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "narrowK", "(", "final", "Higher", "<", "future", ",", "T", ">", "future", ")", "{", "return", "(", "Future", "<", "T", ">", ")", "future", ";", "}" ]
Convert the raw Higher Kinded Type for FutureType types into the FutureType type definition class @param future HKT encoded list into a FutureType @return FutureType
[ "Convert", "the", "raw", "Higher", "Kinded", "Type", "for", "FutureType", "types", "into", "the", "FutureType", "type", "definition", "class" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L140-L142
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.anyOf
public static <T> Future<T> anyOf(Future<T>... fts) { CompletableFuture<T>[] array = new CompletableFuture[fts.length]; for(int i=0;i<fts.length;i++){ array[i] = fts[i].getFuture(); } return (Future<T>) Future.of(CompletableFuture.anyOf(array)); }
java
public static <T> Future<T> anyOf(Future<T>... fts) { CompletableFuture<T>[] array = new CompletableFuture[fts.length]; for(int i=0;i<fts.length;i++){ array[i] = fts[i].getFuture(); } return (Future<T>) Future.of(CompletableFuture.anyOf(array)); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "anyOf", "(", "Future", "<", "T", ">", "...", "fts", ")", "{", "CompletableFuture", "<", "T", ">", "[", "]", "array", "=", "new", "CompletableFuture", "[", "fts", ".", "length", "]", ";", ...
Select the first Future to complete @see CompletableFuture#anyOf(CompletableFuture...) @param fts Futures to race @return First Future to complete
[ "Select", "the", "first", "Future", "to", "complete" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L170-L177
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.fromPublisher
public static <T> Future<T> fromPublisher(final Publisher<T> pub, final Executor ex) { final ValueSubscriber<T> sub = ValueSubscriber.subscriber(); pub.subscribe(sub); return sub.toFutureAsync(ex); }
java
public static <T> Future<T> fromPublisher(final Publisher<T> pub, final Executor ex) { final ValueSubscriber<T> sub = ValueSubscriber.subscriber(); pub.subscribe(sub); return sub.toFutureAsync(ex); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "fromPublisher", "(", "final", "Publisher", "<", "T", ">", "pub", ",", "final", "Executor", "ex", ")", "{", "final", "ValueSubscriber", "<", "T", ">", "sub", "=", "ValueSubscriber", ".", "subs...
Construct a Future asynchronously that contains a single value extracted from the supplied reactive-streams Publisher <pre> {@code ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3); Future<Integer> future = Future.fromPublisher(stream,ex); Future[1] } </pre> @param pub Publisher to extract value from @param ex Executor to extract value on @return Future populated asyncrhonously from Publisher
[ "Construct", "a", "Future", "asynchronously", "that", "contains", "a", "single", "value", "extracted", "from", "the", "supplied", "reactive", "-", "streams", "Publisher" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L251-L255
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.fromIterable
public static <T> Future<T> fromIterable(final Iterable<T> iterable) { if(iterable instanceof Future){ return (Future)iterable; } return Future.ofResult(Eval.fromIterable(iterable)) .map(e -> e.get()); }
java
public static <T> Future<T> fromIterable(final Iterable<T> iterable) { if(iterable instanceof Future){ return (Future)iterable; } return Future.ofResult(Eval.fromIterable(iterable)) .map(e -> e.get()); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "fromIterable", "(", "final", "Iterable", "<", "T", ">", "iterable", ")", "{", "if", "(", "iterable", "instanceof", "Future", ")", "{", "return", "(", "Future", ")", "iterable", ";", "}", "r...
Construct a Future syncrhonously that contains a single value extracted from the supplied Iterable <pre> {@code ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3); Future<Integer> future = Future.fromIterable(stream); Future[1] } </pre> @param iterable Iterable to extract value from @return Future populated syncrhonously from Iterable
[ "Construct", "a", "Future", "syncrhonously", "that", "contains", "a", "single", "value", "extracted", "from", "the", "supplied", "Iterable" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L344-L350
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.fromTry
public static <T, X extends Throwable> Future<T> fromTry(final Try<T, X> value) { return value.fold(s->Future.ofResult(s), e->Future.<T>of(CompletableFutures.error(e))); }
java
public static <T, X extends Throwable> Future<T> fromTry(final Try<T, X> value) { return value.fold(s->Future.ofResult(s), e->Future.<T>of(CompletableFutures.error(e))); }
[ "public", "static", "<", "T", ",", "X", "extends", "Throwable", ">", "Future", "<", "T", ">", "fromTry", "(", "final", "Try", "<", "T", ",", "X", ">", "value", ")", "{", "return", "value", ".", "fold", "(", "s", "->", "Future", ".", "ofResult", "...
Construct a Future syncrhonously from the Supplied Try @param value Try to populate Future from @return Future populated with lazy the value or error in provided Try
[ "Construct", "a", "Future", "syncrhonously", "from", "the", "Supplied", "Try" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L394-L397
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.sequence
public static <T> Future<ReactiveSeq<T>> sequence(final Stream<? extends Future<T>> fts) { return sequence(ReactiveSeq.fromStream(fts)); }
java
public static <T> Future<ReactiveSeq<T>> sequence(final Stream<? extends Future<T>> fts) { return sequence(ReactiveSeq.fromStream(fts)); }
[ "public", "static", "<", "T", ">", "Future", "<", "ReactiveSeq", "<", "T", ">", ">", "sequence", "(", "final", "Stream", "<", "?", "extends", "Future", "<", "T", ">", ">", "fts", ")", "{", "return", "sequence", "(", "ReactiveSeq", ".", "fromStream", ...
Sequence operation that convert a Stream of Futures to a Future with a Stream <pre> {@code Future<Integer> just = Future.ofResult(10); Future<ReactiveSeq<Integer>> futures =Future.sequence(Stream.of(just,Future.ofResult(1))); Seq.of(10,1) } </pre> @param fts Strean of Futures to Sequence into a Future with a Stream @return Future with a Stream
[ "Sequence", "operation", "that", "convert", "a", "Stream", "of", "Futures", "to", "a", "Future", "with", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L509-L511
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.visitAsync
@Deprecated //use foldAsync public <R> Future<R> visitAsync(Function<? super T,? extends R> success, Function<? super Throwable,? extends R> failure){ return foldAsync(success,failure); }
java
@Deprecated //use foldAsync public <R> Future<R> visitAsync(Function<? super T,? extends R> success, Function<? super Throwable,? extends R> failure){ return foldAsync(success,failure); }
[ "@", "Deprecated", "//use foldAsync", "public", "<", "R", ">", "Future", "<", "R", ">", "visitAsync", "(", "Function", "<", "?", "super", "T", ",", "?", "extends", "R", ">", "success", ",", "Function", "<", "?", "super", "Throwable", ",", "?", "extends...
Non-blocking visit on the state of this Future <pre> {@code Future.ofResult(10) .visitAsync(i->i*2, e->-1); Future[20] Future.<Integer>ofError(new RuntimeException()) .visitAsync(i->i*2, e->-1) Future[-1] } </pre> @param success Function to execute if the previous stage completes successfully @param failure Function to execute if this Future fails @return Future with the eventual result of the executed Function
[ "Non", "-", "blocking", "visit", "on", "the", "state", "of", "this", "Future" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L761-L764
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.fold
public <R> R fold(Function<? super T,? extends R> success, Function<? super Throwable,? extends R> failure){ try { return success.apply(future.join()); }catch(Throwable t){ return failure.apply(t); } }
java
public <R> R fold(Function<? super T,? extends R> success, Function<? super Throwable,? extends R> failure){ try { return success.apply(future.join()); }catch(Throwable t){ return failure.apply(t); } }
[ "public", "<", "R", ">", "R", "fold", "(", "Function", "<", "?", "super", "T", ",", "?", "extends", "R", ">", "success", ",", "Function", "<", "?", "super", "Throwable", ",", "?", "extends", "R", ">", "failure", ")", "{", "try", "{", "return", "s...
Blocking analogue to visitAsync. Visit the state of this Future, block until ready. <pre> {@code Future.ofResult(10) .visit(i->i*2, e->-1); 20 Future.<Integer>ofError(new RuntimeException()) .visit(i->i*2, e->-1) [-1] } </pre> @param success Function to execute if the previous stage completes successfully @param failure Function to execute if this Future fails @return Result of the executed Function
[ "Blocking", "analogue", "to", "visitAsync", ".", "Visit", "the", "state", "of", "this", "Future", "block", "until", "ready", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L788-L795
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.map
public <R> Future<R> map(final Function<? super T, ? extends R> fn, Executor ex) { return new Future<R>( future.thenApplyAsync(fn,ex)); }
java
public <R> Future<R> map(final Function<? super T, ? extends R> fn, Executor ex) { return new Future<R>( future.thenApplyAsync(fn,ex)); }
[ "public", "<", "R", ">", "Future", "<", "R", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "R", ">", "fn", ",", "Executor", "ex", ")", "{", "return", "new", "Future", "<", "R", ">", "(", "future", ".", "then...
Asyncrhonous transform operation @see CompletableFuture#thenApplyAsync(Function, Executor) @param fn Transformation function @param ex Executor to execute the transformation asynchronously @return Mapped Future
[ "Asyncrhonous", "transform", "operation" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L819-L822
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.flatMapCf
public <R> Future<R> flatMapCf(final Function<? super T, ? extends CompletionStage<? extends R>> mapper) { return Future.<R> of(future.<R> thenCompose(t -> (CompletionStage<R>) mapper.apply(t))); }
java
public <R> Future<R> flatMapCf(final Function<? super T, ? extends CompletionStage<? extends R>> mapper) { return Future.<R> of(future.<R> thenCompose(t -> (CompletionStage<R>) mapper.apply(t))); }
[ "public", "<", "R", ">", "Future", "<", "R", ">", "flatMapCf", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "CompletionStage", "<", "?", "extends", "R", ">", ">", "mapper", ")", "{", "return", "Future", ".", "<", "R", ">",...
A flatMap operation that accepts a CompleteableFuture CompletionStage as the return type @param mapper Mapping function @return FlatMapped Future
[ "A", "flatMap", "operation", "that", "accepts", "a", "CompleteableFuture", "CompletionStage", "as", "the", "return", "type" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L958-L960
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.recover
public Future<T> recover(final Function<? super Throwable, ? extends T> fn) { return Future.of(toCompletableFuture().exceptionally((Function)fn)); }
java
public Future<T> recover(final Function<? super Throwable, ? extends T> fn) { return Future.of(toCompletableFuture().exceptionally((Function)fn)); }
[ "public", "Future", "<", "T", ">", "recover", "(", "final", "Function", "<", "?", "super", "Throwable", ",", "?", "extends", "T", ">", "fn", ")", "{", "return", "Future", ".", "of", "(", "toCompletableFuture", "(", ")", ".", "exceptionally", "(", "(", ...
Returns a new Future that, when this Future completes exceptionally is executed with this Future exception as the argument to the supplied function. Otherwise, if this Future completes normally, applyHKT the returned Future also completes normally with the same value. <pre> {@code Future.ofError(new RuntimeException()) .recover(__ -> true) //Future[true] } </pre> @param fn the function to use to compute the value of the returned Future if this Future completed exceptionally @return the new Future
[ "Returns", "a", "new", "Future", "that", "when", "this", "Future", "completes", "exceptionally", "is", "executed", "with", "this", "Future", "exception", "as", "the", "argument", "to", "the", "supplied", "function", ".", "Otherwise", "if", "this", "Future", "c...
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1017-L1019
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.map
public <R> Future<R> map(final Function<? super T, R> success, final Function<Throwable, R> failure) { return Future.of(future.thenApply(success) .exceptionally(failure)); }
java
public <R> Future<R> map(final Function<? super T, R> success, final Function<Throwable, R> failure) { return Future.of(future.thenApply(success) .exceptionally(failure)); }
[ "public", "<", "R", ">", "Future", "<", "R", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "R", ">", "success", ",", "final", "Function", "<", "Throwable", ",", "R", ">", "failure", ")", "{", "return", "Future", ".", "of", "(...
Map this Future differently depending on whether the previous stage completed successfully or failed <pre> {@code Future.ofResult(1) .map(i->i*2,e->-1); //Future[2] }</pre> @param success Mapping function for successful outcomes @param failure Mapping function for failed outcomes @return New Future mapped to a new state
[ "Map", "this", "Future", "differently", "depending", "on", "whether", "the", "previous", "stage", "completed", "successfully", "or", "failed" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1042-L1045
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.ofResult
public static <T> Future<T> ofResult(final T result) { return Future.of(CompletableFuture.completedFuture(result)); }
java
public static <T> Future<T> ofResult(final T result) { return Future.of(CompletableFuture.completedFuture(result)); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "ofResult", "(", "final", "T", "result", ")", "{", "return", "Future", ".", "of", "(", "CompletableFuture", ".", "completedFuture", "(", "result", ")", ")", ";", "}" ]
Construct a successfully completed Future from the given value @param result To wrap inside a Future @return Future containing supplied result
[ "Construct", "a", "successfully", "completed", "Future", "from", "the", "given", "value" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1079-L1081
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.ofError
public static <T> Future<T> ofError(final Throwable error) { final CompletableFuture<T> cf = new CompletableFuture<>(); cf.completeExceptionally(error); return Future.<T> of(cf); }
java
public static <T> Future<T> ofError(final Throwable error) { final CompletableFuture<T> cf = new CompletableFuture<>(); cf.completeExceptionally(error); return Future.<T> of(cf); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "ofError", "(", "final", "Throwable", "error", ")", "{", "final", "CompletableFuture", "<", "T", ">", "cf", "=", "new", "CompletableFuture", "<>", "(", ")", ";", "cf", ".", "completeExceptionall...
Construct a completed-with-error Future from the given Exception @param error To wrap inside a Future @return Future containing supplied error
[ "Construct", "a", "completed", "-", "with", "-", "error", "Future", "from", "the", "given", "Exception" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1090-L1095
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.of
public static <T> Future<T> of(final Supplier<T> s) { return Future.of(CompletableFuture.supplyAsync(s)); }
java
public static <T> Future<T> of(final Supplier<T> s) { return Future.of(CompletableFuture.supplyAsync(s)); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "of", "(", "final", "Supplier", "<", "T", ">", "s", ")", "{", "return", "Future", ".", "of", "(", "CompletableFuture", ".", "supplyAsync", "(", "s", ")", ")", ";", "}" ]
Create a Future object that asyncrhonously populates using the Common ForkJoinPool from the user provided Supplier @param s Supplier to asynchronously populate results from @return Future asynchronously populated from the Supplier
[ "Create", "a", "Future", "object", "that", "asyncrhonously", "populates", "using", "the", "Common", "ForkJoinPool", "from", "the", "user", "provided", "Supplier" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1203-L1205
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Future.java
Future.of
public static <T> Future<T> of(final Supplier<T> s, final Executor ex) { return Future.of(CompletableFuture.supplyAsync(s, ex)); }
java
public static <T> Future<T> of(final Supplier<T> s, final Executor ex) { return Future.of(CompletableFuture.supplyAsync(s, ex)); }
[ "public", "static", "<", "T", ">", "Future", "<", "T", ">", "of", "(", "final", "Supplier", "<", "T", ">", "s", ",", "final", "Executor", "ex", ")", "{", "return", "Future", ".", "of", "(", "CompletableFuture", ".", "supplyAsync", "(", "s", ",", "e...
Create a Future object that asyncrhonously populates using the provided Executor and Supplier @param s Supplier to asynchronously populate results from @param ex Executro to asynchronously populate results with @return Future asynchronously populated from the Supplier
[ "Create", "a", "Future", "object", "that", "asyncrhonously", "populates", "using", "the", "provided", "Executor", "and", "Supplier" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Future.java#L1217-L1219
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableFloat.java
MutableFloat.fromExternal
public static MutableFloat fromExternal(final Supplier<Float> s, final Consumer<Float> c) { return new MutableFloat() { @Override public float getAsFloat() { return s.get(); } @Override public Float get() { return getAsFloat(); } @Override public MutableFloat set(final float value) { c.accept(value); return this; } }; }
java
public static MutableFloat fromExternal(final Supplier<Float> s, final Consumer<Float> c) { return new MutableFloat() { @Override public float getAsFloat() { return s.get(); } @Override public Float get() { return getAsFloat(); } @Override public MutableFloat set(final float value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableFloat", "fromExternal", "(", "final", "Supplier", "<", "Float", ">", "s", ",", "final", "Consumer", "<", "Float", ">", "c", ")", "{", "return", "new", "MutableFloat", "(", ")", "{", "@", "Override", "public", "float", "getAsFloa...
Construct a MutableFloat that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableFloat mutable = MutableFloat.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableFloat that gets / sets an external (mutable) value
[ "Construct", "a", "MutableFloat", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableFloat.java#L80-L98
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableBoolean.java
MutableBoolean.fromExternal
public static MutableBoolean fromExternal(final BooleanSupplier s, final Consumer<Boolean> c) { return new MutableBoolean() { @Override public boolean getAsBoolean() { return s.getAsBoolean(); } @Override public Boolean get() { return getAsBoolean(); } @Override public MutableBoolean set(final boolean value) { c.accept(value); return this; } }; }
java
public static MutableBoolean fromExternal(final BooleanSupplier s, final Consumer<Boolean> c) { return new MutableBoolean() { @Override public boolean getAsBoolean() { return s.getAsBoolean(); } @Override public Boolean get() { return getAsBoolean(); } @Override public MutableBoolean set(final boolean value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableBoolean", "fromExternal", "(", "final", "BooleanSupplier", "s", ",", "final", "Consumer", "<", "Boolean", ">", "c", ")", "{", "return", "new", "MutableBoolean", "(", ")", "{", "@", "Override", "public", "boolean", "getAsBoolean", "(...
Construct a MutableBoolean that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableBoolean mutable = MutableBoolean.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableBoolean that gets / sets an external (mutable) value
[ "Construct", "a", "MutableBoolean", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableBoolean.java#L82-L100
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java
SimpleReact.fromPublisher
public <T> SimpleReactStream<T> fromPublisher(final Publisher<? extends T> publisher) { Objects.requireNonNull(publisher); Publisher<T> narrowed = (Publisher<T>)publisher; return from(Spouts.from(narrowed)); }
java
public <T> SimpleReactStream<T> fromPublisher(final Publisher<? extends T> publisher) { Objects.requireNonNull(publisher); Publisher<T> narrowed = (Publisher<T>)publisher; return from(Spouts.from(narrowed)); }
[ "public", "<", "T", ">", "SimpleReactStream", "<", "T", ">", "fromPublisher", "(", "final", "Publisher", "<", "?", "extends", "T", ">", "publisher", ")", "{", "Objects", ".", "requireNonNull", "(", "publisher", ")", ";", "Publisher", "<", "T", ">", "narr...
Construct a SimpleReactStream from an Publisher @param publisher to construct SimpleReactStream from @return SimpleReactStream
[ "Construct", "a", "SimpleReactStream", "from", "an", "Publisher" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java#L166-L170
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java
SimpleReact.parallelBuilder
public static SimpleReact parallelBuilder(final int parallelism) { return SimpleReact.builder() .executor(new ForkJoinPool( parallelism)) .async(true) .build(); }
java
public static SimpleReact parallelBuilder(final int parallelism) { return SimpleReact.builder() .executor(new ForkJoinPool( parallelism)) .async(true) .build(); }
[ "public", "static", "SimpleReact", "parallelBuilder", "(", "final", "int", "parallelism", ")", "{", "return", "SimpleReact", ".", "builder", "(", ")", ".", "executor", "(", "new", "ForkJoinPool", "(", "parallelism", ")", ")", ".", "async", "(", "true", ")", ...
Construct a new SimpleReact builder, with a new task executor and retry executor with configured number of threads @param parallelism Number of threads task executor should have @return eager SimpleReact instance
[ "Construct", "a", "new", "SimpleReact", "builder", "with", "a", "new", "task", "executor", "and", "retry", "executor", "with", "configured", "number", "of", "threads" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java#L278-L284
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java
SimpleReact.fromIterable
@SuppressWarnings("unchecked") public <U> SimpleReactStream<U> fromIterable(final Iterable<U> iter) { if(iter instanceof SimpleReactStream){ return (SimpleReactStream<U>)iter; } return this.from(StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter.iterator(), Spliterator.ORDERED), false)); }
java
@SuppressWarnings("unchecked") public <U> SimpleReactStream<U> fromIterable(final Iterable<U> iter) { if(iter instanceof SimpleReactStream){ return (SimpleReactStream<U>)iter; } return this.from(StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter.iterator(), Spliterator.ORDERED), false)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "U", ">", "SimpleReactStream", "<", "U", ">", "fromIterable", "(", "final", "Iterable", "<", "U", ">", "iter", ")", "{", "if", "(", "iter", "instanceof", "SimpleReactStream", ")", "{", "ret...
Start a reactive flow from a JDK Iterator @param iter SimpleReact will iterate over this iterator concurrently to skip the reactive dataflow @return Next stage in the reactive flow
[ "Start", "a", "reactive", "flow", "from", "a", "JDK", "Iterator" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/SimpleReact.java#L348-L355
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Unrestricted.java
Unrestricted.forEach4
public < T2, T3, R1, R2, R3> Unrestricted<R3> forEach4(Function<? super T, ? extends Unrestricted<R1>> value2, BiFunction<? super T, ? super R1, ? extends Unrestricted<R2>> value3, Function3<? super T, ? super R1, ? super R2, ? extends Unrestricted<R3>> value4 ) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a.flatMap(ina -> { Unrestricted<R2> b = value3.apply(in,ina); return b.flatMap(inb -> { Unrestricted<R3> c = value4.apply(in,ina,inb); return c; }); }); }); }
java
public < T2, T3, R1, R2, R3> Unrestricted<R3> forEach4(Function<? super T, ? extends Unrestricted<R1>> value2, BiFunction<? super T, ? super R1, ? extends Unrestricted<R2>> value3, Function3<? super T, ? super R1, ? super R2, ? extends Unrestricted<R3>> value4 ) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a.flatMap(ina -> { Unrestricted<R2> b = value3.apply(in,ina); return b.flatMap(inb -> { Unrestricted<R3> c = value4.apply(in,ina,inb); return c; }); }); }); }
[ "public", "<", "T2", ",", "T3", ",", "R1", ",", "R2", ",", "R3", ">", "Unrestricted", "<", "R3", ">", "forEach4", "(", "Function", "<", "?", "super", "T", ",", "?", "extends", "Unrestricted", "<", "R1", ">", ">", "value2", ",", "BiFunction", "<", ...
Perform a For Comprehension over a Unrestricted, accepting 3 generating function. This results in a four level nested internal iteration over the provided Computationss. @param value1 top level Unrestricted @param value2 Nested Unrestricted @param value3 Nested Unrestricted @param value4 Nested Unrestricted @return Resulting Unrestricted
[ "Perform", "a", "For", "Comprehension", "over", "a", "Unrestricted", "accepting", "3", "generating", "function", ".", "This", "results", "in", "a", "four", "level", "nested", "internal", "iteration", "over", "the", "provided", "Computationss", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Unrestricted.java#L262-L281
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Unrestricted.java
Unrestricted.forEach3
public <T2, R1, R2> Unrestricted<R2> forEach3(Function<? super T, ? extends Unrestricted<R1>> value2, BiFunction<? super T, ? super R1, ? extends Unrestricted<R2>> value3) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a.flatMap(ina -> { Unrestricted<R2> b = value3.apply(in,ina); return b; }); }); }
java
public <T2, R1, R2> Unrestricted<R2> forEach3(Function<? super T, ? extends Unrestricted<R1>> value2, BiFunction<? super T, ? super R1, ? extends Unrestricted<R2>> value3) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a.flatMap(ina -> { Unrestricted<R2> b = value3.apply(in,ina); return b; }); }); }
[ "public", "<", "T2", ",", "R1", ",", "R2", ">", "Unrestricted", "<", "R2", ">", "forEach3", "(", "Function", "<", "?", "super", "T", ",", "?", "extends", "Unrestricted", "<", "R1", ">", ">", "value2", ",", "BiFunction", "<", "?", "super", "T", ",",...
Perform a For Comprehension over a Unrestricted, accepting 2 generating function. This results in a three level nested internal iteration over the provided Computationss. @param value1 top level Unrestricted @param value2 Nested Unrestricted @param value3 Nested Unrestricted @return Resulting Unrestricted
[ "Perform", "a", "For", "Comprehension", "over", "a", "Unrestricted", "accepting", "2", "generating", "function", ".", "This", "results", "in", "a", "three", "level", "nested", "internal", "iteration", "over", "the", "provided", "Computationss", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Unrestricted.java#L294-L308
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Unrestricted.java
Unrestricted.forEach2
public <R1> Unrestricted<R1> forEach2(Function<? super T, Unrestricted<R1>> value2) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a; }); }
java
public <R1> Unrestricted<R1> forEach2(Function<? super T, Unrestricted<R1>> value2) { return this.flatMap(in -> { Unrestricted<R1> a = value2.apply(in); return a; }); }
[ "public", "<", "R1", ">", "Unrestricted", "<", "R1", ">", "forEach2", "(", "Function", "<", "?", "super", "T", ",", "Unrestricted", "<", "R1", ">", ">", "value2", ")", "{", "return", "this", ".", "flatMap", "(", "in", "->", "{", "Unrestricted", "<", ...
Perform a For Comprehension over a Unrestricted, accepting a generating function. This results in a two level nested internal iteration over the provided Computationss. @param value2 Nested Unrestricted @return Resulting Unrestricted
[ "Perform", "a", "For", "Comprehension", "over", "a", "Unrestricted", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "Computationss", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Unrestricted.java#L319-L330
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Functions.java
Functions.arrowUnit
public static final <T,W extends Unit<T>> Function1<? super T,? extends W> arrowUnit(Unit<?> w){ return t-> (W)w.unit(t); }
java
public static final <T,W extends Unit<T>> Function1<? super T,? extends W> arrowUnit(Unit<?> w){ return t-> (W)w.unit(t); }
[ "public", "static", "final", "<", "T", ",", "W", "extends", "Unit", "<", "T", ">", ">", "Function1", "<", "?", "super", "T", ",", "?", "extends", "W", ">", "arrowUnit", "(", "Unit", "<", "?", ">", "w", ")", "{", "return", "t", "->", "(", "W", ...
Use an existing instance of a type that implements Unit to create a KleisliM arrow for that type <pre> {@code Seq<Integer> myList = Seq.of(1,2,3); Fn1<? super String, ? extends Seq<String>> arrow = Functions.arrowUnit(myList); Seq<String> list = arrow.applyHKT("hello world"); } </pre> @param w @param <T> @param <W> @return
[ "Use", "an", "existing", "instance", "of", "a", "type", "that", "implements", "Unit", "to", "create", "a", "KleisliM", "arrow", "for", "that", "type" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Functions.java#L80-L83
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.CofromPublisher
public static <T> Try<T, Throwable> CofromPublisher(final Publisher<T> pub) { return new Try<>(LazyEither.fromPublisher(pub),new Class[0]); }
java
public static <T> Try<T, Throwable> CofromPublisher(final Publisher<T> pub) { return new Try<>(LazyEither.fromPublisher(pub),new Class[0]); }
[ "public", "static", "<", "T", ">", "Try", "<", "T", ",", "Throwable", ">", "CofromPublisher", "(", "final", "Publisher", "<", "T", ">", "pub", ")", "{", "return", "new", "Try", "<>", "(", "LazyEither", ".", "fromPublisher", "(", "pub", ")", ",", "new...
Construct a Try that contains a single value extracted from the supplied reactive-streams Publisher <pre> {@code ReactiveSeq<Integer> stream = Spouts.of(1,2,3); Try<Integer,Throwable> recover = Try.fromPublisher(stream); Try[1] } </pre> @param pub Publisher to extract value from @return Try populated with first value from Publisher
[ "Construct", "a", "Try", "that", "contains", "a", "single", "value", "extracted", "from", "the", "supplied", "reactive", "-", "streams", "Publisher" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L330-L332
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.fromIterable
public static <T, X extends Throwable> Try<T, X> fromIterable(final Iterable<T> iterable, T alt) { if(iterable instanceof Try){ return (Try)iterable; } return new Try<>(LazyEither.fromIterable(iterable,alt), new Class[0]); }
java
public static <T, X extends Throwable> Try<T, X> fromIterable(final Iterable<T> iterable, T alt) { if(iterable instanceof Try){ return (Try)iterable; } return new Try<>(LazyEither.fromIterable(iterable,alt), new Class[0]); }
[ "public", "static", "<", "T", ",", "X", "extends", "Throwable", ">", "Try", "<", "T", ",", "X", ">", "fromIterable", "(", "final", "Iterable", "<", "T", ">", "iterable", ",", "T", "alt", ")", "{", "if", "(", "iterable", "instanceof", "Try", ")", "{...
Construct a Try that contains a single value extracted from the supplied Iterable <pre> {@code ReactiveSeq<Integer> stream = ReactiveSeq.of(1,2,3); Try<Integer,Throwable> recover = Try.fromIterable(stream); Try[1] } </pre> @param iterable Iterable to extract value from @return Try populated with first value from Iterable
[ "Construct", "a", "Try", "that", "contains", "a", "single", "value", "extracted", "from", "the", "supplied", "Iterable" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L352-L357
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.mapOrCatch
@SafeVarargs public final <R> Try<R,X> mapOrCatch(CheckedFunction<? super T, ? extends R,X> fn, Class<? extends X>... classes){ return new Try<R,X>(xor.flatMap(i ->safeApply(i, fn.asFunction(),classes)),this.classes); }
java
@SafeVarargs public final <R> Try<R,X> mapOrCatch(CheckedFunction<? super T, ? extends R,X> fn, Class<? extends X>... classes){ return new Try<R,X>(xor.flatMap(i ->safeApply(i, fn.asFunction(),classes)),this.classes); }
[ "@", "SafeVarargs", "public", "final", "<", "R", ">", "Try", "<", "R", ",", "X", ">", "mapOrCatch", "(", "CheckedFunction", "<", "?", "super", "T", ",", "?", "extends", "R", ",", "X", ">", "fn", ",", "Class", "<", "?", "extends", "X", ">", "...",...
Perform a mapping operation that may catch the supplied Exception types The supplied Exception types are only applied during this map operation @param fn mapping function @param classes exception types to catch @param <R> return type of mapping function @return Try with result or caught exception
[ "Perform", "a", "mapping", "operation", "that", "may", "catch", "the", "supplied", "Exception", "types", "The", "supplied", "Exception", "types", "are", "only", "applied", "during", "this", "map", "operation" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L555-L558
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.flatMapOrCatch
@SafeVarargs public final <R> Try<R, X> flatMapOrCatch(CheckedFunction<? super T, ? extends Try<? extends R,X>,X> fn,Class<? extends X>... classes){ return new Try<>(xor.flatMap(i->safeApplyM(i, fn.asFunction(),classes).toEither()),classes); }
java
@SafeVarargs public final <R> Try<R, X> flatMapOrCatch(CheckedFunction<? super T, ? extends Try<? extends R,X>,X> fn,Class<? extends X>... classes){ return new Try<>(xor.flatMap(i->safeApplyM(i, fn.asFunction(),classes).toEither()),classes); }
[ "@", "SafeVarargs", "public", "final", "<", "R", ">", "Try", "<", "R", ",", "X", ">", "flatMapOrCatch", "(", "CheckedFunction", "<", "?", "super", "T", ",", "?", "extends", "Try", "<", "?", "extends", "R", ",", "X", ">", ",", "X", ">", "fn", ",",...
Perform a flatMapping operation that may catch the supplied Exception types The supplied Exception types are only applied during this map operation @param fn flatMapping function @param classes exception types to catch @param <R> return type of mapping function @return Try with result or caught exception
[ "Perform", "a", "flatMapping", "operation", "that", "may", "catch", "the", "supplied", "Exception", "types", "The", "supplied", "Exception", "types", "are", "only", "applied", "during", "this", "map", "operation" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L582-L585
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.recoverFor
public Try<T, X> recoverFor(Class<? extends X> t, Function<? super X, ? extends T> fn){ return new Try<T,X>(xor.flatMapLeftToRight(x->{ if (t.isAssignableFrom(x.getClass())) return Either.right(fn.apply(x)); return xor; }),classes); }
java
public Try<T, X> recoverFor(Class<? extends X> t, Function<? super X, ? extends T> fn){ return new Try<T,X>(xor.flatMapLeftToRight(x->{ if (t.isAssignableFrom(x.getClass())) return Either.right(fn.apply(x)); return xor; }),classes); }
[ "public", "Try", "<", "T", ",", "X", ">", "recoverFor", "(", "Class", "<", "?", "extends", "X", ">", "t", ",", "Function", "<", "?", "super", "X", ",", "?", "extends", "T", ">", "fn", ")", "{", "return", "new", "Try", "<", "T", ",", "X", ">",...
Recover if exception is of specified type @param t Type of exception to fold against @param fn Recovery function @return New Success if failure and types fold / otherwise this
[ "Recover", "if", "exception", "is", "of", "specified", "type" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L735-L741
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.withCatch
@SafeVarargs public static <T, X extends Throwable> Try<T, X> withCatch(final CheckedSupplier<T, X> cf, final Class<? extends X>... classes) { Objects.requireNonNull(cf); try { return Try.success(cf.get()); } catch (final Throwable t) { if (classes.length == 0) return Try.failure((X) t); val error = Stream.of(classes) .filter(c -> c.isAssignableFrom(t.getClass())) .findFirst(); if (error.isPresent()) return Try.failure((X) t); else throw ExceptionSoftener.throwSoftenedException(t); } }
java
@SafeVarargs public static <T, X extends Throwable> Try<T, X> withCatch(final CheckedSupplier<T, X> cf, final Class<? extends X>... classes) { Objects.requireNonNull(cf); try { return Try.success(cf.get()); } catch (final Throwable t) { if (classes.length == 0) return Try.failure((X) t); val error = Stream.of(classes) .filter(c -> c.isAssignableFrom(t.getClass())) .findFirst(); if (error.isPresent()) return Try.failure((X) t); else throw ExceptionSoftener.throwSoftenedException(t); } }
[ "@", "SafeVarargs", "public", "static", "<", "T", ",", "X", "extends", "Throwable", ">", "Try", "<", "T", ",", "X", ">", "withCatch", "(", "final", "CheckedSupplier", "<", "T", ",", "X", ">", "cf", ",", "final", "Class", "<", "?", "extends", "X", "...
Try to execute supplied Supplier and will Catch specified Excpetions or java.lang.Exception if none specified. @param cf CheckedSupplier to recover to execute @param classes Exception types to catch (or java.lang.Exception if none specified) @return New Try
[ "Try", "to", "execute", "supplied", "Supplier", "and", "will", "Catch", "specified", "Excpetions", "or", "java", ".", "lang", ".", "Exception", "if", "none", "specified", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L853-L870
train
aol/cyclops
cyclops/src/main/java/cyclops/control/Try.java
Try.runWithCatch
@SafeVarargs public static <X extends Throwable> Try<Void, X> runWithCatch(final CheckedRunnable<X> cf, final Class<? extends X>... classes) { Objects.requireNonNull(cf); try { cf.run(); return Try.success(null); } catch (final Throwable t) { if (classes.length == 0) return Try.failure((X) t); val error = Stream.of(classes) .filter(c -> c.isAssignableFrom(t.getClass())) .findFirst(); if (error.isPresent()) return Try.failure((X) t); else throw ExceptionSoftener.throwSoftenedException(t); } }
java
@SafeVarargs public static <X extends Throwable> Try<Void, X> runWithCatch(final CheckedRunnable<X> cf, final Class<? extends X>... classes) { Objects.requireNonNull(cf); try { cf.run(); return Try.success(null); } catch (final Throwable t) { if (classes.length == 0) return Try.failure((X) t); val error = Stream.of(classes) .filter(c -> c.isAssignableFrom(t.getClass())) .findFirst(); if (error.isPresent()) return Try.failure((X) t); else throw ExceptionSoftener.throwSoftenedException(t); } }
[ "@", "SafeVarargs", "public", "static", "<", "X", "extends", "Throwable", ">", "Try", "<", "Void", ",", "X", ">", "runWithCatch", "(", "final", "CheckedRunnable", "<", "X", ">", "cf", ",", "final", "Class", "<", "?", "extends", "X", ">", "...", "classe...
Try to execute supplied Runnable and will Catch specified Excpetions or java.lang.Exception if none specified. @param cf CheckedRunnable to recover to execute @param classes Exception types to catch (or java.lang.Exception if none specified) @return New Try
[ "Try", "to", "execute", "supplied", "Runnable", "and", "will", "Catch", "specified", "Excpetions", "or", "java", ".", "lang", ".", "Exception", "if", "none", "specified", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/control/Try.java#L881-L900
train
aol/cyclops
cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java
Singles.anyOf
public static <T> Single<T> anyOf(Single<T>... fts) { return Single.fromPublisher(Future.anyOf(futures(fts))); }
java
public static <T> Single<T> anyOf(Single<T>... fts) { return Single.fromPublisher(Future.anyOf(futures(fts))); }
[ "public", "static", "<", "T", ">", "Single", "<", "T", ">", "anyOf", "(", "Single", "<", "T", ">", "...", "fts", ")", "{", "return", "Single", ".", "fromPublisher", "(", "Future", ".", "anyOf", "(", "futures", "(", "fts", ")", ")", ")", ";", "}" ...
Select the first Single to complete @see CompletableFuture#anyOf(CompletableFuture...) @param fts Singles to race @return First Single to complete
[ "Select", "the", "first", "Single", "to", "complete" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java#L100-L103
train
aol/cyclops
cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java
Singles.forEach
public static <T, R1, R> Single<R> forEach(Single<? extends T> value1, Function<? super T, Single<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { Single<R> res = value1.flatMap(in -> { Single<R1> a = value2.apply(in); return a.map(ina -> yieldingFunction.apply(in, ina)); }); return narrow(res); }
java
public static <T, R1, R> Single<R> forEach(Single<? extends T> value1, Function<? super T, Single<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { Single<R> res = value1.flatMap(in -> { Single<R1> a = value2.apply(in); return a.map(ina -> yieldingFunction.apply(in, ina)); }); return narrow(res); }
[ "public", "static", "<", "T", ",", "R1", ",", "R", ">", "Single", "<", "R", ">", "forEach", "(", "Single", "<", "?", "extends", "T", ">", "value1", ",", "Function", "<", "?", "super", "T", ",", "Single", "<", "R1", ">", ">", "value2", ",", "BiF...
Perform a For Comprehension over a Single, accepting a generating function. This results in a two level nested internal iteration over the provided Singles. <pre> {@code import static cyclops.companion.reactor.Singles.forEach; forEach(Single.just(1), a-> Single.just(a+1), Tuple::tuple) } </pre> @param value1 top level Single @param value2 Nested Single @param yieldingFunction Generates a result per combination @return Single with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "Single", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "Singles", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java#L314-L329
train
aol/cyclops
cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java
Singles.fromIterable
public static <T> Single<T> fromIterable(Iterable<T> t) { return Single.fromPublisher(Future.fromIterable(t)); }
java
public static <T> Single<T> fromIterable(Iterable<T> t) { return Single.fromPublisher(Future.fromIterable(t)); }
[ "public", "static", "<", "T", ">", "Single", "<", "T", ">", "fromIterable", "(", "Iterable", "<", "T", ">", "t", ")", "{", "return", "Single", ".", "fromPublisher", "(", "Future", ".", "fromIterable", "(", "t", ")", ")", ";", "}" ]
Construct a Single from Iterable by taking the first value from Iterable @param t Iterable to populate Single from @return Single containing first element from Iterable (or empty Single)
[ "Construct", "a", "Single", "from", "Iterable", "by", "taking", "the", "first", "value", "from", "Iterable" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-rxjava2-integration/src/main/java/cyclops/companion/rx2/Singles.java#L396-L398
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/ListT.java
ListT.map
@Override public <B> ListT<W,B> map(final Function<? super T, ? extends B> f) { return of(run.map(o -> o.map(f))); }
java
@Override public <B> ListT<W,B> map(final Function<? super T, ? extends B> f) { return of(run.map(o -> o.map(f))); }
[ "@", "Override", "public", "<", "B", ">", "ListT", "<", "W", ",", "B", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "B", ">", "f", ")", "{", "return", "of", "(", "run", ".", "map", "(", "o", "->", "o", ...
Map the wrapped List <pre> {@code ListT.of(AnyM.fromStream(Arrays.asList(10)) .map(t->t=t+1); //ListT<AnyM<Stream<List[11]>>> } </pre> @param f Mapping function for the wrapped List @return ListT that applies the transform function to the wrapped List
[ "Map", "the", "wrapped", "List" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/ListT.java#L143-L146
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/ListT.java
ListT.of
public static <W extends WitnessType<W>,A> ListT<W,A> of(final AnyM<W,? extends IndexedSequenceX<A>> monads) { return new ListT<>( monads); }
java
public static <W extends WitnessType<W>,A> ListT<W,A> of(final AnyM<W,? extends IndexedSequenceX<A>> monads) { return new ListT<>( monads); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "A", ">", "ListT", "<", "W", ",", "A", ">", "of", "(", "final", "AnyM", "<", "W", ",", "?", "extends", "IndexedSequenceX", "<", "A", ">", ">", "monads", ")", "{", "return...
Construct an ListT from an AnyM that wraps a monad containing Lists @param monads AnyM that contains a monad wrapping an List @return ListT
[ "Construct", "an", "ListT", "from", "an", "AnyM", "that", "wraps", "a", "monad", "containing", "Lists" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/ListT.java#L197-L200
train
twitter/scalding
maple/src/main/java/com/twitter/maple/hbase/HBaseScheme.java
HBaseScheme.getFamilyNames
public String[] getFamilyNames() { HashSet<String> familyNameSet = new HashSet<String>(); if (familyNames == null) { for (String columnName : columns(null, this.valueFields)) { int pos = columnName.indexOf(":"); familyNameSet.add(hbaseColumn(pos > 0 ? columnName.substring(0, pos) : columnName)); } } else { for (String familyName : familyNames) { familyNameSet.add(familyName); } } return familyNameSet.toArray(new String[0]); }
java
public String[] getFamilyNames() { HashSet<String> familyNameSet = new HashSet<String>(); if (familyNames == null) { for (String columnName : columns(null, this.valueFields)) { int pos = columnName.indexOf(":"); familyNameSet.add(hbaseColumn(pos > 0 ? columnName.substring(0, pos) : columnName)); } } else { for (String familyName : familyNames) { familyNameSet.add(familyName); } } return familyNameSet.toArray(new String[0]); }
[ "public", "String", "[", "]", "getFamilyNames", "(", ")", "{", "HashSet", "<", "String", ">", "familyNameSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "if", "(", "familyNames", "==", "null", ")", "{", "for", "(", "String", "columnName...
Method getFamilyNames returns the set of familyNames of this HBaseScheme object. @return the familyNames (type String[]) of this HBaseScheme object.
[ "Method", "getFamilyNames", "returns", "the", "set", "of", "familyNames", "of", "this", "HBaseScheme", "object", "." ]
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/maple/src/main/java/com/twitter/maple/hbase/HBaseScheme.java#L140-L154
train
twitter/scalding
scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java
Undeprecated.getAsciiBytes
@SuppressWarnings("deprecation") public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) { element.getBytes(charStart, charLen, bytes, byteOffset); }
java
@SuppressWarnings("deprecation") public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) { element.getBytes(charStart, charLen, bytes, byteOffset); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "void", "getAsciiBytes", "(", "String", "element", ",", "int", "charStart", ",", "int", "charLen", ",", "byte", "[", "]", "bytes", ",", "int", "byteOffset", ")", "{", "element", ".", ...
This method is faster for ASCII data, but unsafe otherwise it is used by our macros AFTER checking that the string is ASCII following a pattern seen in Kryo, which benchmarking showed helped. Scala cannot supress warnings like this so we do it here
[ "This", "method", "is", "faster", "for", "ASCII", "data", "but", "unsafe", "otherwise", "it", "is", "used", "by", "our", "macros", "AFTER", "checking", "that", "the", "string", "is", "ASCII", "following", "a", "pattern", "seen", "in", "Kryo", "which", "ben...
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java#L25-L28
train
twitter/scalding
scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java
ScroogeReadSupport.getSchemaForRead
public static MessageType getSchemaForRead(MessageType fileMessageType, MessageType projectedMessageType) { assertGroupsAreCompatible(fileMessageType, projectedMessageType); return projectedMessageType; }
java
public static MessageType getSchemaForRead(MessageType fileMessageType, MessageType projectedMessageType) { assertGroupsAreCompatible(fileMessageType, projectedMessageType); return projectedMessageType; }
[ "public", "static", "MessageType", "getSchemaForRead", "(", "MessageType", "fileMessageType", ",", "MessageType", "projectedMessageType", ")", "{", "assertGroupsAreCompatible", "(", "fileMessageType", ",", "projectedMessageType", ")", ";", "return", "projectedMessageType", ...
Updated method from ReadSupport which checks if the projection's compatible instead of a stricter check to see if the file's schema contains the projection @param fileMessageType @param projectedMessageType @return
[ "Updated", "method", "from", "ReadSupport", "which", "checks", "if", "the", "projection", "s", "compatible", "instead", "of", "a", "stricter", "check", "to", "see", "if", "the", "file", "s", "schema", "contains", "the", "projection" ]
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java#L133-L136
train
twitter/scalding
scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java
ScroogeReadSupport.assertGroupsAreCompatible
public static void assertGroupsAreCompatible(GroupType fileType, GroupType projection) { List<Type> fields = projection.getFields(); for (Type otherType : fields) { if (fileType.containsField(otherType.getName())) { Type thisType = fileType.getType(otherType.getName()); assertAreCompatible(thisType, otherType); if (!otherType.isPrimitive()) { assertGroupsAreCompatible(thisType.asGroupType(), otherType.asGroupType()); } } else if (otherType.getRepetition() == Type.Repetition.REQUIRED) { throw new InvalidRecordException(otherType.getName() + " not found in " + fileType); } } }
java
public static void assertGroupsAreCompatible(GroupType fileType, GroupType projection) { List<Type> fields = projection.getFields(); for (Type otherType : fields) { if (fileType.containsField(otherType.getName())) { Type thisType = fileType.getType(otherType.getName()); assertAreCompatible(thisType, otherType); if (!otherType.isPrimitive()) { assertGroupsAreCompatible(thisType.asGroupType(), otherType.asGroupType()); } } else if (otherType.getRepetition() == Type.Repetition.REQUIRED) { throw new InvalidRecordException(otherType.getName() + " not found in " + fileType); } } }
[ "public", "static", "void", "assertGroupsAreCompatible", "(", "GroupType", "fileType", ",", "GroupType", "projection", ")", "{", "List", "<", "Type", ">", "fields", "=", "projection", ".", "getFields", "(", ")", ";", "for", "(", "Type", "otherType", ":", "fi...
Validates that the requested group type projection is compatible. This allows the projection schema to have extra optional fields. @param fileType the typed schema of the source @param projection requested projection schema
[ "Validates", "that", "the", "requested", "group", "type", "projection", "is", "compatible", ".", "This", "allows", "the", "projection", "schema", "to", "have", "extra", "optional", "fields", "." ]
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java#L160-L173
train
twitter/scalding
scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java
ScroogeReadSupport.assertAreCompatible
public static void assertAreCompatible(Type fileType, Type projection) { if (!fileType.getName().equals(projection.getName()) || (fileType.getRepetition() != projection.getRepetition() && !fileType.getRepetition().isMoreRestrictiveThan(projection.getRepetition()))) { throw new InvalidRecordException(projection + " found: expected " + fileType); } }
java
public static void assertAreCompatible(Type fileType, Type projection) { if (!fileType.getName().equals(projection.getName()) || (fileType.getRepetition() != projection.getRepetition() && !fileType.getRepetition().isMoreRestrictiveThan(projection.getRepetition()))) { throw new InvalidRecordException(projection + " found: expected " + fileType); } }
[ "public", "static", "void", "assertAreCompatible", "(", "Type", "fileType", ",", "Type", "projection", ")", "{", "if", "(", "!", "fileType", ".", "getName", "(", ")", ".", "equals", "(", "projection", ".", "getName", "(", ")", ")", "||", "(", "fileType",...
Validates that the requested projection is compatible. This makes it possible to project a required field using optional since it is less restrictive. @param fileType the typed schema of the source @param projection requested projection schema
[ "Validates", "that", "the", "requested", "projection", "is", "compatible", ".", "This", "makes", "it", "possible", "to", "project", "a", "required", "field", "using", "optional", "since", "it", "is", "less", "restrictive", "." ]
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java#L183-L188
train
twitter/scalding
scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java
ScroogeReadSupport.getThriftClass
public static <T extends ThriftStruct> Class<T> getThriftClass(Map<String, String> fileMetadata, Configuration conf) throws ClassNotFoundException { String className = conf.get(THRIFT_READ_CLASS_KEY, null); if (className == null) { final ThriftMetaData metaData = ThriftMetaData.fromExtraMetaData(fileMetadata); if (metaData == null) { throw new ParquetDecodingException("Could not read file as the Thrift class is not provided and could not be resolved from the file"); } return (Class<T>) metaData.getThriftClass(); } else { return (Class<T>) Class.forName(className); } }
java
public static <T extends ThriftStruct> Class<T> getThriftClass(Map<String, String> fileMetadata, Configuration conf) throws ClassNotFoundException { String className = conf.get(THRIFT_READ_CLASS_KEY, null); if (className == null) { final ThriftMetaData metaData = ThriftMetaData.fromExtraMetaData(fileMetadata); if (metaData == null) { throw new ParquetDecodingException("Could not read file as the Thrift class is not provided and could not be resolved from the file"); } return (Class<T>) metaData.getThriftClass(); } else { return (Class<T>) Class.forName(className); } }
[ "public", "static", "<", "T", "extends", "ThriftStruct", ">", "Class", "<", "T", ">", "getThriftClass", "(", "Map", "<", "String", ",", "String", ">", "fileMetadata", ",", "Configuration", "conf", ")", "throws", "ClassNotFoundException", "{", "String", "classN...
Getting thrift class from extra metadata
[ "Getting", "thrift", "class", "from", "extra", "metadata" ]
428b5507279655676e507d52c669c3cbc7812dc0
https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeReadSupport.java#L227-L238
train
yshrsmz/KeyboardVisibilityEvent
keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/util/UIUtil.java
UIUtil.showKeyboard
public static void showKeyboard(Context context, EditText target) { if (context == null || target == null) { return; } InputMethodManager imm = getInputMethodManager(context); imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT); }
java
public static void showKeyboard(Context context, EditText target) { if (context == null || target == null) { return; } InputMethodManager imm = getInputMethodManager(context); imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT); }
[ "public", "static", "void", "showKeyboard", "(", "Context", "context", ",", "EditText", "target", ")", "{", "if", "(", "context", "==", "null", "||", "target", "==", "null", ")", "{", "return", ";", "}", "InputMethodManager", "imm", "=", "getInputMethodManag...
Show keyboard and focus to given EditText @param context Context @param target EditText to focus
[ "Show", "keyboard", "and", "focus", "to", "given", "EditText" ]
fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8
https://github.com/yshrsmz/KeyboardVisibilityEvent/blob/fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8/keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/util/UIUtil.java#L30-L38
train
yshrsmz/KeyboardVisibilityEvent
keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/util/UIUtil.java
UIUtil.showKeyboardInDialog
public static void showKeyboardInDialog(Dialog dialog, EditText target) { if (dialog == null || target == null) { return; } dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); target.requestFocus(); }
java
public static void showKeyboardInDialog(Dialog dialog, EditText target) { if (dialog == null || target == null) { return; } dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); target.requestFocus(); }
[ "public", "static", "void", "showKeyboardInDialog", "(", "Dialog", "dialog", ",", "EditText", "target", ")", "{", "if", "(", "dialog", "==", "null", "||", "target", "==", "null", ")", "{", "return", ";", "}", "dialog", ".", "getWindow", "(", ")", ".", ...
Show keyboard and focus to given EditText. Use this method if target EditText is in Dialog. @param dialog Dialog @param target EditText to focus
[ "Show", "keyboard", "and", "focus", "to", "given", "EditText", ".", "Use", "this", "method", "if", "target", "EditText", "is", "in", "Dialog", "." ]
fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8
https://github.com/yshrsmz/KeyboardVisibilityEvent/blob/fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8/keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/util/UIUtil.java#L47-L54
train
yshrsmz/KeyboardVisibilityEvent
keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java
KeyboardVisibilityEvent.setEventListener
public static void setEventListener(final Activity activity, final KeyboardVisibilityEventListener listener) { final Unregistrar unregistrar = registerEventListener(activity, listener); activity.getApplication() .registerActivityLifecycleCallbacks(new AutoActivityLifecycleCallback(activity) { @Override protected void onTargetActivityDestroyed() { unregistrar.unregister(); } }); }
java
public static void setEventListener(final Activity activity, final KeyboardVisibilityEventListener listener) { final Unregistrar unregistrar = registerEventListener(activity, listener); activity.getApplication() .registerActivityLifecycleCallbacks(new AutoActivityLifecycleCallback(activity) { @Override protected void onTargetActivityDestroyed() { unregistrar.unregister(); } }); }
[ "public", "static", "void", "setEventListener", "(", "final", "Activity", "activity", ",", "final", "KeyboardVisibilityEventListener", "listener", ")", "{", "final", "Unregistrar", "unregistrar", "=", "registerEventListener", "(", "activity", ",", "listener", ")", ";"...
Set keyboard visibility change event listener. This automatically remove registered event listener when the Activity is destroyed @param activity Activity @param listener KeyboardVisibilityEventListener
[ "Set", "keyboard", "visibility", "change", "event", "listener", ".", "This", "automatically", "remove", "registered", "event", "listener", "when", "the", "Activity", "is", "destroyed" ]
fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8
https://github.com/yshrsmz/KeyboardVisibilityEvent/blob/fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8/keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java#L27-L38
train
yshrsmz/KeyboardVisibilityEvent
keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java
KeyboardVisibilityEvent.registerEventListener
public static Unregistrar registerEventListener(final Activity activity, final KeyboardVisibilityEventListener listener) { if (activity == null) { throw new NullPointerException("Parameter:activity must not be null"); } int softInputAdjust = activity.getWindow().getAttributes().softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; // fix for #37 and #38. // The window will not be resized in case of SOFT_INPUT_ADJUST_NOTHING if ((softInputAdjust & WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) { throw new IllegalArgumentException("Parameter:activity window SoftInputMethod is SOFT_INPUT_ADJUST_NOTHING. In this case window will not be resized"); } if (listener == null) { throw new NullPointerException("Parameter:listener must not be null"); } final View activityRoot = getActivityRoot(activity); final ViewTreeObserver.OnGlobalLayoutListener layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { private final Rect r = new Rect(); private boolean wasOpened = false; @Override public void onGlobalLayout() { activityRoot.getWindowVisibleDisplayFrame(r); int screenHeight = activityRoot.getRootView().getHeight(); int heightDiff = screenHeight - r.height(); boolean isOpen = heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO; if (isOpen == wasOpened) { // keyboard state has not changed return; } wasOpened = isOpen; listener.onVisibilityChanged(isOpen); } }; activityRoot.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener); return new SimpleUnregistrar(activity, layoutListener); }
java
public static Unregistrar registerEventListener(final Activity activity, final KeyboardVisibilityEventListener listener) { if (activity == null) { throw new NullPointerException("Parameter:activity must not be null"); } int softInputAdjust = activity.getWindow().getAttributes().softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; // fix for #37 and #38. // The window will not be resized in case of SOFT_INPUT_ADJUST_NOTHING if ((softInputAdjust & WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) { throw new IllegalArgumentException("Parameter:activity window SoftInputMethod is SOFT_INPUT_ADJUST_NOTHING. In this case window will not be resized"); } if (listener == null) { throw new NullPointerException("Parameter:listener must not be null"); } final View activityRoot = getActivityRoot(activity); final ViewTreeObserver.OnGlobalLayoutListener layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { private final Rect r = new Rect(); private boolean wasOpened = false; @Override public void onGlobalLayout() { activityRoot.getWindowVisibleDisplayFrame(r); int screenHeight = activityRoot.getRootView().getHeight(); int heightDiff = screenHeight - r.height(); boolean isOpen = heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO; if (isOpen == wasOpened) { // keyboard state has not changed return; } wasOpened = isOpen; listener.onVisibilityChanged(isOpen); } }; activityRoot.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener); return new SimpleUnregistrar(activity, layoutListener); }
[ "public", "static", "Unregistrar", "registerEventListener", "(", "final", "Activity", "activity", ",", "final", "KeyboardVisibilityEventListener", "listener", ")", "{", "if", "(", "activity", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Pa...
Set keyboard visibility change event listener. @param activity Activity @param listener KeyboardVisibilityEventListener @return Unregistrar
[ "Set", "keyboard", "visibility", "change", "event", "listener", "." ]
fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8
https://github.com/yshrsmz/KeyboardVisibilityEvent/blob/fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8/keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java#L47-L99
train
yshrsmz/KeyboardVisibilityEvent
keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java
KeyboardVisibilityEvent.isKeyboardVisible
public static boolean isKeyboardVisible(Activity activity) { Rect r = new Rect(); View activityRoot = getActivityRoot(activity); activityRoot.getWindowVisibleDisplayFrame(r); int screenHeight = activityRoot.getRootView().getHeight(); int heightDiff = screenHeight - r.height(); return heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO; }
java
public static boolean isKeyboardVisible(Activity activity) { Rect r = new Rect(); View activityRoot = getActivityRoot(activity); activityRoot.getWindowVisibleDisplayFrame(r); int screenHeight = activityRoot.getRootView().getHeight(); int heightDiff = screenHeight - r.height(); return heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO; }
[ "public", "static", "boolean", "isKeyboardVisible", "(", "Activity", "activity", ")", "{", "Rect", "r", "=", "new", "Rect", "(", ")", ";", "View", "activityRoot", "=", "getActivityRoot", "(", "activity", ")", ";", "activityRoot", ".", "getWindowVisibleDisplayFra...
Determine if keyboard is visible @param activity Activity @return Whether keyboard is visible or not
[ "Determine", "if", "keyboard", "is", "visible" ]
fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8
https://github.com/yshrsmz/KeyboardVisibilityEvent/blob/fbde29a2c28ff1b2fa44f43cdd1ff3ec1d3321d8/keyboardvisibilityevent/src/main/java/net/yslibrary/android/keyboardvisibilityevent/KeyboardVisibilityEvent.java#L107-L118
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.toBitmap
@NonNull public Bitmap toBitmap() { if (mSizeX == -1 || mSizeY == -1) { actionBar(); } Bitmap bitmap = Bitmap.createBitmap( getIntrinsicWidth(), getIntrinsicHeight(), Bitmap.Config.ARGB_8888); style(Paint.Style.FILL); Canvas canvas = new Canvas(bitmap); setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); draw(canvas); return bitmap; }
java
@NonNull public Bitmap toBitmap() { if (mSizeX == -1 || mSizeY == -1) { actionBar(); } Bitmap bitmap = Bitmap.createBitmap( getIntrinsicWidth(), getIntrinsicHeight(), Bitmap.Config.ARGB_8888); style(Paint.Style.FILL); Canvas canvas = new Canvas(bitmap); setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); draw(canvas); return bitmap; }
[ "@", "NonNull", "public", "Bitmap", "toBitmap", "(", ")", "{", "if", "(", "mSizeX", "==", "-", "1", "||", "mSizeY", "==", "-", "1", ")", "{", "actionBar", "(", ")", ";", "}", "Bitmap", "bitmap", "=", "Bitmap", ".", "createBitmap", "(", "getIntrinsicW...
Creates a BitMap to use in Widgets or anywhere else @return bitmap to set
[ "Creates", "a", "BitMap", "to", "use", "in", "Widgets", "or", "anywhere", "else" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L273-L291
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.iconOffsetXDp
@NonNull public IconicsDrawable iconOffsetXDp(@Dimension(unit = DP) int sizeDp) { return iconOffsetXPx(Utils.convertDpToPx(mContext, sizeDp)); }
java
@NonNull public IconicsDrawable iconOffsetXDp(@Dimension(unit = DP) int sizeDp) { return iconOffsetXPx(Utils.convertDpToPx(mContext, sizeDp)); }
[ "@", "NonNull", "public", "IconicsDrawable", "iconOffsetXDp", "(", "@", "Dimension", "(", "unit", "=", "DP", ")", "int", "sizeDp", ")", "{", "return", "iconOffsetXPx", "(", "Utils", ".", "convertDpToPx", "(", "mContext", ",", "sizeDp", ")", ")", ";", "}" ]
set the icon offset for X as dp @return The current IconicsDrawable for chaining.
[ "set", "the", "icon", "offset", "for", "X", "as", "dp" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L525-L528
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.iconOffsetXPx
@NonNull public IconicsDrawable iconOffsetXPx(@Dimension(unit = PX) int sizePx) { mIconOffsetX = sizePx; invalidateSelf(); return this; }
java
@NonNull public IconicsDrawable iconOffsetXPx(@Dimension(unit = PX) int sizePx) { mIconOffsetX = sizePx; invalidateSelf(); return this; }
[ "@", "NonNull", "public", "IconicsDrawable", "iconOffsetXPx", "(", "@", "Dimension", "(", "unit", "=", "PX", ")", "int", "sizePx", ")", "{", "mIconOffsetX", "=", "sizePx", ";", "invalidateSelf", "(", ")", ";", "return", "this", ";", "}" ]
set the icon offset for X @return The current IconicsDrawable for chaining.
[ "set", "the", "icon", "offset", "for", "X" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L535-L541
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.iconOffsetYDp
@NonNull public IconicsDrawable iconOffsetYDp(@Dimension(unit = DP) int sizeDp) { return iconOffsetYPx(Utils.convertDpToPx(mContext, sizeDp)); }
java
@NonNull public IconicsDrawable iconOffsetYDp(@Dimension(unit = DP) int sizeDp) { return iconOffsetYPx(Utils.convertDpToPx(mContext, sizeDp)); }
[ "@", "NonNull", "public", "IconicsDrawable", "iconOffsetYDp", "(", "@", "Dimension", "(", "unit", "=", "DP", ")", "int", "sizeDp", ")", "{", "return", "iconOffsetYPx", "(", "Utils", ".", "convertDpToPx", "(", "mContext", ",", "sizeDp", ")", ")", ";", "}" ]
set the icon offset for Y as dp @return The current IconicsDrawable for chaining.
[ "set", "the", "icon", "offset", "for", "Y", "as", "dp" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L558-L561
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.iconOffsetYPx
@NonNull public IconicsDrawable iconOffsetYPx(@Dimension(unit = PX) int sizePx) { mIconOffsetY = sizePx; invalidateSelf(); return this; }
java
@NonNull public IconicsDrawable iconOffsetYPx(@Dimension(unit = PX) int sizePx) { mIconOffsetY = sizePx; invalidateSelf(); return this; }
[ "@", "NonNull", "public", "IconicsDrawable", "iconOffsetYPx", "(", "@", "Dimension", "(", "unit", "=", "PX", ")", "int", "sizePx", ")", "{", "mIconOffsetY", "=", "sizePx", ";", "invalidateSelf", "(", ")", ";", "return", "this", ";", "}" ]
set the icon offset for Y @return The current IconicsDrawable for chaining.
[ "set", "the", "icon", "offset", "for", "Y" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L568-L574
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.paddingDp
@NonNull public IconicsDrawable paddingDp(@Dimension(unit = DP) int sizeDp) { return paddingPx(Utils.convertDpToPx(mContext, sizeDp)); }
java
@NonNull public IconicsDrawable paddingDp(@Dimension(unit = DP) int sizeDp) { return paddingPx(Utils.convertDpToPx(mContext, sizeDp)); }
[ "@", "NonNull", "public", "IconicsDrawable", "paddingDp", "(", "@", "Dimension", "(", "unit", "=", "DP", ")", "int", "sizeDp", ")", "{", "return", "paddingPx", "(", "Utils", ".", "convertDpToPx", "(", "mContext", ",", "sizeDp", ")", ")", ";", "}" ]
Set the padding in dp for the drawable @return The current IconicsDrawable for chaining.
[ "Set", "the", "padding", "in", "dp", "for", "the", "drawable" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L591-L594
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.paddingPx
@NonNull public IconicsDrawable paddingPx(@Dimension(unit = PX) int sizePx) { if (mIconPadding != sizePx) { mIconPadding = sizePx; if (mDrawContour) { mIconPadding += mContourWidth; } if (mDrawBackgroundContour) { mIconPadding += mBackgroundContourWidth; } invalidateSelf(); } return this; }
java
@NonNull public IconicsDrawable paddingPx(@Dimension(unit = PX) int sizePx) { if (mIconPadding != sizePx) { mIconPadding = sizePx; if (mDrawContour) { mIconPadding += mContourWidth; } if (mDrawBackgroundContour) { mIconPadding += mBackgroundContourWidth; } invalidateSelf(); } return this; }
[ "@", "NonNull", "public", "IconicsDrawable", "paddingPx", "(", "@", "Dimension", "(", "unit", "=", "PX", ")", "int", "sizePx", ")", "{", "if", "(", "mIconPadding", "!=", "sizePx", ")", "{", "mIconPadding", "=", "sizePx", ";", "if", "(", "mDrawContour", "...
Set a padding for the. @return The current IconicsDrawable for chaining.
[ "Set", "a", "padding", "for", "the", "." ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L601-L615
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.contourWidthDp
@NonNull public IconicsDrawable contourWidthDp(@Dimension(unit = DP) int sizeDp) { return contourWidthPx(Utils.convertDpToPx(mContext, sizeDp)); }
java
@NonNull public IconicsDrawable contourWidthDp(@Dimension(unit = DP) int sizeDp) { return contourWidthPx(Utils.convertDpToPx(mContext, sizeDp)); }
[ "@", "NonNull", "public", "IconicsDrawable", "contourWidthDp", "(", "@", "Dimension", "(", "unit", "=", "DP", ")", "int", "sizeDp", ")", "{", "return", "contourWidthPx", "(", "Utils", ".", "convertDpToPx", "(", "mContext", ",", "sizeDp", ")", ")", ";", "}"...
Set contour width from dp for the icon @return The current IconicsDrawable for chaining.
[ "Set", "contour", "width", "from", "dp", "for", "the", "icon" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L1011-L1014
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.contourWidthPx
@NonNull public IconicsDrawable contourWidthPx(@Dimension(unit = PX) int sizePx) { mContourWidth = sizePx; mContourBrush.getPaint().setStrokeWidth(sizePx); drawContour(true); invalidateSelf(); return this; }
java
@NonNull public IconicsDrawable contourWidthPx(@Dimension(unit = PX) int sizePx) { mContourWidth = sizePx; mContourBrush.getPaint().setStrokeWidth(sizePx); drawContour(true); invalidateSelf(); return this; }
[ "@", "NonNull", "public", "IconicsDrawable", "contourWidthPx", "(", "@", "Dimension", "(", "unit", "=", "PX", ")", "int", "sizePx", ")", "{", "mContourWidth", "=", "sizePx", ";", "mContourBrush", ".", "getPaint", "(", ")", ".", "setStrokeWidth", "(", "sizePx...
Set contour width for the icon. @return The current IconicsDrawable for chaining.
[ "Set", "contour", "width", "for", "the", "icon", "." ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L1021-L1029
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.backgroundContourWidthDp
@NonNull public IconicsDrawable backgroundContourWidthDp(@Dimension(unit = DP) int sizeDp) { return backgroundContourWidthPx(Utils.convertDpToPx(mContext, sizeDp)); }
java
@NonNull public IconicsDrawable backgroundContourWidthDp(@Dimension(unit = DP) int sizeDp) { return backgroundContourWidthPx(Utils.convertDpToPx(mContext, sizeDp)); }
[ "@", "NonNull", "public", "IconicsDrawable", "backgroundContourWidthDp", "(", "@", "Dimension", "(", "unit", "=", "DP", ")", "int", "sizeDp", ")", "{", "return", "backgroundContourWidthPx", "(", "Utils", ".", "convertDpToPx", "(", "mContext", ",", "sizeDp", ")",...
Set background contour width from dp for the icon @return The current IconicsDrawable for chaining.
[ "Set", "background", "contour", "width", "from", "dp", "for", "the", "icon" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L1143-L1146
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java
IconicsDrawable.backgroundContourWidthPx
@NonNull public IconicsDrawable backgroundContourWidthPx(@Dimension(unit = PX) int sizePx) { mBackgroundContourWidth = sizePx; mBackgroundContourBrush.getPaint().setStrokeWidth(sizePx); drawBackgroundContour(true); invalidateSelf(); return this; }
java
@NonNull public IconicsDrawable backgroundContourWidthPx(@Dimension(unit = PX) int sizePx) { mBackgroundContourWidth = sizePx; mBackgroundContourBrush.getPaint().setStrokeWidth(sizePx); drawBackgroundContour(true); invalidateSelf(); return this; }
[ "@", "NonNull", "public", "IconicsDrawable", "backgroundContourWidthPx", "(", "@", "Dimension", "(", "unit", "=", "PX", ")", "int", "sizePx", ")", "{", "mBackgroundContourWidth", "=", "sizePx", ";", "mBackgroundContourBrush", ".", "getPaint", "(", ")", ".", "set...
Set background contour width for the icon. @return The current IconicsDrawable for chaining.
[ "Set", "background", "contour", "width", "for", "the", "icon", "." ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L1153-L1161
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/animation/IconicsAnimationProcessor.java
IconicsAnimationProcessor.start
@NonNull public IconicsAnimationProcessor start() { mAnimator.setInterpolator(mInterpolator); mAnimator.setDuration(mDuration); mAnimator.setRepeatCount(mRepeatCount); mAnimator.setRepeatMode(mRepeatMode); if (mDrawable != null) { mIsStartRequested = false; mAnimator.start(); } else { mIsStartRequested = true; } return this; }
java
@NonNull public IconicsAnimationProcessor start() { mAnimator.setInterpolator(mInterpolator); mAnimator.setDuration(mDuration); mAnimator.setRepeatCount(mRepeatCount); mAnimator.setRepeatMode(mRepeatMode); if (mDrawable != null) { mIsStartRequested = false; mAnimator.start(); } else { mIsStartRequested = true; } return this; }
[ "@", "NonNull", "public", "IconicsAnimationProcessor", "start", "(", ")", "{", "mAnimator", ".", "setInterpolator", "(", "mInterpolator", ")", ";", "mAnimator", ".", "setDuration", "(", "mDuration", ")", ";", "mAnimator", ".", "setRepeatCount", "(", "mRepeatCount"...
Starts the animation, if processor is attached to drawable, otherwise sets flag to start animation immediately after attaching
[ "Starts", "the", "animation", "if", "processor", "is", "attached", "to", "drawable", "otherwise", "sets", "flag", "to", "start", "animation", "immediately", "after", "attaching" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/animation/IconicsAnimationProcessor.java#L221-L235
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/utils/GenericsUtil.java
GenericsUtil.resolveRClass
private static Class resolveRClass(String packageName) { do { try { return Class.forName(packageName + ".R$string"); } catch (ClassNotFoundException e) { packageName = packageName.contains(".") ? packageName.substring(0, packageName.lastIndexOf('.')) : ""; } } while (!TextUtils.isEmpty(packageName)); return null; }
java
private static Class resolveRClass(String packageName) { do { try { return Class.forName(packageName + ".R$string"); } catch (ClassNotFoundException e) { packageName = packageName.contains(".") ? packageName.substring(0, packageName.lastIndexOf('.')) : ""; } } while (!TextUtils.isEmpty(packageName)); return null; }
[ "private", "static", "Class", "resolveRClass", "(", "String", "packageName", ")", "{", "do", "{", "try", "{", "return", "Class", ".", "forName", "(", "packageName", "+", "\".R$string\"", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", ...
a helper class to resolve the correct R Class for the package
[ "a", "helper", "class", "to", "resolve", "the", "correct", "R", "Class", "for", "the", "package" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/utils/GenericsUtil.java#L43-L53
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/utils/GenericsUtil.java
GenericsUtil.getStringResourceByName
private static String getStringResourceByName(Context ctx, String resourceName) { String packageName = ctx.getPackageName(); int resId = ctx.getResources().getIdentifier(resourceName, "string", packageName); if (resId == 0) { return ""; } else { return ctx.getString(resId); } }
java
private static String getStringResourceByName(Context ctx, String resourceName) { String packageName = ctx.getPackageName(); int resId = ctx.getResources().getIdentifier(resourceName, "string", packageName); if (resId == 0) { return ""; } else { return ctx.getString(resId); } }
[ "private", "static", "String", "getStringResourceByName", "(", "Context", "ctx", ",", "String", "resourceName", ")", "{", "String", "packageName", "=", "ctx", ".", "getPackageName", "(", ")", ";", "int", "resId", "=", "ctx", ".", "getResources", "(", ")", "....
helper class to retrieve a string by it's resource name
[ "helper", "class", "to", "retrieve", "a", "string", "by", "it", "s", "resource", "name" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/utils/GenericsUtil.java#L90-L98
train
mikepenz/Android-Iconics
library-core/src/main/java/com/mikepenz/iconics/utils/IconicsUtils.java
IconicsUtils.applyStyles
public static void applyStyles(Context ctx, Spannable text, List<StyleContainer> styleContainers, List<CharacterStyle> styles, HashMap<String, List<CharacterStyle>> stylesFor) { for (StyleContainer styleContainer : styleContainers) { if (styleContainer.style != null) { text.setSpan(styleContainer.style, styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } else if (styleContainer.span != null) { text.setSpan(styleContainer.span, styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } else { text.setSpan(new IconicsTypefaceSpan("sans-serif", styleContainer.font.getTypeface(ctx)), styleContainer.startIndex, styleContainer.endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } if (stylesFor != null && stylesFor.containsKey(styleContainer.icon)) { for (CharacterStyle style : stylesFor.get(styleContainer.icon)) { text.setSpan(CharacterStyle.wrap(style), styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } } else if (styles != null) { for (CharacterStyle style : styles) { text.setSpan(CharacterStyle.wrap(style), styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } } } }
java
public static void applyStyles(Context ctx, Spannable text, List<StyleContainer> styleContainers, List<CharacterStyle> styles, HashMap<String, List<CharacterStyle>> stylesFor) { for (StyleContainer styleContainer : styleContainers) { if (styleContainer.style != null) { text.setSpan(styleContainer.style, styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } else if (styleContainer.span != null) { text.setSpan(styleContainer.span, styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } else { text.setSpan(new IconicsTypefaceSpan("sans-serif", styleContainer.font.getTypeface(ctx)), styleContainer.startIndex, styleContainer.endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } if (stylesFor != null && stylesFor.containsKey(styleContainer.icon)) { for (CharacterStyle style : stylesFor.get(styleContainer.icon)) { text.setSpan(CharacterStyle.wrap(style), styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } } else if (styles != null) { for (CharacterStyle style : styles) { text.setSpan(CharacterStyle.wrap(style), styleContainer.startIndex, styleContainer.endIndex, styleContainer.flags); } } } }
[ "public", "static", "void", "applyStyles", "(", "Context", "ctx", ",", "Spannable", "text", ",", "List", "<", "StyleContainer", ">", "styleContainers", ",", "List", "<", "CharacterStyle", ">", "styles", ",", "HashMap", "<", "String", ",", "List", "<", "Chara...
Applies all given styles on the given Spannable @param ctx @param text the text which will get the Styles applied @param styleContainers all styles to apply @param styles additional CharacterStyles to apply @param stylesFor additional styles to apply for specific icons
[ "Applies", "all", "given", "styles", "on", "the", "given", "Spannable" ]
0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8
https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/utils/IconicsUtils.java#L259-L279
train
coursier/coursier
modules/bootstrap-launcher/src/main/java/coursier/bootstrap/launcher/jar/CentralDirectoryEndRecord.java
CentralDirectoryEndRecord.getCentralDirectory
public RandomAccessData getCentralDirectory(RandomAccessData data) { long offset = Bytes.littleEndianValue(this.block, this.offset + 16, 4); long length = Bytes.littleEndianValue(this.block, this.offset + 12, 4); return data.getSubsection(offset, length); }
java
public RandomAccessData getCentralDirectory(RandomAccessData data) { long offset = Bytes.littleEndianValue(this.block, this.offset + 16, 4); long length = Bytes.littleEndianValue(this.block, this.offset + 12, 4); return data.getSubsection(offset, length); }
[ "public", "RandomAccessData", "getCentralDirectory", "(", "RandomAccessData", "data", ")", "{", "long", "offset", "=", "Bytes", ".", "littleEndianValue", "(", "this", ".", "block", ",", "this", ".", "offset", "+", "16", ",", "4", ")", ";", "long", "length", ...
Return the bytes of the "Central directory" based on the offset indicated in this record. @param data the source data @return the central directory data
[ "Return", "the", "bytes", "of", "the", "Central", "directory", "based", "on", "the", "offset", "indicated", "in", "this", "record", "." ]
651da8db6c7528a819b91a5c1bca9b402176b19c
https://github.com/coursier/coursier/blob/651da8db6c7528a819b91a5c1bca9b402176b19c/modules/bootstrap-launcher/src/main/java/coursier/bootstrap/launcher/jar/CentralDirectoryEndRecord.java#L108-L112
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Hosts.java
Hosts.getLocalHostName
public static String getLocalHostName() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostName(); }
java
public static String getLocalHostName() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostName(); }
[ "public", "static", "String", "getLocalHostName", "(", ")", "throws", "UnknownHostException", "{", "String", "preffered", "=", "System", ".", "getProperty", "(", "PREFERED_ADDRESS_PROPERTY_NAME", ")", ";", "return", "chooseAddress", "(", "preffered", ")", ".", "getH...
Returns the local hostname. It loops through the network interfaces and returns the first non loopback address @return @throws UnknownHostException
[ "Returns", "the", "local", "hostname", ".", "It", "loops", "through", "the", "network", "interfaces", "and", "returns", "the", "first", "non", "loopback", "address" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Hosts.java#L158-L161
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Hosts.java
Hosts.getLocalIp
public static String getLocalIp() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostAddress(); }
java
public static String getLocalIp() throws UnknownHostException { String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME); return chooseAddress(preffered).getHostAddress(); }
[ "public", "static", "String", "getLocalIp", "(", ")", "throws", "UnknownHostException", "{", "String", "preffered", "=", "System", ".", "getProperty", "(", "PREFERED_ADDRESS_PROPERTY_NAME", ")", ";", "return", "chooseAddress", "(", "preffered", ")", ".", "getHostAdd...
Returns the local IP. It loops through the network interfaces and returns the first non loopback address @return @throws UnknownHostException
[ "Returns", "the", "local", "IP", ".", "It", "loops", "through", "the", "network", "interfaces", "and", "returns", "the", "first", "non", "loopback", "address" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Hosts.java#L169-L172
train
hawtio/hawtio
hawtio-system/src/main/java/io/hawt/web/auth/LoginServlet.java
LoginServlet.doGet
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (authConfiguration.isKeycloakEnabled()) { redirector.doRedirect(request, response, "/"); } else { redirector.doForward(request, response, "/login.html"); } }
java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (authConfiguration.isKeycloakEnabled()) { redirector.doRedirect(request, response, "/"); } else { redirector.doForward(request, response, "/login.html"); } }
[ "@", "Override", "protected", "void", "doGet", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "if", "(", "authConfiguration", ".", "isKeycloakEnabled", "(", ")", ")", "{", "...
GET simply returns login.html
[ "GET", "simply", "returns", "login", ".", "html" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-system/src/main/java/io/hawt/web/auth/LoginServlet.java#L78-L85
train
hawtio/hawtio
hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java
IdeFacade.findClassAbsoluteFileName
@Override public String findClassAbsoluteFileName(String fileName, String className, List<String> sourceRoots) { // usually the fileName is just the name of the file without any package information // so lets turn the package name into a path int lastIdx = className.lastIndexOf('.'); if (lastIdx > 0 && !(fileName.contains("/") || fileName.contains(File.separator))) { String packagePath = className.substring(0, lastIdx).replace('.', File.separatorChar); fileName = packagePath + File.separator + fileName; } File baseDir = getBaseDir(); String answer = findInSourceFolders(baseDir, fileName); if (answer == null && sourceRoots != null) { for (String sourceRoot : sourceRoots) { answer = findInSourceFolders(new File(sourceRoot), fileName); if (answer != null) break; } } return answer; }
java
@Override public String findClassAbsoluteFileName(String fileName, String className, List<String> sourceRoots) { // usually the fileName is just the name of the file without any package information // so lets turn the package name into a path int lastIdx = className.lastIndexOf('.'); if (lastIdx > 0 && !(fileName.contains("/") || fileName.contains(File.separator))) { String packagePath = className.substring(0, lastIdx).replace('.', File.separatorChar); fileName = packagePath + File.separator + fileName; } File baseDir = getBaseDir(); String answer = findInSourceFolders(baseDir, fileName); if (answer == null && sourceRoots != null) { for (String sourceRoot : sourceRoots) { answer = findInSourceFolders(new File(sourceRoot), fileName); if (answer != null) break; } } return answer; }
[ "@", "Override", "public", "String", "findClassAbsoluteFileName", "(", "String", "fileName", ",", "String", "className", ",", "List", "<", "String", ">", "sourceRoots", ")", "{", "// usually the fileName is just the name of the file without any package information", "// so le...
Given a class name and a file name, try to find the absolute file name of the source file on the users machine or null if it cannot be found
[ "Given", "a", "class", "name", "and", "a", "file", "name", "try", "to", "find", "the", "absolute", "file", "name", "of", "the", "source", "file", "on", "the", "users", "machine", "or", "null", "if", "it", "cannot", "be", "found" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java#L63-L81
train
hawtio/hawtio
hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java
IdeFacade.ideaOpenAndNavigate
@Override public String ideaOpenAndNavigate(String fileName, int line, int column) throws Exception { if (line < 0) line = 0; if (column < 0) column = 0; String xml = "<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n" + "<methodCall>\n" + " <methodName>fileOpener.openAndNavigate</methodName>\n" + " <params>\n" + " <param><value><string>" + fileName + "</string></value></param>\n" + " <param><value><int>" + line + "</int></value></param>\n" + " <param><value><int>" + column + "</int></value></param>\n" + " </params>\n" + "</methodCall>\n"; return ideaXmlRpc(xml); }
java
@Override public String ideaOpenAndNavigate(String fileName, int line, int column) throws Exception { if (line < 0) line = 0; if (column < 0) column = 0; String xml = "<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n" + "<methodCall>\n" + " <methodName>fileOpener.openAndNavigate</methodName>\n" + " <params>\n" + " <param><value><string>" + fileName + "</string></value></param>\n" + " <param><value><int>" + line + "</int></value></param>\n" + " <param><value><int>" + column + "</int></value></param>\n" + " </params>\n" + "</methodCall>\n"; return ideaXmlRpc(xml); }
[ "@", "Override", "public", "String", "ideaOpenAndNavigate", "(", "String", "fileName", ",", "int", "line", ",", "int", "column", ")", "throws", "Exception", "{", "if", "(", "line", "<", "0", ")", "line", "=", "0", ";", "if", "(", "column", "<", "0", ...
Uses Intellij's XmlRPC mechanism to open and navigate to a file
[ "Uses", "Intellij", "s", "XmlRPC", "mechanism", "to", "open", "and", "navigate", "to", "a", "file" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java#L130-L145
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Files.java
Files.recursiveDelete
public static int recursiveDelete(File file) { int answer = 0; if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { answer += recursiveDelete(child); } } } if (file.delete()) { answer += 1; } return answer; }
java
public static int recursiveDelete(File file) { int answer = 0; if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { answer += recursiveDelete(child); } } } if (file.delete()) { answer += 1; } return answer; }
[ "public", "static", "int", "recursiveDelete", "(", "File", "file", ")", "{", "int", "answer", "=", "0", ";", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "files", "=", "file", ".", "listFiles", "(", ")", ";", "if", ...
Recursively deletes the given file whether its a file or directory returning the number of files deleted
[ "Recursively", "deletes", "the", "given", "file", "whether", "its", "a", "file", "or", "directory", "returning", "the", "number", "of", "files", "deleted" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Files.java#L58-L72
train
hawtio/hawtio
tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/main/SpringMain.java
SpringMain.showOptions
public void showOptions() { showOptionsHeader(); for (Option option : options) { System.out.println(option.getInformation()); } }
java
public void showOptions() { showOptionsHeader(); for (Option option : options) { System.out.println(option.getInformation()); } }
[ "public", "void", "showOptions", "(", ")", "{", "showOptionsHeader", "(", ")", ";", "for", "(", "Option", "option", ":", "options", ")", "{", "System", ".", "out", ".", "println", "(", "option", ".", "getInformation", "(", ")", ")", ";", "}", "}" ]
Displays the command line options.
[ "Displays", "the", "command", "line", "options", "." ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/main/SpringMain.java#L96-L102
train
hawtio/hawtio
hawtio-embedded/src/main/java/io/hawt/embedded/Main.java
Main.findWar
protected String findWar(String... paths) { if (paths != null) { for (String path : paths) { if (path != null) { File file = new File(path); if (file.exists()) { if (file.isFile()) { String name = file.getName(); if (isWarFileName(name)) { return file.getPath(); } } if (file.isDirectory()) { // lets look for a war in this directory File[] wars = file.listFiles((dir, name) -> isWarFileName(name)); if (wars != null && wars.length > 0) { return wars[0].getPath(); } } } } } } return null; }
java
protected String findWar(String... paths) { if (paths != null) { for (String path : paths) { if (path != null) { File file = new File(path); if (file.exists()) { if (file.isFile()) { String name = file.getName(); if (isWarFileName(name)) { return file.getPath(); } } if (file.isDirectory()) { // lets look for a war in this directory File[] wars = file.listFiles((dir, name) -> isWarFileName(name)); if (wars != null && wars.length > 0) { return wars[0].getPath(); } } } } } } return null; }
[ "protected", "String", "findWar", "(", "String", "...", "paths", ")", "{", "if", "(", "paths", "!=", "null", ")", "{", "for", "(", "String", "path", ":", "paths", ")", "{", "if", "(", "path", "!=", "null", ")", "{", "File", "file", "=", "new", "F...
Strategy method where we could use some smarts to find the war using known paths or maybe the local maven repository?
[ "Strategy", "method", "where", "we", "could", "use", "some", "smarts", "to", "find", "the", "war", "using", "known", "paths", "or", "maybe", "the", "local", "maven", "repository?" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-embedded/src/main/java/io/hawt/embedded/Main.java#L231-L255
train
hawtio/hawtio
hawtio-system/src/main/java/io/hawt/web/auth/keycloak/KeycloakServlet.java
KeycloakServlet.defaultKeycloakConfigLocation
protected String defaultKeycloakConfigLocation() { String karafBase = System.getProperty("karaf.base"); if (karafBase != null) { return karafBase + "/etc/keycloak.json"; } String jettyHome = System.getProperty("jetty.home"); if (jettyHome != null) { return jettyHome + "/etc/keycloak.json"; } String tomcatHome = System.getProperty("catalina.home"); if (tomcatHome != null) { return tomcatHome + "/conf/keycloak.json"; } String jbossHome = System.getProperty("jboss.server.config.dir"); if (jbossHome != null) { return jbossHome + "/keycloak.json"; } // Fallback to classpath inside hawtio.war return "classpath:keycloak.json"; }
java
protected String defaultKeycloakConfigLocation() { String karafBase = System.getProperty("karaf.base"); if (karafBase != null) { return karafBase + "/etc/keycloak.json"; } String jettyHome = System.getProperty("jetty.home"); if (jettyHome != null) { return jettyHome + "/etc/keycloak.json"; } String tomcatHome = System.getProperty("catalina.home"); if (tomcatHome != null) { return tomcatHome + "/conf/keycloak.json"; } String jbossHome = System.getProperty("jboss.server.config.dir"); if (jbossHome != null) { return jbossHome + "/keycloak.json"; } // Fallback to classpath inside hawtio.war return "classpath:keycloak.json"; }
[ "protected", "String", "defaultKeycloakConfigLocation", "(", ")", "{", "String", "karafBase", "=", "System", ".", "getProperty", "(", "\"karaf.base\"", ")", ";", "if", "(", "karafBase", "!=", "null", ")", "{", "return", "karafBase", "+", "\"/etc/keycloak.json\"", ...
Will try to guess the config location based on the server where hawtio is running. Used just if keycloakClientConfig is not provided @return config to be used by default
[ "Will", "try", "to", "guess", "the", "config", "location", "based", "on", "the", "server", "where", "hawtio", "is", "running", ".", "Used", "just", "if", "keycloakClientConfig", "is", "not", "provided" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-system/src/main/java/io/hawt/web/auth/keycloak/KeycloakServlet.java#L88-L111
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Zips.java
Zips.createZipFile
public static void createZipFile(Logger log, File sourceDir, File outputZipFile) throws IOException { FileFilter filter = null; createZipFile(log, sourceDir, outputZipFile, filter); }
java
public static void createZipFile(Logger log, File sourceDir, File outputZipFile) throws IOException { FileFilter filter = null; createZipFile(log, sourceDir, outputZipFile, filter); }
[ "public", "static", "void", "createZipFile", "(", "Logger", "log", ",", "File", "sourceDir", ",", "File", "outputZipFile", ")", "throws", "IOException", "{", "FileFilter", "filter", "=", "null", ";", "createZipFile", "(", "log", ",", "sourceDir", ",", "outputZ...
Creates a zip fie from the given source directory and output zip file name
[ "Creates", "a", "zip", "fie", "from", "the", "given", "source", "directory", "and", "output", "zip", "file", "name" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Zips.java#L43-L46
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Zips.java
Zips.zipDirectory
public static void zipDirectory(Logger log, File directory, ZipOutputStream zos, String path, FileFilter filter) throws IOException { // get a listing of the directory content File[] dirList = directory.listFiles(); byte[] readBuffer = new byte[8192]; int bytesIn = 0; // loop through dirList, and zip the files if (dirList != null) { for (File f : dirList) { if (f.isDirectory()) { String prefix = path + f.getName() + "/"; if (matches(filter, f)) { zos.putNextEntry(new ZipEntry(prefix)); zipDirectory(log, f, zos, prefix, filter); } } else { String entry = path + f.getName(); if (matches(filter, f)) { FileInputStream fis = new FileInputStream(f); try { ZipEntry anEntry = new ZipEntry(entry); zos.putNextEntry(anEntry); bytesIn = fis.read(readBuffer); while (bytesIn != -1) { zos.write(readBuffer, 0, bytesIn); bytesIn = fis.read(readBuffer); } } finally { fis.close(); } if (log.isDebugEnabled()) { log.debug("zipping file " + entry); } } } zos.closeEntry(); } } }
java
public static void zipDirectory(Logger log, File directory, ZipOutputStream zos, String path, FileFilter filter) throws IOException { // get a listing of the directory content File[] dirList = directory.listFiles(); byte[] readBuffer = new byte[8192]; int bytesIn = 0; // loop through dirList, and zip the files if (dirList != null) { for (File f : dirList) { if (f.isDirectory()) { String prefix = path + f.getName() + "/"; if (matches(filter, f)) { zos.putNextEntry(new ZipEntry(prefix)); zipDirectory(log, f, zos, prefix, filter); } } else { String entry = path + f.getName(); if (matches(filter, f)) { FileInputStream fis = new FileInputStream(f); try { ZipEntry anEntry = new ZipEntry(entry); zos.putNextEntry(anEntry); bytesIn = fis.read(readBuffer); while (bytesIn != -1) { zos.write(readBuffer, 0, bytesIn); bytesIn = fis.read(readBuffer); } } finally { fis.close(); } if (log.isDebugEnabled()) { log.debug("zipping file " + entry); } } } zos.closeEntry(); } } }
[ "public", "static", "void", "zipDirectory", "(", "Logger", "log", ",", "File", "directory", ",", "ZipOutputStream", "zos", ",", "String", "path", ",", "FileFilter", "filter", ")", "throws", "IOException", "{", "// get a listing of the directory content", "File", "["...
Zips the directory recursively into the ZIP stream given the starting path and optional filter
[ "Zips", "the", "directory", "recursively", "into", "the", "ZIP", "stream", "given", "the", "starting", "path", "and", "optional", "filter" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Zips.java#L65-L102
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Zips.java
Zips.unzip
public static void unzip(InputStream in, File toDir) throws IOException { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in)); try { ZipEntry entry = zis.getNextEntry(); while (entry != null) { if (!entry.isDirectory()) { String entryName = entry.getName(); File toFile = new File(toDir, entryName); toFile.getParentFile().mkdirs(); OutputStream os = new FileOutputStream(toFile); try { try { copy(zis, os); } finally { zis.closeEntry(); } } finally { closeQuietly(os); } } entry = zis.getNextEntry(); } } finally { closeQuietly(zis); } }
java
public static void unzip(InputStream in, File toDir) throws IOException { ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in)); try { ZipEntry entry = zis.getNextEntry(); while (entry != null) { if (!entry.isDirectory()) { String entryName = entry.getName(); File toFile = new File(toDir, entryName); toFile.getParentFile().mkdirs(); OutputStream os = new FileOutputStream(toFile); try { try { copy(zis, os); } finally { zis.closeEntry(); } } finally { closeQuietly(os); } } entry = zis.getNextEntry(); } } finally { closeQuietly(zis); } }
[ "public", "static", "void", "unzip", "(", "InputStream", "in", ",", "File", "toDir", ")", "throws", "IOException", "{", "ZipInputStream", "zis", "=", "new", "ZipInputStream", "(", "new", "BufferedInputStream", "(", "in", ")", ")", ";", "try", "{", "ZipEntry"...
Unzips the given input stream of a ZIP to the given directory
[ "Unzips", "the", "given", "input", "stream", "of", "a", "ZIP", "to", "the", "given", "directory" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Zips.java#L111-L136
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/IOHelper.java
IOHelper.readFully
public static String readFully(BufferedReader reader) throws IOException { if (reader == null) { return null; } StringBuilder sb = new StringBuilder(BUFFER_SIZE); char[] buf = new char[BUFFER_SIZE]; try { int len; // read until we reach then end which is the -1 marker while ((len = reader.read(buf)) != -1) { sb.append(buf, 0, len); } } finally { IOHelper.close(reader, "reader", LOG); } return sb.toString(); }
java
public static String readFully(BufferedReader reader) throws IOException { if (reader == null) { return null; } StringBuilder sb = new StringBuilder(BUFFER_SIZE); char[] buf = new char[BUFFER_SIZE]; try { int len; // read until we reach then end which is the -1 marker while ((len = reader.read(buf)) != -1) { sb.append(buf, 0, len); } } finally { IOHelper.close(reader, "reader", LOG); } return sb.toString(); }
[ "public", "static", "String", "readFully", "(", "BufferedReader", "reader", ")", "throws", "IOException", "{", "if", "(", "reader", "==", "null", ")", "{", "return", "null", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "BUFFER_SIZE", ")...
Reads the entire reader into memory as a String
[ "Reads", "the", "entire", "reader", "into", "memory", "as", "a", "String" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/IOHelper.java#L35-L53
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/IOHelper.java
IOHelper.close
public static void close(Closeable closeable, String name, Logger log) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { if (log == null) { // then fallback to use the own Logger log = LOG; } if (name != null) { log.warn("Cannot close: " + name + ". Reason: " + e.getMessage(), e); } else { log.warn("Cannot close. Reason: " + e.getMessage(), e); } } } }
java
public static void close(Closeable closeable, String name, Logger log) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { if (log == null) { // then fallback to use the own Logger log = LOG; } if (name != null) { log.warn("Cannot close: " + name + ". Reason: " + e.getMessage(), e); } else { log.warn("Cannot close. Reason: " + e.getMessage(), e); } } } }
[ "public", "static", "void", "close", "(", "Closeable", "closeable", ",", "String", "name", ",", "Logger", "log", ")", "{", "if", "(", "closeable", "!=", "null", ")", "{", "try", "{", "closeable", ".", "close", "(", ")", ";", "}", "catch", "(", "IOExc...
Closes the given resource if it is available, logging any closing exceptions to the given log. @param closeable the object to close @param name the name of the resource @param log the log to use when reporting closure warnings, will use this class's own {@link Logger} if <tt>log == null</tt>
[ "Closes", "the", "given", "resource", "if", "it", "is", "available", "logging", "any", "closing", "exceptions", "to", "the", "given", "log", "." ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/IOHelper.java#L62-L78
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/IOHelper.java
IOHelper.write
public static void write(File file, String text, boolean append) throws IOException { FileWriter writer = new FileWriter(file, append); try { writer.write(text); } finally { writer.close(); } }
java
public static void write(File file, String text, boolean append) throws IOException { FileWriter writer = new FileWriter(file, append); try { writer.write(text); } finally { writer.close(); } }
[ "public", "static", "void", "write", "(", "File", "file", ",", "String", "text", ",", "boolean", "append", ")", "throws", "IOException", "{", "FileWriter", "writer", "=", "new", "FileWriter", "(", "file", ",", "append", ")", ";", "try", "{", "writer", "....
Writes the given text to the file; either in append mode or replace mode depending the append flag
[ "Writes", "the", "given", "text", "to", "the", "file", ";", "either", "in", "append", "mode", "or", "replace", "mode", "depending", "the", "append", "flag" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/IOHelper.java#L96-L103
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/IOHelper.java
IOHelper.write
public static void write(File file, byte[] data, boolean append) throws IOException { FileOutputStream stream = new FileOutputStream(file, append); try { stream.write(data); } finally { stream.close(); } }
java
public static void write(File file, byte[] data, boolean append) throws IOException { FileOutputStream stream = new FileOutputStream(file, append); try { stream.write(data); } finally { stream.close(); } }
[ "public", "static", "void", "write", "(", "File", "file", ",", "byte", "[", "]", "data", ",", "boolean", "append", ")", "throws", "IOException", "{", "FileOutputStream", "stream", "=", "new", "FileOutputStream", "(", "file", ",", "append", ")", ";", "try",...
Writes the given data to the file; either in append mode or replace mode depending the append flag
[ "Writes", "the", "given", "data", "to", "the", "file", ";", "either", "in", "append", "mode", "or", "replace", "mode", "depending", "the", "append", "flag" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/IOHelper.java#L109-L116
train
hawtio/hawtio
examples/springboot-1-authentication/src/main/java/io/hawt/example/spring/boot/SampleAuthenticationSpringBootService.java
SampleAuthenticationSpringBootService.configFacade
@Bean(initMethod = "init") public ConfigFacade configFacade() throws Exception { final URL loginResource = this.getClass().getClassLoader().getResource("login.conf"); if (loginResource != null) { setSystemPropertyIfNotSet(JAVA_SECURITY_AUTH_LOGIN_CONFIG, loginResource.toExternalForm()); } LOG.info("Using loginResource " + JAVA_SECURITY_AUTH_LOGIN_CONFIG + " : " + System .getProperty(JAVA_SECURITY_AUTH_LOGIN_CONFIG)); final URL loginFile = this.getClass().getClassLoader().getResource("realm.properties"); if (loginFile != null) { setSystemPropertyIfNotSet("login.file", loginFile.toExternalForm()); } LOG.info("Using login.file : " + System.getProperty("login.file")); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_ROLES, "admin"); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_REALM, "hawtio"); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_ROLE_PRINCIPAL_CLASSES, "org.eclipse.jetty.jaas.JAASRole"); if (!Boolean.getBoolean("debugMode")) { System.setProperty(AuthenticationConfiguration.HAWTIO_AUTHENTICATION_ENABLED, "true"); } return new ConfigFacade(); }
java
@Bean(initMethod = "init") public ConfigFacade configFacade() throws Exception { final URL loginResource = this.getClass().getClassLoader().getResource("login.conf"); if (loginResource != null) { setSystemPropertyIfNotSet(JAVA_SECURITY_AUTH_LOGIN_CONFIG, loginResource.toExternalForm()); } LOG.info("Using loginResource " + JAVA_SECURITY_AUTH_LOGIN_CONFIG + " : " + System .getProperty(JAVA_SECURITY_AUTH_LOGIN_CONFIG)); final URL loginFile = this.getClass().getClassLoader().getResource("realm.properties"); if (loginFile != null) { setSystemPropertyIfNotSet("login.file", loginFile.toExternalForm()); } LOG.info("Using login.file : " + System.getProperty("login.file")); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_ROLES, "admin"); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_REALM, "hawtio"); setSystemPropertyIfNotSet(AuthenticationConfiguration.HAWTIO_ROLE_PRINCIPAL_CLASSES, "org.eclipse.jetty.jaas.JAASRole"); if (!Boolean.getBoolean("debugMode")) { System.setProperty(AuthenticationConfiguration.HAWTIO_AUTHENTICATION_ENABLED, "true"); } return new ConfigFacade(); }
[ "@", "Bean", "(", "initMethod", "=", "\"init\"", ")", "public", "ConfigFacade", "configFacade", "(", ")", "throws", "Exception", "{", "final", "URL", "loginResource", "=", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResource"...
Configure facade to use authentication. @return config @throws Exception if an error occurs
[ "Configure", "facade", "to", "use", "authentication", "." ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/examples/springboot-1-authentication/src/main/java/io/hawt/example/spring/boot/SampleAuthenticationSpringBootService.java#L40-L63
train
hawtio/hawtio
hawtio-util/src/main/java/io/hawt/util/Strings.java
Strings.sanitizeDirectory
public static String sanitizeDirectory(String name) { if (isBlank(name)) { return name; } return sanitize(name).replace(".", ""); }
java
public static String sanitizeDirectory(String name) { if (isBlank(name)) { return name; } return sanitize(name).replace(".", ""); }
[ "public", "static", "String", "sanitizeDirectory", "(", "String", "name", ")", "{", "if", "(", "isBlank", "(", "name", ")", ")", "{", "return", "name", ";", "}", "return", "sanitize", "(", "name", ")", ".", "replace", "(", "\".\"", ",", "\"\"", ")", ...
Also remove any dots in the directory name @param name @return
[ "Also", "remove", "any", "dots", "in", "the", "directory", "name" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Strings.java#L50-L55
train
hawtio/hawtio
tooling/hawtio-junit/src/main/java/io/hawt/junit/ThrowableDTO.java
ThrowableDTO.addThrowableAndCauses
public static void addThrowableAndCauses(List<ThrowableDTO> exceptions, Throwable exception) { if (exception != null) { ThrowableDTO dto = new ThrowableDTO(exception); exceptions.add(dto); Throwable cause = exception.getCause(); if (cause != null && cause != exception) { addThrowableAndCauses(exceptions, cause); } } }
java
public static void addThrowableAndCauses(List<ThrowableDTO> exceptions, Throwable exception) { if (exception != null) { ThrowableDTO dto = new ThrowableDTO(exception); exceptions.add(dto); Throwable cause = exception.getCause(); if (cause != null && cause != exception) { addThrowableAndCauses(exceptions, cause); } } }
[ "public", "static", "void", "addThrowableAndCauses", "(", "List", "<", "ThrowableDTO", ">", "exceptions", ",", "Throwable", "exception", ")", "{", "if", "(", "exception", "!=", "null", ")", "{", "ThrowableDTO", "dto", "=", "new", "ThrowableDTO", "(", "exceptio...
Adds the exception and all of the causes to the given list of exceptions
[ "Adds", "the", "exception", "and", "all", "of", "the", "causes", "to", "the", "given", "list", "of", "exceptions" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/tooling/hawtio-junit/src/main/java/io/hawt/junit/ThrowableDTO.java#L35-L44
train
hawtio/hawtio
hawtio-log/src/main/java/io/hawt/log/support/Objects.java
Objects.compare
@SuppressWarnings("unchecked") public static int compare(Object a, Object b) { if (a == b) { return 0; } if (a == null) { return -1; } if (b == null) { return 1; } if (a instanceof Comparable) { Comparable comparable = (Comparable)a; return comparable.compareTo(b); } int answer = a.getClass().getName().compareTo(b.getClass().getName()); if (answer == 0) { answer = a.hashCode() - b.hashCode(); } return answer; }
java
@SuppressWarnings("unchecked") public static int compare(Object a, Object b) { if (a == b) { return 0; } if (a == null) { return -1; } if (b == null) { return 1; } if (a instanceof Comparable) { Comparable comparable = (Comparable)a; return comparable.compareTo(b); } int answer = a.getClass().getName().compareTo(b.getClass().getName()); if (answer == 0) { answer = a.hashCode() - b.hashCode(); } return answer; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "int", "compare", "(", "Object", "a", ",", "Object", "b", ")", "{", "if", "(", "a", "==", "b", ")", "{", "return", "0", ";", "}", "if", "(", "a", "==", "null", ")", "{", "ret...
A helper method for performing an ordered comparison on the objects handling nulls and objects which do not handle sorting gracefully @param a the first object @param b the second object
[ "A", "helper", "method", "for", "performing", "an", "ordered", "comparison", "on", "the", "objects", "handling", "nulls", "and", "objects", "which", "do", "not", "handle", "sorting", "gracefully" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-log/src/main/java/io/hawt/log/support/Objects.java#L26-L46
train
hawtio/hawtio
hawtio-system/src/main/java/io/hawt/web/auth/keycloak/KeycloakUserServlet.java
KeycloakUserServlet.getKeycloakUsername
protected String getKeycloakUsername(final HttpServletRequest req, HttpServletResponse resp) { AtomicReference<String> username = new AtomicReference<>(); Authenticator.authenticate( authConfiguration, req, subject -> { username.set(AuthHelpers.getUsername(subject)); // Start httpSession req.getSession(true); } ); return username.get(); }
java
protected String getKeycloakUsername(final HttpServletRequest req, HttpServletResponse resp) { AtomicReference<String> username = new AtomicReference<>(); Authenticator.authenticate( authConfiguration, req, subject -> { username.set(AuthHelpers.getUsername(subject)); // Start httpSession req.getSession(true); } ); return username.get(); }
[ "protected", "String", "getKeycloakUsername", "(", "final", "HttpServletRequest", "req", ",", "HttpServletResponse", "resp", ")", "{", "AtomicReference", "<", "String", ">", "username", "=", "new", "AtomicReference", "<>", "(", ")", ";", "Authenticator", ".", "aut...
With Keycloak integration, the Authorization header is available in the request to the UserServlet.
[ "With", "Keycloak", "integration", "the", "Authorization", "header", "is", "available", "in", "the", "request", "to", "the", "UserServlet", "." ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-system/src/main/java/io/hawt/web/auth/keycloak/KeycloakUserServlet.java#L39-L51
train
hawtio/hawtio
tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java
BaseMojo.filterUnwantedArtifacts
protected boolean filterUnwantedArtifacts(Artifact artifact) { // filter out maven and plexus stuff (plexus used by maven plugins) if (artifact.getGroupId().startsWith("org.apache.maven")) { return true; } else if (artifact.getGroupId().startsWith("org.codehaus.plexus")) { return true; } return false; }
java
protected boolean filterUnwantedArtifacts(Artifact artifact) { // filter out maven and plexus stuff (plexus used by maven plugins) if (artifact.getGroupId().startsWith("org.apache.maven")) { return true; } else if (artifact.getGroupId().startsWith("org.codehaus.plexus")) { return true; } return false; }
[ "protected", "boolean", "filterUnwantedArtifacts", "(", "Artifact", "artifact", ")", "{", "// filter out maven and plexus stuff (plexus used by maven plugins)", "if", "(", "artifact", ".", "getGroupId", "(", ")", ".", "startsWith", "(", "\"org.apache.maven\"", ")", ")", "...
Filter unwanted artifacts @param artifact the artifact @return <tt>true</tt> to skip this artifact, <tt>false</tt> to keep it
[ "Filter", "unwanted", "artifacts" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java#L163-L172
train
hawtio/hawtio
tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java
BaseMojo.addRelevantPluginDependencies
protected void addRelevantPluginDependencies(Set<Artifact> artifacts) throws MojoExecutionException { if (pluginDependencies == null) { return; } Iterator<Artifact> iter = this.pluginDependencies.iterator(); while (iter.hasNext()) { Artifact classPathElement = iter.next(); getLog().debug("Adding plugin dependency artifact: " + classPathElement.getArtifactId() + " to classpath"); artifacts.add(classPathElement); } }
java
protected void addRelevantPluginDependencies(Set<Artifact> artifacts) throws MojoExecutionException { if (pluginDependencies == null) { return; } Iterator<Artifact> iter = this.pluginDependencies.iterator(); while (iter.hasNext()) { Artifact classPathElement = iter.next(); getLog().debug("Adding plugin dependency artifact: " + classPathElement.getArtifactId() + " to classpath"); artifacts.add(classPathElement); } }
[ "protected", "void", "addRelevantPluginDependencies", "(", "Set", "<", "Artifact", ">", "artifacts", ")", "throws", "MojoExecutionException", "{", "if", "(", "pluginDependencies", "==", "null", ")", "{", "return", ";", "}", "Iterator", "<", "Artifact", ">", "ite...
Add any relevant project dependencies to the classpath.
[ "Add", "any", "relevant", "project", "dependencies", "to", "the", "classpath", "." ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java#L228-L239
train
hawtio/hawtio
tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java
BaseMojo.getAllDependencies
protected Collection<Artifact> getAllDependencies() throws Exception { List<Artifact> artifacts = new ArrayList<Artifact>(); for (Iterator<?> dependencies = project.getDependencies().iterator(); dependencies.hasNext();) { Dependency dependency = (Dependency)dependencies.next(); String groupId = dependency.getGroupId(); String artifactId = dependency.getArtifactId(); VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec(dependency.getVersion()); } catch (InvalidVersionSpecificationException e) { throw new MojoExecutionException("unable to parse version", e); } String type = dependency.getType(); if (type == null) { type = "jar"; } String classifier = dependency.getClassifier(); boolean optional = dependency.isOptional(); String scope = dependency.getScope(); if (scope == null) { scope = Artifact.SCOPE_COMPILE; } Artifact art = this.artifactFactory.createDependencyArtifact(groupId, artifactId, versionRange, type, classifier, scope, null, optional); if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) { art.setFile(new File(dependency.getSystemPath())); } List<String> exclusions = new ArrayList<String>(); for (Iterator<?> j = dependency.getExclusions().iterator(); j.hasNext();) { Exclusion e = (Exclusion)j.next(); exclusions.add(e.getGroupId() + ":" + e.getArtifactId()); } ArtifactFilter newFilter = new ExcludesArtifactFilter(exclusions); art.setDependencyFilter(newFilter); artifacts.add(art); } return artifacts; }
java
protected Collection<Artifact> getAllDependencies() throws Exception { List<Artifact> artifacts = new ArrayList<Artifact>(); for (Iterator<?> dependencies = project.getDependencies().iterator(); dependencies.hasNext();) { Dependency dependency = (Dependency)dependencies.next(); String groupId = dependency.getGroupId(); String artifactId = dependency.getArtifactId(); VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec(dependency.getVersion()); } catch (InvalidVersionSpecificationException e) { throw new MojoExecutionException("unable to parse version", e); } String type = dependency.getType(); if (type == null) { type = "jar"; } String classifier = dependency.getClassifier(); boolean optional = dependency.isOptional(); String scope = dependency.getScope(); if (scope == null) { scope = Artifact.SCOPE_COMPILE; } Artifact art = this.artifactFactory.createDependencyArtifact(groupId, artifactId, versionRange, type, classifier, scope, null, optional); if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) { art.setFile(new File(dependency.getSystemPath())); } List<String> exclusions = new ArrayList<String>(); for (Iterator<?> j = dependency.getExclusions().iterator(); j.hasNext();) { Exclusion e = (Exclusion)j.next(); exclusions.add(e.getGroupId() + ":" + e.getArtifactId()); } ArtifactFilter newFilter = new ExcludesArtifactFilter(exclusions); art.setDependencyFilter(newFilter); artifacts.add(art); } return artifacts; }
[ "protected", "Collection", "<", "Artifact", ">", "getAllDependencies", "(", ")", "throws", "Exception", "{", "List", "<", "Artifact", ">", "artifacts", "=", "new", "ArrayList", "<", "Artifact", ">", "(", ")", ";", "for", "(", "Iterator", "<", "?", ">", "...
generic method to retrieve all the transitive dependencies
[ "generic", "method", "to", "retrieve", "all", "the", "transitive", "dependencies" ]
d8b1c8f246307c0313ba297a494106d0859f3ffd
https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/BaseMojo.java#L255-L303
train