id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
52,800
jenetics/jenetics
jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java
EvolvingImagesWorker.start
public void start( final BiConsumer< EvolutionResult<PolygonGene, Double>, EvolutionResult<PolygonGene, Double>> callback ) { final Thread thread = new Thread(() -> { final MinMax<EvolutionResult<PolygonGene, Double>> best = MinMax.of(); _engine.stream() .limit(result -> !Thread.currentThread().is...
java
public void start( final BiConsumer< EvolutionResult<PolygonGene, Double>, EvolutionResult<PolygonGene, Double>> callback ) { final Thread thread = new Thread(() -> { final MinMax<EvolutionResult<PolygonGene, Double>> best = MinMax.of(); _engine.stream() .limit(result -> !Thread.currentThread().is...
[ "public", "void", "start", "(", "final", "BiConsumer", "<", "EvolutionResult", "<", "PolygonGene", ",", "Double", ">", ",", "EvolutionResult", "<", "PolygonGene", ",", "Double", ">", ">", "callback", ")", "{", "final", "Thread", "thread", "=", "new", "Thread...
Starts the evolution worker with the given evolution result callback. The callback may be null. @param callback the {@code EvolutionResult} callback. The first parameter contains the current result and the second the best.
[ "Starts", "the", "evolution", "worker", "with", "the", "given", "evolution", "result", "callback", ".", "The", "callback", "may", "be", "null", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java#L163-L183
52,801
jenetics/jenetics
jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java
EvolvingImagesWorker.stop
public void stop() { resume(); final Thread thread = _thread; if (thread != null) { thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { _thread = null; } } }
java
public void stop() { resume(); final Thread thread = _thread; if (thread != null) { thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { _thread = null; } } }
[ "public", "void", "stop", "(", ")", "{", "resume", "(", ")", ";", "final", "Thread", "thread", "=", "_thread", ";", "if", "(", "thread", "!=", "null", ")", "{", "thread", ".", "interrupt", "(", ")", ";", "try", "{", "thread", ".", "join", "(", ")...
Stops the current evolution, if running.
[ "Stops", "the", "current", "evolution", "if", "running", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java#L203-L216
52,802
jenetics/jenetics
jenetics/src/main/java/io/jenetics/AltererResult.java
AltererResult.of
public static <G extends Gene<?, G>, C extends Comparable<? super C>> AltererResult<G, C> of( final ISeq<Phenotype<G, C>> population, final int alterations ) { return new AltererResult<>(population, alterations); }
java
public static <G extends Gene<?, G>, C extends Comparable<? super C>> AltererResult<G, C> of( final ISeq<Phenotype<G, C>> population, final int alterations ) { return new AltererResult<>(population, alterations); }
[ "public", "static", "<", "G", "extends", "Gene", "<", "?", ",", "G", ">", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "AltererResult", "<", "G", ",", "C", ">", "of", "(", "final", "ISeq", "<", "Phenotype", "<", "G", ",", ...
Return a new alter result for the given arguments. @param population the altered population @param alterations the number of altered individuals @param <G> the gene type @param <C> the result type @return a new alterer for the given arguments @throws NullPointerException if the given population is {@code null} @throws...
[ "Return", "a", "new", "alter", "result", "for", "the", "given", "arguments", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/AltererResult.java#L120-L126
52,803
jenetics/jenetics
jenetics/src/main/java/io/jenetics/LongChromosome.java
LongChromosome.toArray
public long[] toArray(final long[] array) { final long[] a = array.length >= length() ? array : new long[length()]; for (int i = length(); --i >= 0;) { a[i] = longValue(i); } return a; }
java
public long[] toArray(final long[] array) { final long[] a = array.length >= length() ? array : new long[length()]; for (int i = length(); --i >= 0;) { a[i] = longValue(i); } return a; }
[ "public", "long", "[", "]", "toArray", "(", "final", "long", "[", "]", "array", ")", "{", "final", "long", "[", "]", "a", "=", "array", ".", "length", ">=", "length", "(", ")", "?", "array", ":", "new", "long", "[", "length", "(", ")", "]", ";"...
Returns an long array containing all of the elements in this chromosome in proper sequence. If the chromosome fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the length of this chromosome. @since 3.0 @param array the array into which the elements of this chromosomes are ...
[ "Returns", "an", "long", "array", "containing", "all", "of", "the", "elements", "in", "this", "chromosome", "in", "proper", "sequence", ".", "If", "the", "chromosome", "fits", "in", "the", "specified", "array", "it", "is", "returned", "therein", ".", "Otherw...
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/LongChromosome.java#L167-L174
52,804
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java
MathExpr.eval
public double eval(final double... args) { final double val = apply( DoubleStream.of(args) .boxed() .toArray(Double[]::new) ); return val == -0.0 ? 0.0 : val; }
java
public double eval(final double... args) { final double val = apply( DoubleStream.of(args) .boxed() .toArray(Double[]::new) ); return val == -0.0 ? 0.0 : val; }
[ "public", "double", "eval", "(", "final", "double", "...", "args", ")", "{", "final", "double", "val", "=", "apply", "(", "DoubleStream", ".", "of", "(", "args", ")", ".", "boxed", "(", ")", ".", "toArray", "(", "Double", "[", "]", "::", "new", ")"...
Convenient method, which lets you apply the program function without explicitly create a wrapper array. <pre>{@code final double result = MathExpr.parse("2*z + 3*x - y").eval(3, 2, 1); assert result == 9.0; }</pre> @see #apply(Double[]) @see #eval(String, double...) @param args the function arguments @return the eva...
[ "Convenient", "method", "which", "lets", "you", "apply", "the", "program", "function", "without", "explicitly", "create", "a", "wrapper", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java#L148-L155
52,805
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java
MathExpr.simplify
public static Tree<? extends Op<Double>, ?> simplify(final Tree<? extends Op<Double>, ?> tree) { return MathExprRewriter.prune(TreeNode.ofTree(tree)); }
java
public static Tree<? extends Op<Double>, ?> simplify(final Tree<? extends Op<Double>, ?> tree) { return MathExprRewriter.prune(TreeNode.ofTree(tree)); }
[ "public", "static", "Tree", "<", "?", "extends", "Op", "<", "Double", ">", ",", "?", ">", "simplify", "(", "final", "Tree", "<", "?", "extends", "Op", "<", "Double", ">", ",", "?", ">", "tree", ")", "{", "return", "MathExprRewriter", ".", "prune", ...
Tries to simplify the given math tree. <pre>{@code final Tree<? extends Op<Double>, ?> tree = MathExpr.parseTree("4.0 + 4.0 + x*(5.0 + 13.0)"); final Tree<? extends Op<Double>, ?> simplified = MathExpr.simplify(tree) System.out.println(simplified); }</pre> The simplified tree will be look like this: <pre> {@code add ├...
[ "Tries", "to", "simplify", "the", "given", "math", "tree", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java#L408-L411
52,806
jenetics/jenetics
jenetics.ext/src/main/java/io/jenetics/ext/TreeCrossover.java
TreeCrossover.crossover
private <A> void crossover( final MSeq<Chromosome<G>> c1, final MSeq<Chromosome<G>> c2, final int index ) { @SuppressWarnings("unchecked") final TreeNode<A> tree1 = (TreeNode<A>)TreeNode.ofTree(c1.get(index).getGene()); @SuppressWarnings("unchecked") final TreeNode<A> tree2 = (TreeNode<A>)TreeNode.ofTree...
java
private <A> void crossover( final MSeq<Chromosome<G>> c1, final MSeq<Chromosome<G>> c2, final int index ) { @SuppressWarnings("unchecked") final TreeNode<A> tree1 = (TreeNode<A>)TreeNode.ofTree(c1.get(index).getGene()); @SuppressWarnings("unchecked") final TreeNode<A> tree2 = (TreeNode<A>)TreeNode.ofTree...
[ "private", "<", "A", ">", "void", "crossover", "(", "final", "MSeq", "<", "Chromosome", "<", "G", ">", ">", "c1", ",", "final", "MSeq", "<", "Chromosome", "<", "G", ">", ">", "c2", ",", "final", "int", "index", ")", "{", "@", "SuppressWarnings", "(...
the abstract "crossover" method usually don't have to do additional casts.
[ "the", "abstract", "crossover", "method", "usually", "don", "t", "have", "to", "do", "additional", "casts", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/TreeCrossover.java#L105-L128
52,807
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java
Const.of
public static <T> Const<T> of(final String name, final T value) { return new Const<>(requireNonNull(name), value); }
java
public static <T> Const<T> of(final String name, final T value) { return new Const<>(requireNonNull(name), value); }
[ "public", "static", "<", "T", ">", "Const", "<", "T", ">", "of", "(", "final", "String", "name", ",", "final", "T", "value", ")", "{", "return", "new", "Const", "<>", "(", "requireNonNull", "(", "name", ")", ",", "value", ")", ";", "}" ]
Return a new constant with the given name and value. @param name the constant name @param value the constant value @param <T> the constant type @return a new constant @throws NullPointerException if the given constant {@code name} is {@code null}
[ "Return", "a", "new", "constant", "with", "the", "given", "name", "and", "value", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java#L119-L121
52,808
jenetics/jenetics
jenetics/src/main/java/io/jenetics/CharacterGene.java
CharacterGene.of
public static CharacterGene of(final CharSeq validCharacters) { return new CharacterGene( validCharacters, RandomRegistry.getRandom().nextInt(validCharacters.length()) ); }
java
public static CharacterGene of(final CharSeq validCharacters) { return new CharacterGene( validCharacters, RandomRegistry.getRandom().nextInt(validCharacters.length()) ); }
[ "public", "static", "CharacterGene", "of", "(", "final", "CharSeq", "validCharacters", ")", "{", "return", "new", "CharacterGene", "(", "validCharacters", ",", "RandomRegistry", ".", "getRandom", "(", ")", ".", "nextInt", "(", "validCharacters", ".", "length", "...
Create a new CharacterGene with a randomly chosen character from the set of valid characters. @param validCharacters the valid characters for this gene. @return a new valid, <em>random</em> gene, @throws NullPointerException if the {@code validCharacters} are {@code null}.
[ "Create", "a", "new", "CharacterGene", "with", "a", "randomly", "chosen", "character", "from", "the", "set", "of", "valid", "characters", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/CharacterGene.java#L201-L206
52,809
jenetics/jenetics
jenetics.tool/src/main/java/io/jenetics/tool/evaluation/Diagram.java
Diagram.create
public static void create( final Path input, final Template template, final Params<?> params, final Path output, final SampleSummary summary, final SampleSummary... summaries ) throws IOException { final Stream<SampleSummary> summaryStream = Stream.concat( Stream.of(summary), Stream.of(summaries) ...
java
public static void create( final Path input, final Template template, final Params<?> params, final Path output, final SampleSummary summary, final SampleSummary... summaries ) throws IOException { final Stream<SampleSummary> summaryStream = Stream.concat( Stream.of(summary), Stream.of(summaries) ...
[ "public", "static", "void", "create", "(", "final", "Path", "input", ",", "final", "Template", "template", ",", "final", "Params", "<", "?", ">", "params", ",", "final", "Path", "output", ",", "final", "SampleSummary", "summary", ",", "final", "SampleSummary...
Create a performance diagram. @param input the input data @param template the Gnuplot template to use @param params the diagram parameters (x-axis) @param output the output file @param summary the first summary data @param summaries the rest of the summary data @throws IOException if the diagram generation fails @thro...
[ "Create", "a", "performance", "diagram", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/evaluation/Diagram.java#L146-L187
52,810
jenetics/jenetics
jenetics.tool/src/main/java/io/jenetics/tool/trial/Data.java
Data.summary
public SampleSummary summary() { return _samples.stream() .filter(Sample::isFull) .collect(toSampleSummary(sampleSize())); }
java
public SampleSummary summary() { return _samples.stream() .filter(Sample::isFull) .collect(toSampleSummary(sampleSize())); }
[ "public", "SampleSummary", "summary", "(", ")", "{", "return", "_samples", ".", "stream", "(", ")", ".", "filter", "(", "Sample", "::", "isFull", ")", ".", "collect", "(", "toSampleSummary", "(", "sampleSize", "(", ")", ")", ")", ";", "}" ]
Calculate the sample summary of this data object. @return the sample summary of this data object
[ "Calculate", "the", "sample", "summary", "of", "this", "data", "object", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/Data.java#L127-L131
52,811
jenetics/jenetics
jenetics.tool/src/main/java/io/jenetics/tool/trial/Params.java
Params.of
public static <T> Params<T> of( final String name, final ISeq<T> params ) { return new Params<>(name, params); }
java
public static <T> Params<T> of( final String name, final ISeq<T> params ) { return new Params<>(name, params); }
[ "public", "static", "<", "T", ">", "Params", "<", "T", ">", "of", "(", "final", "String", "name", ",", "final", "ISeq", "<", "T", ">", "params", ")", "{", "return", "new", "Params", "<>", "(", "name", ",", "params", ")", ";", "}" ]
Return a new parameters object. @param name the name of the parameters @param params the actual parameters @param <T> the parameter type @throws NullPointerException if one of the parameters is {@code null} @return a new parameters object
[ "Return", "a", "new", "parameters", "object", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/Params.java#L134-L139
52,812
jenetics/jenetics
jenetics/src/main/java/io/jenetics/AnyGene.java
AnyGene.seq
static <A> ISeq<AnyGene<A>> seq( final IntRange lengthRange, final Supplier<? extends A> supplier, final Predicate<? super A> validator ) { return MSeq.<AnyGene<A>>ofLength(random.nextInt(lengthRange, getRandom())) .fill(() -> of(supplier.get(), supplier, validator)) .toISeq(); }
java
static <A> ISeq<AnyGene<A>> seq( final IntRange lengthRange, final Supplier<? extends A> supplier, final Predicate<? super A> validator ) { return MSeq.<AnyGene<A>>ofLength(random.nextInt(lengthRange, getRandom())) .fill(() -> of(supplier.get(), supplier, validator)) .toISeq(); }
[ "static", "<", "A", ">", "ISeq", "<", "AnyGene", "<", "A", ">", ">", "seq", "(", "final", "IntRange", "lengthRange", ",", "final", "Supplier", "<", "?", "extends", "A", ">", "supplier", ",", "final", "Predicate", "<", "?", "super", "A", ">", "validat...
Create gene sequence.
[ "Create", "gene", "sequence", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/AnyGene.java#L209-L217
52,813
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/util/bit.java
bit.swap
public static void swap( final byte[] data, final int start, final int end, final byte[] otherData, final int otherStart ) { for (int i = end - start; --i >= 0;) { final boolean temp = get(data, i + start); set(data, i + start, get(otherData, otherStart + i)); set(otherData, otherStart + i, temp); } ...
java
public static void swap( final byte[] data, final int start, final int end, final byte[] otherData, final int otherStart ) { for (int i = end - start; --i >= 0;) { final boolean temp = get(data, i + start); set(data, i + start, get(otherData, otherStart + i)); set(otherData, otherStart + i, temp); } ...
[ "public", "static", "void", "swap", "(", "final", "byte", "[", "]", "data", ",", "final", "int", "start", ",", "final", "int", "end", ",", "final", "byte", "[", "]", "otherData", ",", "final", "int", "otherStart", ")", "{", "for", "(", "int", "i", ...
Swap a given range with a range of the same size with another array. <pre> start end | | data: +---+---+---+---+---+---+---+---+---+---+---+---+ +---------------+ +---------------+ otherData: +---+---+---+---+---+---+---+---+---+---+---+---+ | otherStart </pre> @param data the first byte...
[ "Swap", "a", "given", "range", "with", "a", "range", "of", "the", "same", "size", "with", "another", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L177-L186
52,814
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/util/bit.java
bit.flip
public static byte[] flip(final byte[] data, final int index) { return get(data, index) ? unset(data, index) : set(data, index); }
java
public static byte[] flip(final byte[] data, final int index) { return get(data, index) ? unset(data, index) : set(data, index); }
[ "public", "static", "byte", "[", "]", "flip", "(", "final", "byte", "[", "]", "data", ",", "final", "int", "index", ")", "{", "return", "get", "(", "data", ",", "index", ")", "?", "unset", "(", "data", ",", "index", ")", ":", "set", "(", "data", ...
Flip the bit at the given index. @param data the data array. @param index the index of the bit to flip. @return the input array, for command chaining @throws IndexOutOfBoundsException if the index is {@code index >= max || index < 0}. @throws NullPointerException if the {@code data} array is {@code null}.
[ "Flip", "the", "bit", "at", "the", "given", "index", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L342-L344
52,815
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/util/bit.java
bit.copy
public static byte[] copy(final byte[] data, final int start, final int end) { if (start > end) { throw new IllegalArgumentException(String.format( "start > end: %d > %d", start, end )); } if (start < 0 || start > data.length << 3) { throw new ArrayIndexOutOfBoundsException(String.format( "%d < 0...
java
public static byte[] copy(final byte[] data, final int start, final int end) { if (start > end) { throw new IllegalArgumentException(String.format( "start > end: %d > %d", start, end )); } if (start < 0 || start > data.length << 3) { throw new ArrayIndexOutOfBoundsException(String.format( "%d < 0...
[ "public", "static", "byte", "[", "]", "copy", "(", "final", "byte", "[", "]", "data", ",", "final", "int", "start", ",", "final", "int", "end", ")", "{", "if", "(", "start", ">", "end", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Stri...
Copies the specified range of the specified array into a new array. @param data the bits from which a range is to be copied @param start the initial index of the range to be copied, inclusive @param end the final index of the range to be copied, exclusive. @return a new array containing the specified range from the or...
[ "Copies", "the", "specified", "range", "of", "the", "specified", "array", "into", "a", "new", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L376-L413
52,816
jenetics/jenetics
jenetics/src/main/java/io/jenetics/MutatorResult.java
MutatorResult.of
public static <T> MutatorResult<T> of(final T result, final int mutations) { return new MutatorResult<>(result, mutations); }
java
public static <T> MutatorResult<T> of(final T result, final int mutations) { return new MutatorResult<>(result, mutations); }
[ "public", "static", "<", "T", ">", "MutatorResult", "<", "T", ">", "of", "(", "final", "T", "result", ",", "final", "int", "mutations", ")", "{", "return", "new", "MutatorResult", "<>", "(", "result", ",", "mutations", ")", ";", "}" ]
Create a new mutation result with the given values. @param result the mutation result @param mutations the number of mutations @param <T> the mutation result type @return a new mutation result @throws IllegalArgumentException if the given {@code mutations} is negative @throws NullPointerException if the given mutation...
[ "Create", "a", "new", "mutation", "result", "with", "the", "given", "values", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/MutatorResult.java#L106-L108
52,817
jenetics/jenetics
jenetics/src/main/java/io/jenetics/SwapMutator.java
SwapMutator.mutate
@Override protected MutatorResult<Chromosome<G>> mutate( final Chromosome<G> chromosome, final double p, final Random random ) { final MutatorResult<Chromosome<G>> result; if (chromosome.length() > 1) { final MSeq<G> genes = chromosome.toSeq().copy(); final int mutations = (int)indexes(random, genes.l...
java
@Override protected MutatorResult<Chromosome<G>> mutate( final Chromosome<G> chromosome, final double p, final Random random ) { final MutatorResult<Chromosome<G>> result; if (chromosome.length() > 1) { final MSeq<G> genes = chromosome.toSeq().copy(); final int mutations = (int)indexes(random, genes.l...
[ "@", "Override", "protected", "MutatorResult", "<", "Chromosome", "<", "G", ">", ">", "mutate", "(", "final", "Chromosome", "<", "G", ">", "chromosome", ",", "final", "double", "p", ",", "final", "Random", "random", ")", "{", "final", "MutatorResult", "<",...
Swaps the genes in the given array, with the mutation probability of this mutation.
[ "Swaps", "the", "genes", "in", "the", "given", "array", "with", "the", "mutation", "probability", "of", "this", "mutation", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/SwapMutator.java#L70-L91
52,818
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/util/require.java
require.nonNegative
public static double nonNegative(final double value, final String message) { if (value < 0) { throw new IllegalArgumentException(format( "%s must not be negative: %f.", message, value )); } return value; }
java
public static double nonNegative(final double value, final String message) { if (value < 0) { throw new IllegalArgumentException(format( "%s must not be negative: %f.", message, value )); } return value; }
[ "public", "static", "double", "nonNegative", "(", "final", "double", "value", ",", "final", "String", "message", ")", "{", "if", "(", "value", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "format", "(", "\"%s must not be negative: %f.\"",...
Check if the specified value is not negative. @param value the value to check. @param message the exception message. @return the given value. @throws IllegalArgumentException if {@code value < 0}.
[ "Check", "if", "the", "specified", "value", "is", "not", "negative", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/require.java#L42-L49
52,819
jenetics/jenetics
jenetics.doc/src/main/java/Knapsack.java
Knapsack.fitness
static Function<ISeq<Item>, Double> fitness(final double size) { return items -> { final Item sum = items.stream().collect(Item.toSum()); return sum.size <= size ? sum.value : 0; }; }
java
static Function<ISeq<Item>, Double> fitness(final double size) { return items -> { final Item sum = items.stream().collect(Item.toSum()); return sum.size <= size ? sum.value : 0; }; }
[ "static", "Function", "<", "ISeq", "<", "Item", ">", ",", "Double", ">", "fitness", "(", "final", "double", "size", ")", "{", "return", "items", "->", "{", "final", "Item", "sum", "=", "items", ".", "stream", "(", ")", ".", "collect", "(", "Item", ...
Creating the fitness function.
[ "Creating", "the", "fitness", "function", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.doc/src/main/java/Knapsack.java#L56-L62
52,820
jenetics/jenetics
jenetics/src/main/java/io/jenetics/stat/DoubleMoments.java
DoubleMoments.of
public static DoubleMoments of( final long count, final double min, final double max, final double sum, final double mean, final double variance, final double skewness, final double kurtosis ) { return new DoubleMoments( count, min, max, sum, mean, variance, skewness, kurtosis...
java
public static DoubleMoments of( final long count, final double min, final double max, final double sum, final double mean, final double variance, final double skewness, final double kurtosis ) { return new DoubleMoments( count, min, max, sum, mean, variance, skewness, kurtosis...
[ "public", "static", "DoubleMoments", "of", "(", "final", "long", "count", ",", "final", "double", "min", ",", "final", "double", "max", ",", "final", "double", "sum", ",", "final", "double", "mean", ",", "final", "double", "variance", ",", "final", "double...
Create an immutable object which contains statistical values. @param count the count of values recorded @param min the minimum value @param max the maximum value @param sum the sum of the recorded values @param mean the arithmetic mean of values @param variance the variance of values @param skewness the skewness of va...
[ "Create", "an", "immutable", "object", "which", "contains", "statistical", "values", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/DoubleMoments.java#L222-L242
52,821
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java
ProgramChromosome.create
private static <A> ProgramChromosome<A> create( final Tree<? extends Op<A>, ?> program, final Predicate<? super ProgramChromosome<A>> validator, final ISeq<? extends Op<A>> operations, final ISeq<? extends Op<A>> terminals ) { final ISeq<ProgramGene<A>> genes = FlatTreeNode.of(program).stream() .map(n -> ...
java
private static <A> ProgramChromosome<A> create( final Tree<? extends Op<A>, ?> program, final Predicate<? super ProgramChromosome<A>> validator, final ISeq<? extends Op<A>> operations, final ISeq<? extends Op<A>> terminals ) { final ISeq<ProgramGene<A>> genes = FlatTreeNode.of(program).stream() .map(n -> ...
[ "private", "static", "<", "A", ">", "ProgramChromosome", "<", "A", ">", "create", "(", "final", "Tree", "<", "?", "extends", "Op", "<", "A", ">", ",", "?", ">", "program", ",", "final", "Predicate", "<", "?", "super", "ProgramChromosome", "<", "A", "...
Create the chromosomes without checks.
[ "Create", "the", "chromosomes", "without", "checks", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java#L212-L224
52,822
jenetics/jenetics
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java
TreeParser.tokenize
static List<Token> tokenize(final String value) { final List<Token> tokens = new ArrayList<>(); char pc = '\0'; int pos = 0; final StringBuilder token = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { final char c = value.charAt(i); if (isTokenSeparator(c) && pc != ESCAPE_CHAR) { t...
java
static List<Token> tokenize(final String value) { final List<Token> tokens = new ArrayList<>(); char pc = '\0'; int pos = 0; final StringBuilder token = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { final char c = value.charAt(i); if (isTokenSeparator(c) && pc != ESCAPE_CHAR) { t...
[ "static", "List", "<", "Token", ">", "tokenize", "(", "final", "String", "value", ")", "{", "final", "List", "<", "Token", ">", "tokens", "=", "new", "ArrayList", "<>", "(", ")", ";", "char", "pc", "=", "'", "'", ";", "int", "pos", "=", "0", ";",...
Tokenize the given parentheses string. @param value the parentheses string @return the parentheses string tokens @throws NullPointerException if the given {@code value} is {@code null}
[ "Tokenize", "the", "given", "parentheses", "string", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java#L63-L89
52,823
jenetics/jenetics
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java
TreeParser.parse
static <B> TreeNode<B> parse( final String value, final Function<? super String, ? extends B> mapper ) { requireNonNull(value); requireNonNull(mapper); final TreeNode<B> root = TreeNode.of(); final Deque<TreeNode<B>> parents = new ArrayDeque<>(); TreeNode<B> current = root; for (Token token : tokeniz...
java
static <B> TreeNode<B> parse( final String value, final Function<? super String, ? extends B> mapper ) { requireNonNull(value); requireNonNull(mapper); final TreeNode<B> root = TreeNode.of(); final Deque<TreeNode<B>> parents = new ArrayDeque<>(); TreeNode<B> current = root; for (Token token : tokeniz...
[ "static", "<", "B", ">", "TreeNode", "<", "B", ">", "parse", "(", "final", "String", "value", ",", "final", "Function", "<", "?", "super", "String", ",", "?", "extends", "B", ">", "mapper", ")", "{", "requireNonNull", "(", "value", ")", ";", "require...
Parses the given parentheses tree string @since 4.3 @param <B> the tree node value type @param value the parentheses tree string @param mapper the mapper which converts the serialized string value to the desired type @return the parsed tree object @throws NullPointerException if one of the arguments is {@code null} @...
[ "Parses", "the", "given", "parentheses", "tree", "string" ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java#L109-L179
52,824
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java
ProgramGene.newInstance
@Override public ProgramGene<A> newInstance(final Op<A> op) { if (getValue().arity() != op.arity()) { throw new IllegalArgumentException(format( "New operation must have same arity: %s[%d] != %s[%d]", getValue().name(), getValue().arity(), op.name(), op.arity() )); } return new ProgramGene<>(op, ch...
java
@Override public ProgramGene<A> newInstance(final Op<A> op) { if (getValue().arity() != op.arity()) { throw new IllegalArgumentException(format( "New operation must have same arity: %s[%d] != %s[%d]", getValue().name(), getValue().arity(), op.name(), op.arity() )); } return new ProgramGene<>(op, ch...
[ "@", "Override", "public", "ProgramGene", "<", "A", ">", "newInstance", "(", "final", "Op", "<", "A", ">", "op", ")", "{", "if", "(", "getValue", "(", ")", ".", "arity", "(", ")", "!=", "op", ".", "arity", "(", ")", ")", "{", "throw", "new", "I...
Create a new program gene with the given operation. @param op the operation of the new program gene @return a new program gene with the given operation @throws NullPointerException if the given {@code op} is {@code null} @throws IllegalArgumentException if the arity of the given operation is different from the arity o...
[ "Create", "a", "new", "program", "gene", "with", "the", "given", "operation", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java#L170-L179
52,825
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/Engine.java
Engine.selectSurvivors
private ISeq<Phenotype<G, C>> selectSurvivors(final ISeq<Phenotype<G, C>> population) { return _survivorsCount > 0 ?_survivorsSelector.select(population, _survivorsCount, _optimize) : ISeq.empty(); }
java
private ISeq<Phenotype<G, C>> selectSurvivors(final ISeq<Phenotype<G, C>> population) { return _survivorsCount > 0 ?_survivorsSelector.select(population, _survivorsCount, _optimize) : ISeq.empty(); }
[ "private", "ISeq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "selectSurvivors", "(", "final", "ISeq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "population", ")", "{", "return", "_survivorsCount", ">", "0", "?", "_survivorsSelector", ".", "...
Selects the survivors population. A new population object is returned.
[ "Selects", "the", "survivors", "population", ".", "A", "new", "population", "object", "is", "returned", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L373-L378
52,826
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/Engine.java
Engine.selectOffspring
private ISeq<Phenotype<G, C>> selectOffspring(final ISeq<Phenotype<G, C>> population) { return _offspringCount > 0 ? _offspringSelector.select(population, _offspringCount, _optimize) : ISeq.empty(); }
java
private ISeq<Phenotype<G, C>> selectOffspring(final ISeq<Phenotype<G, C>> population) { return _offspringCount > 0 ? _offspringSelector.select(population, _offspringCount, _optimize) : ISeq.empty(); }
[ "private", "ISeq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "selectOffspring", "(", "final", "ISeq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "population", ")", "{", "return", "_offspringCount", ">", "0", "?", "_offspringSelector", ".", "...
Selects the offspring population. A new population object is returned.
[ "Selects", "the", "offspring", "population", ".", "A", "new", "population", "object", "is", "returned", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L381-L386
52,827
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/Engine.java
Engine.filter
private FilterResult<G, C> filter( final Seq<Phenotype<G, C>> population, final long generation ) { int killCount = 0; int invalidCount = 0; final MSeq<Phenotype<G, C>> pop = MSeq.of(population); for (int i = 0, n = pop.size(); i < n; ++i) { final Phenotype<G, C> individual = pop.get(i); if (!_vali...
java
private FilterResult<G, C> filter( final Seq<Phenotype<G, C>> population, final long generation ) { int killCount = 0; int invalidCount = 0; final MSeq<Phenotype<G, C>> pop = MSeq.of(population); for (int i = 0, n = pop.size(); i < n; ++i) { final Phenotype<G, C> individual = pop.get(i); if (!_vali...
[ "private", "FilterResult", "<", "G", ",", "C", ">", "filter", "(", "final", "Seq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "population", ",", "final", "long", "generation", ")", "{", "int", "killCount", "=", "0", ";", "int", "invalidCount", "...
Filters out invalid and old individuals. Filtering is done in place.
[ "Filters", "out", "invalid", "and", "old", "individuals", ".", "Filtering", "is", "done", "in", "place", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L389-L410
52,828
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/Engine.java
Engine.newPhenotype
private Phenotype<G, C> newPhenotype(final long generation) { int count = 0; Phenotype<G, C> phenotype; do { phenotype = Phenotype.of( _genotypeFactory.newInstance(), generation, _fitnessFunction, _fitnessScaler ); } while (++count < _individualCreationRetries && !_validator.test(pheno...
java
private Phenotype<G, C> newPhenotype(final long generation) { int count = 0; Phenotype<G, C> phenotype; do { phenotype = Phenotype.of( _genotypeFactory.newInstance(), generation, _fitnessFunction, _fitnessScaler ); } while (++count < _individualCreationRetries && !_validator.test(pheno...
[ "private", "Phenotype", "<", "G", ",", "C", ">", "newPhenotype", "(", "final", "long", "generation", ")", "{", "int", "count", "=", "0", ";", "Phenotype", "<", "G", ",", "C", ">", "phenotype", ";", "do", "{", "phenotype", "=", "Phenotype", ".", "of",...
Create a new and valid phenotype
[ "Create", "a", "new", "and", "valid", "phenotype" ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L413-L427
52,829
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java
Program.eval
@SafeVarargs public static <T> T eval( final Tree<? extends Op<T>, ?> tree, final T... variables ) { requireNonNull(tree); requireNonNull(variables); final Op<T> op = tree.getValue(); return op.isTerminal() ? eval(op, variables) : eval(op, tree.childStream() .map(child -> eval(child, var...
java
@SafeVarargs public static <T> T eval( final Tree<? extends Op<T>, ?> tree, final T... variables ) { requireNonNull(tree); requireNonNull(variables); final Op<T> op = tree.getValue(); return op.isTerminal() ? eval(op, variables) : eval(op, tree.childStream() .map(child -> eval(child, var...
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "T", "eval", "(", "final", "Tree", "<", "?", "extends", "Op", "<", "T", ">", ",", "?", ">", "tree", ",", "final", "T", "...", "variables", ")", "{", "requireNonNull", "(", "tree", ")", ";", "...
Evaluates the given operation tree with the given variables. @param <T> the argument type @param tree the operation tree @param variables the input variables @return the result of the operation tree evaluation @throws NullPointerException if one of the arguments is {@code null} @throws IllegalArgumentException if the ...
[ "Evaluates", "the", "given", "operation", "tree", "with", "the", "given", "variables", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L164-L180
52,830
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java
Program.check
public static void check(final Tree<? extends Op<?>, ?> program) { requireNonNull(program); program.forEach(Program::checkArity); }
java
public static void check(final Tree<? extends Op<?>, ?> program) { requireNonNull(program); program.forEach(Program::checkArity); }
[ "public", "static", "void", "check", "(", "final", "Tree", "<", "?", "extends", "Op", "<", "?", ">", ",", "?", ">", "program", ")", "{", "requireNonNull", "(", "program", ")", ";", "program", ".", "forEach", "(", "Program", "::", "checkArity", ")", "...
Validates the given program tree. @param program the program to validate @throws NullPointerException if the given {@code program} is {@code null} @throws IllegalArgumentException if the given operation tree is invalid, which means there is at least one node where the operation arity and the node child count differ.
[ "Validates", "the", "given", "program", "tree", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L207-L210
52,831
jenetics/jenetics
jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java
Program.offsets
static int[] offsets(final ISeq<? extends FlatTree<? extends Op<?>, ?>> nodes) { final int[] offsets = new int[nodes.size()]; int offset = 1; for (int i = 0; i < offsets.length; ++i) { final Op<?> op = nodes.get(i).getValue(); offsets[i] = op.isTerminal() ? -1 : offset; offset += op.arity(); } re...
java
static int[] offsets(final ISeq<? extends FlatTree<? extends Op<?>, ?>> nodes) { final int[] offsets = new int[nodes.size()]; int offset = 1; for (int i = 0; i < offsets.length; ++i) { final Op<?> op = nodes.get(i).getValue(); offsets[i] = op.isTerminal() ? -1 : offset; offset += op.arity(); } re...
[ "static", "int", "[", "]", "offsets", "(", "final", "ISeq", "<", "?", "extends", "FlatTree", "<", "?", "extends", "Op", "<", "?", ">", ",", "?", ">", ">", "nodes", ")", "{", "final", "int", "[", "]", "offsets", "=", "new", "int", "[", "nodes", ...
Create the offset array for the given nodes. The offsets are calculated using the arity of the stored operations. @param nodes the flattened tree nodes @return the offset array for the given nodes
[ "Create", "the", "offset", "array", "for", "the", "given", "nodes", ".", "The", "offsets", "are", "calculated", "using", "the", "arity", "of", "the", "stored", "operations", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L449-L462
52,832
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/math/base.java
base.divide
public static void divide(final double[] values, final double divisor) { for (int i = values.length; --i >= 0;) { values[i] /= divisor; } }
java
public static void divide(final double[] values, final double divisor) { for (int i = values.length; --i >= 0;) { values[i] /= divisor; } }
[ "public", "static", "void", "divide", "(", "final", "double", "[", "]", "values", ",", "final", "double", "divisor", ")", "{", "for", "(", "int", "i", "=", "values", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "values", "[", "i", "]"...
Component wise division of the given double array. @param values the double values to divide. @param divisor the divisor. @throws NullPointerException if the given double array is {@code null}.
[ "Component", "wise", "division", "of", "the", "given", "double", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/math/base.java#L71-L75
52,833
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/math/base.java
base.pow
public static long pow(final long b, final long e) { long base = b; long exp = e; long result = 1; while (exp != 0) { if ((exp & 1) != 0) { result *= base; } exp >>>= 1; base *= base; } return result; }
java
public static long pow(final long b, final long e) { long base = b; long exp = e; long result = 1; while (exp != 0) { if ((exp & 1) != 0) { result *= base; } exp >>>= 1; base *= base; } return result; }
[ "public", "static", "long", "pow", "(", "final", "long", "b", ",", "final", "long", "e", ")", "{", "long", "base", "=", "b", ";", "long", "exp", "=", "e", ";", "long", "result", "=", "1", ";", "while", "(", "exp", "!=", "0", ")", "{", "if", "...
Binary exponentiation algorithm. @param b the base number. @param e the exponent. @return {@code b^e}.
[ "Binary", "exponentiation", "algorithm", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/math/base.java#L84-L98
52,834
jenetics/jenetics
jenetics/src/main/java/io/jenetics/TruncationSelector.java
TruncationSelector.select
@Override public ISeq<Phenotype<G, C>> select( final Seq<Phenotype<G, C>> population, final int count, final Optimize opt ) { requireNonNull(population, "Population"); requireNonNull(opt, "Optimization"); if (count < 0) { throw new IllegalArgumentException(format( "Selection count must be greater o...
java
@Override public ISeq<Phenotype<G, C>> select( final Seq<Phenotype<G, C>> population, final int count, final Optimize opt ) { requireNonNull(population, "Population"); requireNonNull(opt, "Optimization"); if (count < 0) { throw new IllegalArgumentException(format( "Selection count must be greater o...
[ "@", "Override", "public", "ISeq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "select", "(", "final", "Seq", "<", "Phenotype", "<", "G", ",", "C", ">", ">", "population", ",", "final", "int", "count", ",", "final", "Optimize", "opt", ")", "{",...
This method sorts the population in descending order while calculating the selection probabilities. If the selection size is greater the the population size, the whole population is duplicated until the desired sample size is reached. @throws NullPointerException if the {@code population} or {@code opt} is {@code null...
[ "This", "method", "sorts", "the", "population", "in", "descending", "order", "while", "calculating", "the", "selection", "probabilities", ".", "If", "the", "selection", "size", "is", "greater", "the", "the", "population", "size", "the", "whole", "population", "i...
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/TruncationSelector.java#L92-L127
52,835
jenetics/jenetics
jenetics/src/main/java/io/jenetics/internal/util/Concurrency.java
Concurrency.with
public static Concurrency with(final Executor executor) { if (executor instanceof ForkJoinPool) { return new ForkJoinPoolConcurrency((ForkJoinPool)executor); } else if (executor instanceof ExecutorService) { return new ExecutorServiceConcurrency((ExecutorService)executor); } else if (executor == SERIAL_EXEC...
java
public static Concurrency with(final Executor executor) { if (executor instanceof ForkJoinPool) { return new ForkJoinPoolConcurrency((ForkJoinPool)executor); } else if (executor instanceof ExecutorService) { return new ExecutorServiceConcurrency((ExecutorService)executor); } else if (executor == SERIAL_EXEC...
[ "public", "static", "Concurrency", "with", "(", "final", "Executor", "executor", ")", "{", "if", "(", "executor", "instanceof", "ForkJoinPool", ")", "{", "return", "new", "ForkJoinPoolConcurrency", "(", "(", "ForkJoinPool", ")", "executor", ")", ";", "}", "els...
Return an new Concurrency object from the given executor. @param executor the underlying Executor @return a new Concurrency object
[ "Return", "an", "new", "Concurrency", "object", "from", "the", "given", "executor", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Concurrency.java#L73-L83
52,836
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java
EvolutionResult.getGenotypes
public ISeq<Genotype<G>> getGenotypes() { return _population.stream() .map(Phenotype::getGenotype) .collect(ISeq.toISeq()); }
java
public ISeq<Genotype<G>> getGenotypes() { return _population.stream() .map(Phenotype::getGenotype) .collect(ISeq.toISeq()); }
[ "public", "ISeq", "<", "Genotype", "<", "G", ">", ">", "getGenotypes", "(", ")", "{", "return", "_population", ".", "stream", "(", ")", ".", "map", "(", "Phenotype", "::", "getGenotype", ")", ".", "collect", "(", "ISeq", ".", "toISeq", "(", ")", ")",...
Return the current list of genotypes of this evolution result. @since 3.9 @return the list of genotypes of this evolution result.
[ "Return", "the", "current", "list", "of", "genotypes", "of", "this", "evolution", "result", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L146-L150
52,837
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java
EvolutionResult.toBestEvolutionResult
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, EvolutionResult<G, C>> toBestEvolutionResult() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().withTotalGenerat...
java
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, EvolutionResult<G, C>> toBestEvolutionResult() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().withTotalGenerat...
[ "public", "static", "<", "G", "extends", "Gene", "<", "?", ",", "G", ">", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "Collector", "<", "EvolutionResult", "<", "G", ",", "C", ">", ",", "?", ",", "EvolutionResult", "<", "G",...
Return a collector which collects the best result of an evolution stream. <pre>{@code final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...; final EvolutionResult<EnumGene<Point>, Double> result = Engine.builder(tsm) .optimize(Optimize.MINIMUM).build() .stream() .limit(100) .collect(EvolutionResult.toBestEvolu...
[ "Return", "a", "collector", "which", "collects", "the", "best", "result", "of", "an", "evolution", "stream", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L355-L366
52,838
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java
EvolutionResult.toBestPhenotype
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, Phenotype<G, C>> toBestPhenotype() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().getBestPhenotype() : nul...
java
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, Phenotype<G, C>> toBestPhenotype() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().getBestPhenotype() : nul...
[ "public", "static", "<", "G", "extends", "Gene", "<", "?", ",", "G", ">", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "Collector", "<", "EvolutionResult", "<", "G", ",", "C", ">", ",", "?", ",", "Phenotype", "<", "G", ","...
Return a collector which collects the best phenotype of an evolution stream. <pre>{@code final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...; final Phenotype<EnumGene<Point>, Double> result = Engine.builder(tsm) .optimize(Optimize.MINIMUM).build() .stream() .limit(100) .collect(EvolutionResult.toBestPhenotyp...
[ "Return", "a", "collector", "which", "collects", "the", "best", "phenotype", "of", "an", "evolution", "stream", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L389-L400
52,839
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java
EvolutionResult.toBestGenotype
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, Genotype<G>> toBestGenotype() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().getBestPhenotype() != null ?...
java
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Collector<EvolutionResult<G, C>, ?, Genotype<G>> toBestGenotype() { return Collector.of( MinMax::<EvolutionResult<G, C>>of, MinMax::accept, MinMax::combine, mm -> mm.getMax() != null ? mm.getMax().getBestPhenotype() != null ?...
[ "public", "static", "<", "G", "extends", "Gene", "<", "?", ",", "G", ">", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "Collector", "<", "EvolutionResult", "<", "G", ",", "C", ">", ",", "?", ",", "Genotype", "<", "G", ">",...
Return a collector which collects the best genotype of an evolution stream. <pre>{@code final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...; final Genotype<EnumGene<Point>> result = Engine.builder(tsm) .optimize(Optimize.MINIMUM).build() .stream() .limit(100) .collect(EvolutionResult.toBestGenotype()); }</pr...
[ "Return", "a", "collector", "which", "collects", "the", "best", "genotype", "of", "an", "evolution", "stream", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L423-L436
52,840
jenetics/jenetics
jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java
EvolutionResult.toUniquePopulation
public static <G extends Gene<?, G>, C extends Comparable<? super C>> UnaryOperator<EvolutionResult<G, C>> toUniquePopulation(final int maxRetries) { return result -> { final Factory<Genotype<G>> factory = result .getPopulation().get(0) .getGenotype(); final UnaryOperator<EvolutionResult<G, C>> unifie...
java
public static <G extends Gene<?, G>, C extends Comparable<? super C>> UnaryOperator<EvolutionResult<G, C>> toUniquePopulation(final int maxRetries) { return result -> { final Factory<Genotype<G>> factory = result .getPopulation().get(0) .getGenotype(); final UnaryOperator<EvolutionResult<G, C>> unifie...
[ "public", "static", "<", "G", "extends", "Gene", "<", "?", ",", "G", ">", ",", "C", "extends", "Comparable", "<", "?", "super", "C", ">", ">", "UnaryOperator", "<", "EvolutionResult", "<", "G", ",", "C", ">", ">", "toUniquePopulation", "(", "final", ...
Return a mapping function, which removes duplicate individuals from the population and replaces it with newly created one by the existing genotype factory. <pre>{@code final Problem<Double, DoubleGene, Integer> problem = ...; final Engine<DoubleGene, Integer> engine = Engine.builder(problem) .mapping(EvolutionResult.t...
[ "Return", "a", "mapping", "function", "which", "removes", "duplicate", "individuals", "from", "the", "population", "and", "replaces", "it", "with", "newly", "created", "one", "by", "the", "existing", "genotype", "factory", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L643-L655
52,841
jenetics/jenetics
jenetics.ext/src/main/java/io/jenetics/ext/SingleNodeCrossover.java
SingleNodeCrossover.swap
static <A> int swap(final TreeNode<A> that, final TreeNode<A> other) { assert that != null; assert other != null; final Random random = RandomRegistry.getRandom(); final ISeq<TreeNode<A>> seq1 = that.breadthFirstStream() .collect(ISeq.toISeq()); final ISeq<TreeNode<A>> seq2 = other.breadthFirstStream() ...
java
static <A> int swap(final TreeNode<A> that, final TreeNode<A> other) { assert that != null; assert other != null; final Random random = RandomRegistry.getRandom(); final ISeq<TreeNode<A>> seq1 = that.breadthFirstStream() .collect(ISeq.toISeq()); final ISeq<TreeNode<A>> seq2 = other.breadthFirstStream() ...
[ "static", "<", "A", ">", "int", "swap", "(", "final", "TreeNode", "<", "A", ">", "that", ",", "final", "TreeNode", "<", "A", ">", "other", ")", "{", "assert", "that", "!=", "null", ";", "assert", "other", "!=", "null", ";", "final", "Random", "rand...
The static method makes it easier to test.
[ "The", "static", "method", "makes", "it", "easier", "to", "test", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/SingleNodeCrossover.java#L94-L126
52,842
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.sortAndRevert
static double[] sortAndRevert(final double[] array) { final int[] indexes = sort(array); // Copy the elements in reversed order. final double[] result = new double[array.length]; for (int i = 0; i < result.length; ++i) { result[indexes[result.length - 1 - i]] = array[indexes[i]]; } return result; }
java
static double[] sortAndRevert(final double[] array) { final int[] indexes = sort(array); // Copy the elements in reversed order. final double[] result = new double[array.length]; for (int i = 0; i < result.length; ++i) { result[indexes[result.length - 1 - i]] = array[indexes[i]]; } return result; }
[ "static", "double", "[", "]", "sortAndRevert", "(", "final", "double", "[", "]", "array", ")", "{", "final", "int", "[", "]", "indexes", "=", "sort", "(", "array", ")", ";", "// Copy the elements in reversed order.", "final", "double", "[", "]", "result", ...
Package private for testing.
[ "Package", "private", "for", "testing", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L159-L169
52,843
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.checkAndCorrect
private static void checkAndCorrect(final double[] probabilities) { boolean ok = true; for (int i = probabilities.length; --i >= 0 && ok;) { ok = Double.isFinite(probabilities[i]); } if (!ok) { final double value = 1.0/probabilities.length; for (int i = probabilities.length; --i >= 0;) { probabili...
java
private static void checkAndCorrect(final double[] probabilities) { boolean ok = true; for (int i = probabilities.length; --i >= 0 && ok;) { ok = Double.isFinite(probabilities[i]); } if (!ok) { final double value = 1.0/probabilities.length; for (int i = probabilities.length; --i >= 0;) { probabili...
[ "private", "static", "void", "checkAndCorrect", "(", "final", "double", "[", "]", "probabilities", ")", "{", "boolean", "ok", "=", "true", ";", "for", "(", "int", "i", "=", "probabilities", ".", "length", ";", "--", "i", ">=", "0", "&&", "ok", ";", "...
Checks if the given probability values are finite. If not, all values are set to the same probability. @param probabilities the probabilities to check.
[ "Checks", "if", "the", "given", "probability", "values", "are", "finite", ".", "If", "not", "all", "values", "are", "set", "to", "the", "same", "probability", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L202-L214
52,844
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.sum2one
static boolean sum2one(final double[] probabilities) { final double sum = probabilities.length > 0 ? DoubleAdder.sum(probabilities) : 1.0; return abs(ulpDistance(sum, 1.0)) < MAX_ULP_DISTANCE; }
java
static boolean sum2one(final double[] probabilities) { final double sum = probabilities.length > 0 ? DoubleAdder.sum(probabilities) : 1.0; return abs(ulpDistance(sum, 1.0)) < MAX_ULP_DISTANCE; }
[ "static", "boolean", "sum2one", "(", "final", "double", "[", "]", "probabilities", ")", "{", "final", "double", "sum", "=", "probabilities", ".", "length", ">", "0", "?", "DoubleAdder", ".", "sum", "(", "probabilities", ")", ":", "1.0", ";", "return", "a...
Check if the given probabilities sum to one. @param probabilities the probabilities to check. @return {@code true} if the sum of the probabilities are within the error range, {@code false} otherwise.
[ "Check", "if", "the", "given", "probabilities", "sum", "to", "one", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L223-L228
52,845
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.indexOfBinary
static int indexOfBinary(final double[] incr, final double v) { int imin = 0; int imax = incr.length; int index = -1; while (imax > imin && index == -1) { final int imid = (imin + imax) >>> 1; if (imid == 0 || (incr[imid] >= v && incr[imid - 1] < v)) { index = imid; } else if (incr[imid] <= v) { ...
java
static int indexOfBinary(final double[] incr, final double v) { int imin = 0; int imax = incr.length; int index = -1; while (imax > imin && index == -1) { final int imid = (imin + imax) >>> 1; if (imid == 0 || (incr[imid] >= v && incr[imid - 1] < v)) { index = imid; } else if (incr[imid] <= v) { ...
[ "static", "int", "indexOfBinary", "(", "final", "double", "[", "]", "incr", ",", "final", "double", "v", ")", "{", "int", "imin", "=", "0", ";", "int", "imax", "=", "incr", ".", "length", ";", "int", "index", "=", "-", "1", ";", "while", "(", "im...
Perform a binary-search on the summed probability array.
[ "Perform", "a", "binary", "-", "search", "on", "the", "summed", "probability", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L243-L261
52,846
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.indexOfSerial
static int indexOfSerial(final double[] incr, final double v) { int index = -1; for (int i = 0; i < incr.length && index == -1; ++i) { if (incr[i] >= v) { index = i; } } return index; }
java
static int indexOfSerial(final double[] incr, final double v) { int index = -1; for (int i = 0; i < incr.length && index == -1; ++i) { if (incr[i] >= v) { index = i; } } return index; }
[ "static", "int", "indexOfSerial", "(", "final", "double", "[", "]", "incr", ",", "final", "double", "v", ")", "{", "int", "index", "=", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "incr", ".", "length", "&&", "index", "==", ...
Perform a serial-search on the summed probability array.
[ "Perform", "a", "serial", "-", "search", "on", "the", "summed", "probability", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L266-L275
52,847
jenetics/jenetics
jenetics/src/main/java/io/jenetics/ProbabilitySelector.java
ProbabilitySelector.incremental
static double[] incremental(final double[] values) { final DoubleAdder adder = new DoubleAdder(values[0]); for (int i = 1; i < values.length; ++i) { values[i] = adder.add(values[i]).doubleValue(); } return values; }
java
static double[] incremental(final double[] values) { final DoubleAdder adder = new DoubleAdder(values[0]); for (int i = 1; i < values.length; ++i) { values[i] = adder.add(values[i]).doubleValue(); } return values; }
[ "static", "double", "[", "]", "incremental", "(", "final", "double", "[", "]", "values", ")", "{", "final", "DoubleAdder", "adder", "=", "new", "DoubleAdder", "(", "values", "[", "0", "]", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", ...
In-place summation of the probability array.
[ "In", "-", "place", "summation", "of", "the", "probability", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L280-L286
52,848
jenetics/jenetics
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java
TreeNode.getChild
@Override public TreeNode<T> getChild(final int index) { if (_children == null) { throw new ArrayIndexOutOfBoundsException(format( "Child index is out of bounds: %s", index )); } return _children.get(index); }
java
@Override public TreeNode<T> getChild(final int index) { if (_children == null) { throw new ArrayIndexOutOfBoundsException(format( "Child index is out of bounds: %s", index )); } return _children.get(index); }
[ "@", "Override", "public", "TreeNode", "<", "T", ">", "getChild", "(", "final", "int", "index", ")", "{", "if", "(", "_children", "==", "null", ")", "{", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "format", "(", "\"Child index is out of bounds: %s\""...
Returns the child at the specified index in this node's child array. @param index an index into this node's child array @return the tree-node in this node's child array at the specified index @throws ArrayIndexOutOfBoundsException if the {@code index} is out of bounds
[ "Returns", "the", "child", "at", "the", "specified", "index", "in", "this", "node", "s", "child", "array", "." ]
ee516770c65ef529b27deb283f071c85f344eff4
https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java#L122-L131
52,849
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java
ValidationUtils.ensureValidResource
public static void ensureValidResource(JsonNode resource) { if (!resource.has(JSONAPISpecConstants.DATA) && !resource.has(JSONAPISpecConstants.META)) { throw new InvalidJsonApiResourceException(); } }
java
public static void ensureValidResource(JsonNode resource) { if (!resource.has(JSONAPISpecConstants.DATA) && !resource.has(JSONAPISpecConstants.META)) { throw new InvalidJsonApiResourceException(); } }
[ "public", "static", "void", "ensureValidResource", "(", "JsonNode", "resource", ")", "{", "if", "(", "!", "resource", ".", "has", "(", "JSONAPISpecConstants", ".", "DATA", ")", "&&", "!", "resource", ".", "has", "(", "JSONAPISpecConstants", ".", "META", ")",...
Asserts that provided resource has required 'data' or 'meta' node. @param resource resource
[ "Asserts", "that", "provided", "resource", "has", "required", "data", "or", "meta", "node", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java#L25-L29
52,850
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java
ValidationUtils.ensureNotError
public static void ensureNotError(ObjectMapper mapper, JsonNode resourceNode) { if (resourceNode != null && resourceNode.hasNonNull(JSONAPISpecConstants.ERRORS)) { try { throw new ResourceParseException(ErrorUtils.parseError(mapper, resourceNode, Errors.class)); } catch (JsonProcessingException e) { thr...
java
public static void ensureNotError(ObjectMapper mapper, JsonNode resourceNode) { if (resourceNode != null && resourceNode.hasNonNull(JSONAPISpecConstants.ERRORS)) { try { throw new ResourceParseException(ErrorUtils.parseError(mapper, resourceNode, Errors.class)); } catch (JsonProcessingException e) { thr...
[ "public", "static", "void", "ensureNotError", "(", "ObjectMapper", "mapper", ",", "JsonNode", "resourceNode", ")", "{", "if", "(", "resourceNode", "!=", "null", "&&", "resourceNode", ".", "hasNonNull", "(", "JSONAPISpecConstants", ".", "ERRORS", ")", ")", "{", ...
Ensures that provided node does not hold 'errors' attribute. @param resourceNode resource node @throws ResourceParseException
[ "Ensures", "that", "provided", "node", "does", "not", "hold", "errors", "attribute", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java#L46-L54
52,851
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java
JSONAPIDocument.createErrorDocument
@NotNull public static JSONAPIDocument<?> createErrorDocument(Iterable<? extends Error> errors) { JSONAPIDocument<?> result = new JSONAPIDocument(); result.errors = errors; return result; }
java
@NotNull public static JSONAPIDocument<?> createErrorDocument(Iterable<? extends Error> errors) { JSONAPIDocument<?> result = new JSONAPIDocument(); result.errors = errors; return result; }
[ "@", "NotNull", "public", "static", "JSONAPIDocument", "<", "?", ">", "createErrorDocument", "(", "Iterable", "<", "?", "extends", "Error", ">", "errors", ")", "{", "JSONAPIDocument", "<", "?", ">", "result", "=", "new", "JSONAPIDocument", "(", ")", ";", "...
Factory method for creating JSONAPIDocument that holds the Error object. <p> This method should be used in case error response is being built by the server side. </p> @param errors
[ "Factory", "method", "for", "creating", "JSONAPIDocument", "that", "holds", "the", "Error", "object", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java#L114-L119
52,852
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java
JSONAPIDocument.addLink
public void addLink(String linkName, Link link) { if (links == null) { links = new Links(new HashMap<String, Link>()); } links.addLink(linkName, link); }
java
public void addLink(String linkName, Link link) { if (links == null) { links = new Links(new HashMap<String, Link>()); } links.addLink(linkName, link); }
[ "public", "void", "addLink", "(", "String", "linkName", ",", "Link", "link", ")", "{", "if", "(", "links", "==", "null", ")", "{", "links", "=", "new", "Links", "(", "new", "HashMap", "<", "String", ",", "Link", ">", "(", ")", ")", ";", "}", "lin...
Adds a named link. @param linkName the named link to add @param link the link to add
[ "Adds", "a", "named", "link", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java#L173-L178
52,853
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getRelationshipField
public Field getRelationshipField(Class<?> clazz, String fieldName) { return relationshipFieldMap.get(clazz).get(fieldName); }
java
public Field getRelationshipField(Class<?> clazz, String fieldName) { return relationshipFieldMap.get(clazz).get(fieldName); }
[ "public", "Field", "getRelationshipField", "(", "Class", "<", "?", ">", "clazz", ",", "String", "fieldName", ")", "{", "return", "relationshipFieldMap", ".", "get", "(", "clazz", ")", ".", "get", "(", "fieldName", ")", ";", "}" ]
Returns relationship field. @param clazz {@link Class} class holding relationship @param fieldName {@link String} name of the field @return {@link Field} field
[ "Returns", "relationship", "field", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L235-L237
52,854
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getRelationshipType
public Class<?> getRelationshipType(Class<?> clazz, String fieldName) { return relationshipTypeMap.get(clazz).get(fieldName); }
java
public Class<?> getRelationshipType(Class<?> clazz, String fieldName) { return relationshipTypeMap.get(clazz).get(fieldName); }
[ "public", "Class", "<", "?", ">", "getRelationshipType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "fieldName", ")", "{", "return", "relationshipTypeMap", ".", "get", "(", "clazz", ")", ".", "get", "(", "fieldName", ")", ";", "}" ]
Returns a type of a relationship. @param clazz {@link Class} owning the field with relationship annotation @param fieldName {@link String} name of the field @return {@link Class} field type
[ "Returns", "a", "type", "of", "a", "relationship", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L245-L247
52,855
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getTypeName
public String getTypeName(Class<?> clazz) { Type type = typeAnnotations.get(clazz); if (type != null) { return type.value(); } return null; }
java
public String getTypeName(Class<?> clazz) { Type type = typeAnnotations.get(clazz); if (type != null) { return type.value(); } return null; }
[ "public", "String", "getTypeName", "(", "Class", "<", "?", ">", "clazz", ")", "{", "Type", "type", "=", "typeAnnotations", ".", "get", "(", "clazz", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ".", "value", "(", ")", ";",...
Resolves and returns name of the type given to provided class. @param clazz {@link Class} to resolve type name for @return type name or <code>null</code> if type was not registered
[ "Resolves", "and", "returns", "name", "of", "the", "type", "given", "to", "provided", "class", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L285-L292
52,856
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getRelationshipMetaField
public Field getRelationshipMetaField(Class<?> clazz, String relationshipName) { return relationshipMetaFieldMap.get(clazz).get(relationshipName); }
java
public Field getRelationshipMetaField(Class<?> clazz, String relationshipName) { return relationshipMetaFieldMap.get(clazz).get(relationshipName); }
[ "public", "Field", "getRelationshipMetaField", "(", "Class", "<", "?", ">", "clazz", ",", "String", "relationshipName", ")", "{", "return", "relationshipMetaFieldMap", ".", "get", "(", "clazz", ")", ".", "get", "(", "relationshipName", ")", ";", "}" ]
Returns relationship meta field. @param clazz {@link Class} class holding relationship @param relationshipName {@link String} name of the relationship @return {@link Field} field
[ "Returns", "relationship", "meta", "field", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L334-L336
52,857
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getRelationshipMetaType
public Class<?> getRelationshipMetaType(Class<?> clazz, String relationshipName) { return relationshipMetaTypeMap.get(clazz).get(relationshipName); }
java
public Class<?> getRelationshipMetaType(Class<?> clazz, String relationshipName) { return relationshipMetaTypeMap.get(clazz).get(relationshipName); }
[ "public", "Class", "<", "?", ">", "getRelationshipMetaType", "(", "Class", "<", "?", ">", "clazz", ",", "String", "relationshipName", ")", "{", "return", "relationshipMetaTypeMap", ".", "get", "(", "clazz", ")", ".", "get", "(", "relationshipName", ")", ";",...
Returns a type of a relationship meta field. @param clazz {@link Class} owning the field with relationship meta annotation @param relationshipName {@link String} name of the field @return {@link Class} meta field type
[ "Returns", "a", "type", "of", "a", "relationship", "meta", "field", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L344-L346
52,858
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java
ConverterConfiguration.getRelationshipLinksField
public Field getRelationshipLinksField(Class<?> clazz, String relationshipName) { return relationshipLinksFieldMap.get(clazz).get(relationshipName); }
java
public Field getRelationshipLinksField(Class<?> clazz, String relationshipName) { return relationshipLinksFieldMap.get(clazz).get(relationshipName); }
[ "public", "Field", "getRelationshipLinksField", "(", "Class", "<", "?", ">", "clazz", ",", "String", "relationshipName", ")", "{", "return", "relationshipLinksFieldMap", ".", "get", "(", "clazz", ")", ".", "get", "(", "relationshipName", ")", ";", "}" ]
Returns relationship links field. @param clazz {@link Class} class holding relationship @param relationshipName {@link String} name of the relationship @return {@link Field} field
[ "Returns", "relationship", "links", "field", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ConverterConfiguration.java#L354-L356
52,859
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.setTypeResolver
public void setTypeResolver(RelationshipResolver resolver, Class<?> type) { if (resolver != null) { String typeName = ReflectionUtils.getTypeName(type); if (typeName != null) { typedResolvers.put(type, resolver); } } }
java
public void setTypeResolver(RelationshipResolver resolver, Class<?> type) { if (resolver != null) { String typeName = ReflectionUtils.getTypeName(type); if (typeName != null) { typedResolvers.put(type, resolver); } } }
[ "public", "void", "setTypeResolver", "(", "RelationshipResolver", "resolver", ",", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "resolver", "!=", "null", ")", "{", "String", "typeName", "=", "ReflectionUtils", ".", "getTypeName", "(", "type", ")", ...
Registers relationship resolver for given type. Resolver will be used if relationship resolution is enabled trough relationship annotation. @param resolver resolver instance @param type type
[ "Registers", "relationship", "resolver", "for", "given", "type", ".", "Resolver", "will", "be", "used", "if", "relationship", "resolution", "is", "enabled", "trough", "relationship", "annotation", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L131-L139
52,860
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.readObject
@Deprecated public <T> T readObject(byte [] data, Class<T> clazz) { return readDocument(data, clazz).get(); }
java
@Deprecated public <T> T readObject(byte [] data, Class<T> clazz) { return readDocument(data, clazz).get(); }
[ "@", "Deprecated", "public", "<", "T", ">", "T", "readObject", "(", "byte", "[", "]", "data", ",", "Class", "<", "T", ">", "clazz", ")", "{", "return", "readDocument", "(", "data", ",", "clazz", ")", ".", "get", "(", ")", ";", "}" ]
Converts raw data input into requested target type. @param data raw data @param clazz target object @param <T> type @return converted object @throws RuntimeException in case conversion fails
[ "Converts", "raw", "data", "input", "into", "requested", "target", "type", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L148-L151
52,861
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.readObjectCollection
@Deprecated public <T> List<T> readObjectCollection(byte [] data, Class<T> clazz) { return readDocumentCollection(data, clazz).get(); }
java
@Deprecated public <T> List<T> readObjectCollection(byte [] data, Class<T> clazz) { return readDocumentCollection(data, clazz).get(); }
[ "@", "Deprecated", "public", "<", "T", ">", "List", "<", "T", ">", "readObjectCollection", "(", "byte", "[", "]", "data", ",", "Class", "<", "T", ">", "clazz", ")", "{", "return", "readDocumentCollection", "(", "data", ",", "clazz", ")", ".", "get", ...
Converts rawdata input into a collection of requested output objects. @param data raw data input @param clazz target type @param <T> type @return collection of converted elements @throws RuntimeException in case conversion fails
[ "Converts", "rawdata", "input", "into", "a", "collection", "of", "requested", "output", "objects", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L161-L164
52,862
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.readObject
private <T> T readObject(JsonNode source, Class<T> clazz, boolean handleRelationships) throws IOException, IllegalAccessException, InstantiationException { String identifier = createIdentifier(source); T result = (T) resourceCache.get(identifier); if (result == null) { Class<?> type = getActualType(source,...
java
private <T> T readObject(JsonNode source, Class<T> clazz, boolean handleRelationships) throws IOException, IllegalAccessException, InstantiationException { String identifier = createIdentifier(source); T result = (T) resourceCache.get(identifier); if (result == null) { Class<?> type = getActualType(source,...
[ "private", "<", "T", ">", "T", "readObject", "(", "JsonNode", "source", ",", "Class", "<", "T", ">", "clazz", ",", "boolean", "handleRelationships", ")", "throws", "IOException", ",", "IllegalAccessException", ",", "InstantiationException", "{", "String", "ident...
Converts provided input into a target object. After conversion completes any relationships defined are resolved. @param source JSON source @param clazz target type @param <T> type @return converted target object @throws IOException @throws IllegalAccessException
[ "Converts", "provided", "input", "into", "a", "target", "object", ".", "After", "conversion", "completes", "any", "relationships", "defined", "are", "resolved", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L324-L375
52,863
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.parseIncluded
private Map<String, Object> parseIncluded(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { // Get resources Map<String, Object> includedResources = getIncludedResources(parent); if (!included...
java
private Map<String, Object> parseIncluded(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { // Get resources Map<String, Object> includedResources = getIncludedResources(parent); if (!included...
[ "private", "Map", "<", "String", ",", "Object", ">", "parseIncluded", "(", "JsonNode", "parent", ")", "throws", "IOException", ",", "IllegalAccessException", ",", "InstantiationException", "{", "Map", "<", "String", ",", "Object", ">", "result", "=", "new", "H...
Converts included data and returns it as pairs of its unique identifiers and converted types. @param parent data source @return identifier/object pairs @throws IOException @throws IllegalAccessException
[ "Converts", "included", "data", "and", "returns", "it", "as", "pairs", "of", "its", "unique", "identifiers", "and", "converted", "types", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L385-L412
52,864
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.getIncludedResources
private Map<String, Object> getIncludedResources(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { for (JsonNode jsonNode : parent.get(INCLUDED)) { String type = jsonNode.get(TYPE).asText(); ...
java
private Map<String, Object> getIncludedResources(JsonNode parent) throws IOException, IllegalAccessException, InstantiationException { Map<String, Object> result = new HashMap<>(); if (parent.has(INCLUDED)) { for (JsonNode jsonNode : parent.get(INCLUDED)) { String type = jsonNode.get(TYPE).asText(); ...
[ "private", "Map", "<", "String", ",", "Object", ">", "getIncludedResources", "(", "JsonNode", "parent", ")", "throws", "IOException", ",", "IllegalAccessException", ",", "InstantiationException", "{", "Map", "<", "String", ",", "Object", ">", "result", "=", "new...
Parses out included resources excluding relationships. @param parent root node @return map of identifier/resource pairs @throws IOException @throws IllegalAccessException @throws InstantiationException
[ "Parses", "out", "included", "resources", "excluding", "relationships", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L422-L444
52,865
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.parseRelationship
private Object parseRelationship(JsonNode relationshipDataNode, Class<?> type) throws IOException, IllegalAccessException, InstantiationException { if (ValidationUtils.isRelationshipParsable(relationshipDataNode)) { String identifier = createIdentifier(relationshipDataNode); if (resourceCache.contains(ident...
java
private Object parseRelationship(JsonNode relationshipDataNode, Class<?> type) throws IOException, IllegalAccessException, InstantiationException { if (ValidationUtils.isRelationshipParsable(relationshipDataNode)) { String identifier = createIdentifier(relationshipDataNode); if (resourceCache.contains(ident...
[ "private", "Object", "parseRelationship", "(", "JsonNode", "relationshipDataNode", ",", "Class", "<", "?", ">", "type", ")", "throws", "IOException", ",", "IllegalAccessException", ",", "InstantiationException", "{", "if", "(", "ValidationUtils", ".", "isRelationshipP...
Creates relationship object by consuming provided 'data' node. @param relationshipDataNode relationship data node @param type object type @return created object or <code>null</code> in case data node is not valid @throws IOException @throws IllegalAccessException @throws InstantiationException
[ "Creates", "relationship", "object", "by", "consuming", "provided", "data", "node", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L576-L595
52,866
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.setIdValue
private void setIdValue(Object target, JsonNode idValue) throws IllegalAccessException { Field idField = configuration.getIdField(target.getClass()); ResourceIdHandler idHandler = configuration.getIdHandler(target.getClass()); if (idValue != null) { idField.set(target, idHandler.fromString(idValue.asText()));...
java
private void setIdValue(Object target, JsonNode idValue) throws IllegalAccessException { Field idField = configuration.getIdField(target.getClass()); ResourceIdHandler idHandler = configuration.getIdHandler(target.getClass()); if (idValue != null) { idField.set(target, idHandler.fromString(idValue.asText()));...
[ "private", "void", "setIdValue", "(", "Object", "target", ",", "JsonNode", "idValue", ")", "throws", "IllegalAccessException", "{", "Field", "idField", "=", "configuration", ".", "getIdField", "(", "target", ".", "getClass", "(", ")", ")", ";", "ResourceIdHandle...
Sets an id attribute value to a target object. @param target target POJO @param idValue id node @throws IllegalAccessException thrown in case target field is not accessible
[ "Sets", "an", "id", "attribute", "value", "to", "a", "target", "object", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L622-L629
52,867
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.getResolver
private RelationshipResolver getResolver(Class<?> type) { RelationshipResolver resolver = typedResolvers.get(type); return resolver != null ? resolver : globalResolver; }
java
private RelationshipResolver getResolver(Class<?> type) { RelationshipResolver resolver = typedResolvers.get(type); return resolver != null ? resolver : globalResolver; }
[ "private", "RelationshipResolver", "getResolver", "(", "Class", "<", "?", ">", "type", ")", "{", "RelationshipResolver", "resolver", "=", "typedResolvers", ".", "get", "(", "type", ")", ";", "return", "resolver", "!=", "null", "?", "resolver", ":", "globalReso...
Returns relationship resolver for given type. In case no specific type resolver is registered, global resolver is returned. @param type relationship object type @return relationship resolver or <code>null</code>
[ "Returns", "relationship", "resolver", "for", "given", "type", ".", "In", "case", "no", "specific", "type", "resolver", "is", "registered", "global", "resolver", "is", "returned", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L991-L994
52,868
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java
ResourceConverter.registerType
public boolean registerType(Class<?> type) { if (!configuration.isRegisteredType(type) && ConverterConfiguration.isEligibleType(type)) { return configuration.registerType(type); } return false; }
java
public boolean registerType(Class<?> type) { if (!configuration.isRegisteredType(type) && ConverterConfiguration.isEligibleType(type)) { return configuration.registerType(type); } return false; }
[ "public", "boolean", "registerType", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "!", "configuration", ".", "isRegisteredType", "(", "type", ")", "&&", "ConverterConfiguration", ".", "isEligibleType", "(", "type", ")", ")", "{", "return", "co...
Registers new type to be used with this converter instance. @param type {@link Class} type to register @return <code>true</code> if type was registed, else <code>false</code> (in case type was registered already or type is not eligible for registering ie. missing required annotations)
[ "Registers", "new", "type", "to", "be", "used", "with", "this", "converter", "instance", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceConverter.java#L1271-L1276
52,869
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ReflectionUtils.java
ReflectionUtils.getAnnotatedFields
public static List<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotation, boolean checkSuperclass) { Field [] fields = clazz.getDeclaredFields(); List<Field> result = new ArrayList<>(); for (Field field : fields) { if (field.isAnnotationPresent(annotation)) { resul...
java
public static List<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotation, boolean checkSuperclass) { Field [] fields = clazz.getDeclaredFields(); List<Field> result = new ArrayList<>(); for (Field field : fields) { if (field.isAnnotationPresent(annotation)) { resul...
[ "public", "static", "List", "<", "Field", ">", "getAnnotatedFields", "(", "Class", "<", "?", ">", "clazz", ",", "Class", "<", "?", "extends", "Annotation", ">", "annotation", ",", "boolean", "checkSuperclass", ")", "{", "Field", "[", "]", "fields", "=", ...
Returns all field from a given class that are annotated with provided annotation type. @param clazz source class @param annotation target annotation @param checkSuperclass if true, method will follow class hierarchy to look for fields with target annotation @return list of fields or empty collection in case no fields w...
[ "Returns", "all", "field", "from", "a", "given", "class", "that", "are", "annotated", "with", "provided", "annotation", "type", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ReflectionUtils.java#L30-L47
52,870
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ReflectionUtils.java
ReflectionUtils.getTypeName
public static String getTypeName(Class<?> clazz) { Type typeAnnotation = clazz.getAnnotation(Type.class); return typeAnnotation != null ? typeAnnotation.value() : null; }
java
public static String getTypeName(Class<?> clazz) { Type typeAnnotation = clazz.getAnnotation(Type.class); return typeAnnotation != null ? typeAnnotation.value() : null; }
[ "public", "static", "String", "getTypeName", "(", "Class", "<", "?", ">", "clazz", ")", "{", "Type", "typeAnnotation", "=", "clazz", ".", "getAnnotation", "(", "Type", ".", "class", ")", ";", "return", "typeAnnotation", "!=", "null", "?", "typeAnnotation", ...
Returns the type name defined using Type annotation on provided class. @param clazz type class @return name of the type or <code>null</code> in case Type annotation is not present
[ "Returns", "the", "type", "name", "defined", "using", "Type", "annotation", "on", "provided", "class", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ReflectionUtils.java#L54-L57
52,871
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceCache.java
ResourceCache.init
public void init() { if (initDepth.get() == null) { initDepth.set(1); } else { initDepth.set(initDepth.get() + 1); } if (resourceCache.get() == null) { resourceCache.set(new HashMap<String, Object>()); } if (cacheLocked.get() == null) { cacheLocked.set(Boolean.FALSE); } }
java
public void init() { if (initDepth.get() == null) { initDepth.set(1); } else { initDepth.set(initDepth.get() + 1); } if (resourceCache.get() == null) { resourceCache.set(new HashMap<String, Object>()); } if (cacheLocked.get() == null) { cacheLocked.set(Boolean.FALSE); } }
[ "public", "void", "init", "(", ")", "{", "if", "(", "initDepth", ".", "get", "(", ")", "==", "null", ")", "{", "initDepth", ".", "set", "(", "1", ")", ";", "}", "else", "{", "initDepth", ".", "set", "(", "initDepth", ".", "get", "(", ")", "+", ...
Initialises cache for current thread-scope.
[ "Initialises", "cache", "for", "current", "thread", "-", "scope", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceCache.java#L42-L56
52,872
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceCache.java
ResourceCache.clear
public void clear() { verifyState(); initDepth.set(initDepth.get() - 1); if (initDepth.get() == 0) { resourceCache.set(null); cacheLocked.set(null); initDepth.set(null); } }
java
public void clear() { verifyState(); initDepth.set(initDepth.get() - 1); if (initDepth.get() == 0) { resourceCache.set(null); cacheLocked.set(null); initDepth.set(null); } }
[ "public", "void", "clear", "(", ")", "{", "verifyState", "(", ")", ";", "initDepth", ".", "set", "(", "initDepth", ".", "get", "(", ")", "-", "1", ")", ";", "if", "(", "initDepth", ".", "get", "(", ")", "==", "0", ")", "{", "resourceCache", ".", ...
Clears current thread scope state. @throws IllegalStateException in case <code>init()</code> was not called
[ "Clears", "current", "thread", "scope", "state", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceCache.java#L62-L71
52,873
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceCache.java
ResourceCache.cache
public void cache(Map<String, Object> resources) { verifyState(); if (!cacheLocked.get()) { resourceCache.get().putAll(resources); } }
java
public void cache(Map<String, Object> resources) { verifyState(); if (!cacheLocked.get()) { resourceCache.get().putAll(resources); } }
[ "public", "void", "cache", "(", "Map", "<", "String", ",", "Object", ">", "resources", ")", "{", "verifyState", "(", ")", ";", "if", "(", "!", "cacheLocked", ".", "get", "(", ")", ")", "{", "resourceCache", ".", "get", "(", ")", ".", "putAll", "(",...
Adds multiple resources to cache. @param resources items to add @throws IllegalStateException in case <code>init()</code> was not called
[ "Adds", "multiple", "resources", "to", "cache", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceCache.java#L79-L85
52,874
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ResourceCache.java
ResourceCache.cache
public void cache(String identifier, Object resource) { verifyState(); if (!cacheLocked.get()) { resourceCache.get().put(identifier, resource); } }
java
public void cache(String identifier, Object resource) { verifyState(); if (!cacheLocked.get()) { resourceCache.get().put(identifier, resource); } }
[ "public", "void", "cache", "(", "String", "identifier", ",", "Object", "resource", ")", "{", "verifyState", "(", ")", ";", "if", "(", "!", "cacheLocked", ".", "get", "(", ")", ")", "{", "resourceCache", ".", "get", "(", ")", ".", "put", "(", "identif...
Adds resource to cache. @param identifier resource identifier @param resource resource @throws IllegalStateException in case <code>init()</code> was not called
[ "Adds", "resource", "to", "cache", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ResourceCache.java#L93-L99
52,875
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java
ErrorUtils.parseErrorResponse
public static <T extends Errors> T parseErrorResponse(ObjectMapper mapper, ResponseBody errorResponse, Class<T> cls) throws IOException { return mapper.readValue(errorResponse.bytes(), cls); }
java
public static <T extends Errors> T parseErrorResponse(ObjectMapper mapper, ResponseBody errorResponse, Class<T> cls) throws IOException { return mapper.readValue(errorResponse.bytes(), cls); }
[ "public", "static", "<", "T", "extends", "Errors", ">", "T", "parseErrorResponse", "(", "ObjectMapper", "mapper", ",", "ResponseBody", "errorResponse", ",", "Class", "<", "T", ">", "cls", ")", "throws", "IOException", "{", "return", "mapper", ".", "readValue",...
Parses provided ResponseBody and returns it as T. @param mapper Jackson Object mapper instance @param errorResponse error response body @return T collection @throws IOException
[ "Parses", "provided", "ResponseBody", "and", "returns", "it", "as", "T", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java#L32-L34
52,876
jasminb/jsonapi-converter
src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java
ErrorUtils.parseError
public static <T extends Errors> T parseError(ObjectMapper mapper, JsonNode errorResponse, Class<T> cls) throws JsonProcessingException { return mapper.treeToValue(errorResponse, cls); }
java
public static <T extends Errors> T parseError(ObjectMapper mapper, JsonNode errorResponse, Class<T> cls) throws JsonProcessingException { return mapper.treeToValue(errorResponse, cls); }
[ "public", "static", "<", "T", "extends", "Errors", ">", "T", "parseError", "(", "ObjectMapper", "mapper", ",", "JsonNode", "errorResponse", ",", "Class", "<", "T", ">", "cls", ")", "throws", "JsonProcessingException", "{", "return", "mapper", ".", "treeToValue...
Parses provided JsonNode and returns it as T. @param mapper Jackson Object mapper instance @param errorResponse error response body @return T collection @throws JsonProcessingException thrown in case JsonNode cannot be parsed
[ "Parses", "provided", "JsonNode", "and", "returns", "it", "as", "T", "." ]
73b41c3b9274e70e62b3425071ca8afdc7bddaf6
https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java#L44-L46
52,877
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/Either.java
Either.left
public static <L, R> Either<L, R> left(L l) { return new Left<>(l); }
java
public static <L, R> Either<L, R> left(L l) { return new Left<>(l); }
[ "public", "static", "<", "L", ",", "R", ">", "Either", "<", "L", ",", "R", ">", "left", "(", "L", "l", ")", "{", "return", "new", "Left", "<>", "(", "l", ")", ";", "}" ]
Static factory method for creating a left value. @param l the wrapped value @param <L> the left parameter type @param <R> the right parameter type @return a left value of l
[ "Static", "factory", "method", "for", "creating", "a", "left", "value", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/Either.java#L385-L387
52,878
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/Either.java
Either.right
public static <L, R> Either<L, R> right(R r) { return new Right<>(r); }
java
public static <L, R> Either<L, R> right(R r) { return new Right<>(r); }
[ "public", "static", "<", "L", ",", "R", ">", "Either", "<", "L", ",", "R", ">", "right", "(", "R", "r", ")", "{", "return", "new", "Right", "<>", "(", "r", ")", ";", "}" ]
Static factory method for creating a right value. @param r the wrapped value @param <L> the left parameter type @param <R> the right parameter type @return a right value of r
[ "Static", "factory", "method", "for", "creating", "a", "right", "value", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/Either.java#L397-L399
52,879
palatable/lambda
src/main/java/com/jnape/palatable/lambda/optics/lenses/ListLens.java
ListLens.asCopy
public static <X> Lens.Simple<List<X>, List<X>> asCopy() { return simpleLens(ArrayList::new, (xs, ys) -> ys); }
java
public static <X> Lens.Simple<List<X>, List<X>> asCopy() { return simpleLens(ArrayList::new, (xs, ys) -> ys); }
[ "public", "static", "<", "X", ">", "Lens", ".", "Simple", "<", "List", "<", "X", ">", ",", "List", "<", "X", ">", ">", "asCopy", "(", ")", "{", "return", "simpleLens", "(", "ArrayList", "::", "new", ",", "(", "xs", ",", "ys", ")", "->", "ys", ...
Convenience static factory method for creating a lens over a copy of a list. Useful for composition to avoid mutating a list reference. @param <X> the list element type @return a lens that focuses on copies of lists
[ "Convenience", "static", "factory", "method", "for", "creating", "a", "lens", "over", "a", "copy", "of", "a", "list", ".", "Useful", "for", "composition", "to", "avoid", "mutating", "a", "list", "reference", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/optics/lenses/ListLens.java#L32-L34
52,880
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/Try.java
Try.success
public static <T extends Throwable, A> Try<T, A> success(A a) { return new Success<>(a); }
java
public static <T extends Throwable, A> Try<T, A> success(A a) { return new Success<>(a); }
[ "public", "static", "<", "T", "extends", "Throwable", ",", "A", ">", "Try", "<", "T", ",", "A", ">", "success", "(", "A", "a", ")", "{", "return", "new", "Success", "<>", "(", "a", ")", ";", "}" ]
Static factory method for creating a success value. @param a the wrapped value @param <T> the failure parameter type @param <A> the success parameter type @return a success value of a
[ "Static", "factory", "method", "for", "creating", "a", "success", "value", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/Try.java#L245-L247
52,881
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/Try.java
Try.failure
public static <T extends Throwable, A> Try<T, A> failure(T t) { return new Failure<>(t); }
java
public static <T extends Throwable, A> Try<T, A> failure(T t) { return new Failure<>(t); }
[ "public", "static", "<", "T", "extends", "Throwable", ",", "A", ">", "Try", "<", "T", ",", "A", ">", "failure", "(", "T", "t", ")", "{", "return", "new", "Failure", "<>", "(", "t", ")", ";", "}" ]
Static factory method for creating a failure value. @param t the wrapped {@link Throwable} @param <T> the failure parameter type @param <A> the success parameter type @return a failure value of t
[ "Static", "factory", "method", "for", "creating", "a", "failure", "value", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/Try.java#L257-L259
52,882
palatable/lambda
src/main/java/com/jnape/palatable/lambda/functor/builtin/State.java
State.mapState
public <B> State<S, B> mapState(Fn1<? super Tuple2<A, S>, ? extends Product2<B, S>> fn) { return state(s -> fn.apply(run(s))); }
java
public <B> State<S, B> mapState(Fn1<? super Tuple2<A, S>, ? extends Product2<B, S>> fn) { return state(s -> fn.apply(run(s))); }
[ "public", "<", "B", ">", "State", "<", "S", ",", "B", ">", "mapState", "(", "Fn1", "<", "?", "super", "Tuple2", "<", "A", ",", "S", ">", ",", "?", "extends", "Product2", "<", "B", ",", "S", ">", ">", "fn", ")", "{", "return", "state", "(", ...
Map both the result and the final state to a new result and final state. @param fn the mapping function @param <B> the potentially new final state type @return the mapped {@link State}
[ "Map", "both", "the", "result", "and", "the", "final", "state", "to", "a", "new", "result", "and", "final", "state", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/functor/builtin/State.java#L74-L76
52,883
palatable/lambda
src/main/java/com/jnape/palatable/lambda/functor/builtin/State.java
State.withState
public State<S, A> withState(Fn1<? super S, ? extends S> fn) { return state(s -> run(fn.apply(s))); }
java
public State<S, A> withState(Fn1<? super S, ? extends S> fn) { return state(s -> run(fn.apply(s))); }
[ "public", "State", "<", "S", ",", "A", ">", "withState", "(", "Fn1", "<", "?", "super", "S", ",", "?", "extends", "S", ">", "fn", ")", "{", "return", "state", "(", "s", "->", "run", "(", "fn", ".", "apply", "(", "s", ")", ")", ")", ";", "}"...
Map the final state to a new final state using the provided function. @param fn the state-mapping function @return the mapped {@link State}
[ "Map", "the", "final", "state", "to", "a", "new", "final", "state", "using", "the", "provided", "function", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/functor/builtin/State.java#L84-L86
52,884
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.cons
public static <Head, Tail extends HList> HCons<Head, Tail> cons(Head head, Tail tail) { return new HCons<>(head, tail); }
java
public static <Head, Tail extends HList> HCons<Head, Tail> cons(Head head, Tail tail) { return new HCons<>(head, tail); }
[ "public", "static", "<", "Head", ",", "Tail", "extends", "HList", ">", "HCons", "<", "Head", ",", "Tail", ">", "cons", "(", "Head", "head", ",", "Tail", "tail", ")", "{", "return", "new", "HCons", "<>", "(", "head", ",", "tail", ")", ";", "}" ]
Static factory method for creating an HList from the given head and tail. @param head the head element @param tail the tail HList @param <Head> the head type @param <Tail> the tail type @return the newly created HList
[ "Static", "factory", "method", "for", "creating", "an", "HList", "from", "the", "given", "head", "and", "tail", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L65-L67
52,885
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2> Tuple2<_1, _2> tuple(_1 _1, _2 _2) { return singletonHList(_2).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2> Tuple2<_1, _2> tuple(_1 _1, _2 _2) { return singletonHList(_2).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ">", "Tuple2", "<", "_1", ",", "_2", ">", "tuple", "(", "_1", "_1", ",", "_2", "_2", ")", "{", "return", "singletonHList", "(", "_2", ")", ".", "cons", "(",...
Static factory method for creating a 2-element HList. @param _1 the head element @param _2 the second element @param <_1> the head element type @param <_2> the second element type @return the 2-element HList @see Tuple2
[ "Static", "factory", "method", "for", "creating", "a", "2", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L90-L93
52,886
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3> Tuple3<_1, _2, _3> tuple(_1 _1, _2 _2, _3 _3) { return tuple(_2, _3).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3> Tuple3<_1, _2, _3> tuple(_1 _1, _2 _2, _3 _3) { return tuple(_2, _3).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ">", "Tuple3", "<", "_1", ",", "_2", ",", "_3", ">", "tuple", "(", "_1", "_1", ",", "_2", "_2", ",", "_3", "_3", ")", "{", "return", "tuple", ...
Static factory method for creating a 3-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param <_1> the head element type @param <_2> the second element type @param <_3> the third element type @return the 3-element HList @see Tuple3
[ "Static", "factory", "method", "for", "creating", "a", "3", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L107-L110
52,887
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4> Tuple4<_1, _2, _3, _4> tuple(_1 _1, _2 _2, _3 _3, _4 _4) { return tuple(_2, _3, _4).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4> Tuple4<_1, _2, _3, _4> tuple(_1 _1, _2 _2, _3 _3, _4 _4) { return tuple(_2, _3, _4).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ">", "Tuple4", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ">", "tuple", "(", "_1", "_1", ",", "_2", "_2", ",", "_3", "_3", ",", ...
Static factory method for creating a 4-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param _4 the fourth element @param <_1> the head element type @param <_2> the second element type @param <_3> the third element type @param <_4> the fourth element type @re...
[ "Static", "factory", "method", "for", "creating", "a", "4", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L126-L129
52,888
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5> Tuple5<_1, _2, _3, _4, _5> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5) { return tuple(_2, _3, _4, _5).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5> Tuple5<_1, _2, _3, _4, _5> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5) { return tuple(_2, _3, _4, _5).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ">", "Tuple5", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ">", "tuple", "(", "_1", "_1", ",", "_2", "_2", ...
Static factory method for creating a 5-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param _4 the fourth element @param _5 the fifth element @param <_1> the head element type @param <_2> the second element type @param <_3> the third element type @param <_...
[ "Static", "factory", "method", "for", "creating", "a", "5", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L147-L150
52,889
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6> Tuple6<_1, _2, _3, _4, _5, _6> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6) { return tuple(_2, _3, _4, _5, _6).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6> Tuple6<_1, _2, _3, _4, _5, _6> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6) { return tuple(_2, _3, _4, _5, _6).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ">", "Tuple6", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ">", "tuple", "(", "_1", ...
Static factory method for creating a 6-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param _4 the fourth element @param _5 the fifth element @param _6 the sixth element @param <_1> the head element type @param <_2> the second element type @param <_3> th...
[ "Static", "factory", "method", "for", "creating", "a", "6", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L170-L174
52,890
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6, _7> Tuple7<_1, _2, _3, _4, _5, _6, _7> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7) { return tuple(_2, _3, _4, _5, _6, _7).cons(_1); }
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6, _7> Tuple7<_1, _2, _3, _4, _5, _6, _7> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7) { return tuple(_2, _3, _4, _5, _6, _7).cons(_1); }
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ",", "_7", ">", "Tuple7", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ",", "_7", ">"...
Static factory method for creating a 7-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param _4 the fourth element @param _5 the fifth element @param _6 the sixth element @param _7 the seventh element @param <_1> the head element type @param <_2> the se...
[ "Static", "factory", "method", "for", "creating", "a", "7", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L196-L200
52,891
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java
HList.tuple
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6, _7, _8> Tuple8<_1, _2, _3, _4, _5, _6, _7, _8> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, ...
java
@SuppressWarnings("JavaDoc") public static <_1, _2, _3, _4, _5, _6, _7, _8> Tuple8<_1, _2, _3, _4, _5, _6, _7, _8> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, ...
[ "@", "SuppressWarnings", "(", "\"JavaDoc\"", ")", "public", "static", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ",", "_7", ",", "_8", ">", "Tuple8", "<", "_1", ",", "_2", ",", "_3", ",", "_4", ",", "_5", ",", "_6", ","...
Static factory method for creating an 8-element HList. @param _1 the head element @param _2 the second element @param _3 the third element @param _4 the fourth element @param _5 the fifth element @param _6 the sixth element @param _7 the seventh element @param _8 the eighth element @param <_1> the head...
[ "Static", "factory", "method", "for", "creating", "an", "8", "-", "element", "HList", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java#L224-L229
52,892
palatable/lambda
src/main/java/com/jnape/palatable/lambda/functor/builtin/Lazy.java
Lazy.lazy
public static <A> Lazy<A> lazy(Supplier<A> supplier) { return new Later<>(fn0(supplier)); }
java
public static <A> Lazy<A> lazy(Supplier<A> supplier) { return new Later<>(fn0(supplier)); }
[ "public", "static", "<", "A", ">", "Lazy", "<", "A", ">", "lazy", "(", "Supplier", "<", "A", ">", "supplier", ")", "{", "return", "new", "Later", "<>", "(", "fn0", "(", "supplier", ")", ")", ";", "}" ]
Wrap a computation in a lazy computation. @param supplier the computation @param <A> the value type @return the new {@link Lazy}
[ "Wrap", "a", "computation", "in", "a", "lazy", "computation", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/functor/builtin/Lazy.java#L105-L107
52,893
palatable/lambda
src/main/java/com/jnape/palatable/lambda/optics/lenses/MapLens.java
MapLens.asCopy
public static <K, V> Lens.Simple<Map<K, V>, Map<K, V>> asCopy() { return adapt(asCopy(HashMap::new)); }
java
public static <K, V> Lens.Simple<Map<K, V>, Map<K, V>> asCopy() { return adapt(asCopy(HashMap::new)); }
[ "public", "static", "<", "K", ",", "V", ">", "Lens", ".", "Simple", "<", "Map", "<", "K", ",", "V", ">", ",", "Map", "<", "K", ",", "V", ">", ">", "asCopy", "(", ")", "{", "return", "adapt", "(", "asCopy", "(", "HashMap", "::", "new", ")", ...
A lens that focuses on a copy of a Map. Useful for composition to avoid mutating a map reference. @param <K> the key type @param <V> the value type @return a lens that focuses on copies of maps
[ "A", "lens", "that", "focuses", "on", "a", "copy", "of", "a", "Map", ".", "Useful", "for", "composition", "to", "avoid", "mutating", "a", "map", "reference", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/optics/lenses/MapLens.java#L61-L63
52,894
palatable/lambda
src/main/java/com/jnape/palatable/lambda/optics/lenses/MapLens.java
MapLens.keys
public static <K, V> Lens.Simple<Map<K, V>, Set<K>> keys() { return simpleLens(m -> new HashSet<>(m.keySet()), (m, ks) -> { HashSet<K> ksCopy = new HashSet<>(ks); Map<K, V> updated = new HashMap<>(m); Set<K> keys = updated.keySet(); keys.retainAll(ksCopy); ...
java
public static <K, V> Lens.Simple<Map<K, V>, Set<K>> keys() { return simpleLens(m -> new HashSet<>(m.keySet()), (m, ks) -> { HashSet<K> ksCopy = new HashSet<>(ks); Map<K, V> updated = new HashMap<>(m); Set<K> keys = updated.keySet(); keys.retainAll(ksCopy); ...
[ "public", "static", "<", "K", ",", "V", ">", "Lens", ".", "Simple", "<", "Map", "<", "K", ",", "V", ">", ",", "Set", "<", "K", ">", ">", "keys", "(", ")", "{", "return", "simpleLens", "(", "m", "->", "new", "HashSet", "<>", "(", "m", ".", "...
A lens that focuses on the keys of a map. @param <K> the key type @param <V> the value type @return a lens that focuses on the keys of a map
[ "A", "lens", "that", "focuses", "on", "the", "keys", "of", "a", "map", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/optics/lenses/MapLens.java#L120-L130
52,895
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java
HMap.get
@SuppressWarnings("unchecked") public <A, B> Maybe<B> get(TypeSafeKey<A, B> key) { return maybe((A) table.get(key)).fmap(view(key)); }
java
@SuppressWarnings("unchecked") public <A, B> Maybe<B> get(TypeSafeKey<A, B> key) { return maybe((A) table.get(key)).fmap(view(key)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "A", ",", "B", ">", "Maybe", "<", "B", ">", "get", "(", "TypeSafeKey", "<", "A", ",", "B", ">", "key", ")", "{", "return", "maybe", "(", "(", "A", ")", "table", ".", "get", "(", ...
Retrieve the value at this key. @param key the key @param <A> the value type @param <B> the value type @return Maybe the value at this key
[ "Retrieve", "the", "value", "at", "this", "key", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L48-L51
52,896
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java
HMap.put
public <V> HMap put(TypeSafeKey<?, V> key, V value) { return alter(t -> t.put(key, view(key.mirror(), value))); }
java
public <V> HMap put(TypeSafeKey<?, V> key, V value) { return alter(t -> t.put(key, view(key.mirror(), value))); }
[ "public", "<", "V", ">", "HMap", "put", "(", "TypeSafeKey", "<", "?", ",", "V", ">", "key", ",", "V", "value", ")", "{", "return", "alter", "(", "t", "->", "t", ".", "put", "(", "key", ",", "view", "(", "key", ".", "mirror", "(", ")", ",", ...
Store a value for the given key. @param key the key @param value the value @param <V> the value type @return the updated HMap
[ "Store", "a", "value", "for", "the", "given", "key", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L73-L75
52,897
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java
HMap.singletonHMap
public static <V> HMap singletonHMap(TypeSafeKey<?, V> key, V value) { return emptyHMap().put(key, value); }
java
public static <V> HMap singletonHMap(TypeSafeKey<?, V> key, V value) { return emptyHMap().put(key, value); }
[ "public", "static", "<", "V", ">", "HMap", "singletonHMap", "(", "TypeSafeKey", "<", "?", ",", "V", ">", "key", ",", "V", "value", ")", "{", "return", "emptyHMap", "(", ")", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Static factory method for creating a singleton HMap. @param key the only mapped key @param value the only mapped value @param <V> the only mapped value type @return a singleton HMap
[ "Static", "factory", "method", "for", "creating", "a", "singleton", "HMap", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L197-L199
52,898
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java
HMap.hMap
public static <V1, V2> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1, TypeSafeKey<?, V2> key2, V2 value2) { return singletonHMap(key1, value1).put(key2, value2); }
java
public static <V1, V2> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1, TypeSafeKey<?, V2> key2, V2 value2) { return singletonHMap(key1, value1).put(key2, value2); }
[ "public", "static", "<", "V1", ",", "V2", ">", "HMap", "hMap", "(", "TypeSafeKey", "<", "?", ",", "V1", ">", "key1", ",", "V1", "value1", ",", "TypeSafeKey", "<", "?", ",", "V2", ">", "key2", ",", "V2", "value2", ")", "{", "return", "singletonHMap"...
Static factory method for creating an HMap from two given associations. @param key1 the first mapped key @param value1 the value mapped at key1 @param key2 the second mapped key @param value2 the value mapped at key2 @param <V1> value1's type @param <V2> value2's type @return an HMap with the given association...
[ "Static", "factory", "method", "for", "creating", "an", "HMap", "from", "two", "given", "associations", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L212-L215
52,899
palatable/lambda
src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java
HMap.hMap
public static <V1, V2, V3> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1, TypeSafeKey<?, V2> key2, V2 value2, TypeSafeKey<?, V3> key3, V3 value3) { return hMap(key1, value1, key2, value2) .put(ke...
java
public static <V1, V2, V3> HMap hMap(TypeSafeKey<?, V1> key1, V1 value1, TypeSafeKey<?, V2> key2, V2 value2, TypeSafeKey<?, V3> key3, V3 value3) { return hMap(key1, value1, key2, value2) .put(ke...
[ "public", "static", "<", "V1", ",", "V2", ",", "V3", ">", "HMap", "hMap", "(", "TypeSafeKey", "<", "?", ",", "V1", ">", "key1", ",", "V1", "value1", ",", "TypeSafeKey", "<", "?", ",", "V2", ">", "key2", ",", "V2", "value2", ",", "TypeSafeKey", "<...
Static factory method for creating an HMap from three given associations. @param key1 the first mapped key @param value1 the value mapped at key1 @param key2 the second mapped key @param value2 the value mapped at key2 @param key3 the third mapped key @param value3 the value mapped at key3 @param <V1> value1's...
[ "Static", "factory", "method", "for", "creating", "an", "HMap", "from", "three", "given", "associations", "." ]
b643ba836c5916d1d8193822e5efb4e7b40c489a
https://github.com/palatable/lambda/blob/b643ba836c5916d1d8193822e5efb4e7b40c489a/src/main/java/com/jnape/palatable/lambda/adt/hmap/HMap.java#L231-L237