proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/AnnotationUsageView.java
AnnotationUsageView
transform
class AnnotationUsageView implements Transform<AnnotationUsage, String> { @Override public Optional<String> transform(Generator gen, AnnotationUsage model) {<FILL_FUNCTION_BODY>} }
requireNonNull(gen); requireNonNull(model); final Optional<String> value = gen.on(model.getValue()); final Stream<String> valueStream = value.map(Stream::of).orElseGet(Stream::empty); return Optional.of( "@" + gen.on(model.getType()).orElseThrow(NoSuchElementException::new) + Stream.of( model.getValues().stream() .map(e -> e.getKey() + gen.on(e.getValue()) .map(s -> " = " + s) .orElse("") ), valueStream ).flatMap(s -> s).collect( joinIfNotEmpty(", ", "(", ")") ) );
53
201
254
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/AnnotationView.java
AnnotationView
transform
class AnnotationView implements Transform<Annotation, String>, HasJavadocView<Annotation>, HasAnnotationUsageView<Annotation>, HasNameView<Annotation> { @Override public Optional<String> transform(Generator gen, Annotation model) {<FILL_FUNCTION_BODY>} }
requireNonNulls(gen, model); return Optional.of( renderAnnotations(gen, model) + renderAnnotations(gen, model) + "@interface " + renderName(gen, model) + block( model.getFields().stream().map(f -> // Field javadoc (optional) renderJavadoc(gen, model) + // Field declaration gen.on(f.getType()) + " " + f.getName() + "()" + // Default value (optional) ifelse(gen.on(f.getValue()), v -> " default " + v, "") + ";" ).collect(joining(dnl())) ) );
80
182
262
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/ClassOrInterfaceView.java
ClassOrInterfaceView
transform
class ClassOrInterfaceView<M extends ClassOrInterface<M>> implements Transform<M, String>, HasNameView<M>, HasModifiersView<M>, HasJavadocView<M>, HasGenericsView<M>, HasImplementsView<M>, HasInitializersView<M>, HasMethodsView<M>, HasClassesView<M>, HasAnnotationUsageView<M>, HasFieldsView<M> { private static final Pattern EMPTY_BLOCK = Pattern.compile("^\\s*\\{\\s*}\\s*$"); protected static final String CLASS_STRING = "class "; protected static final String INTERFACE_STRING = "interface "; protected static final String ENUM_STRING = "enum "; protected static final String IMPLEMENTS_STRING = "implements "; protected static final String EXTENDS_STRING = "extends "; /** * A hook that is executed just before the 'fields' part of the class code. * * @param gen the generator being used * @param model the model that is generated * @return code to be inserted before the fields */ protected String onBeforeFields(Generator gen, M model) { return ""; } @Override public String fieldSeparator(M model) { return nl(); } @Override public String fieldSuffix() { return ";"; } /** * Returns the declaration type of this model. This can be either 'class', * 'interface' or 'enum'. * * @return the declaration type */ protected abstract String renderDeclarationType(); /** * Returns the supertype of this model. The supertype should include any * declaration like 'implements' or 'extends'. * <p> * Example: <pre>"implements List"</pre> * * @param gen the generator to use * @param model the model of the component * @return the supertype part */ protected abstract String renderSupertype(Generator gen, M model); /** * Should render the constructors part of the code and return it. * * @param gen the generator to use * @param model the model of the component * @return generated constructors or an empty string if there shouldn't * be any */ protected abstract String renderConstructors(Generator gen, M model); @Override public Optional<String> transform(Generator gen, M model) {<FILL_FUNCTION_BODY>} /** * Converts the specified elements into strings using their * <code>toString</code>-method and combines them with two new-line-characters. * Empty strings will be discarded. * * @param strings the strings to combine * @return the combined string */ private String separate(Object... strings) { requireNonNullElements(strings); return Stream.of(strings) .map(Object::toString) .filter(s -> s.length() > 0) .collect(joining(dnl())); } }
requireNonNulls(gen, model); String code = block(nl() + separate( onBeforeFields(gen, model), // Enums have constants here.´ renderFields(gen, model), renderConstructors(gen, model), renderInitalizers(gen, model), renderMethods(gen, model), renderClasses(gen, model) )); if (EMPTY_BLOCK.matcher(code).find()) { code = "{}"; } return Optional.of(renderJavadoc(gen, model) + renderAnnotations(gen, model) + renderModifiers(gen, model) + renderDeclarationType() + renderName(gen, model) + renderGenerics(gen, model) + (model.getGenerics().isEmpty() ? " " : "") + renderSupertype(gen, model) + renderInterfaces(gen, model) + // Code code );
828
259
1,087
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/ConstructorView.java
ConstructorView
transform
class ConstructorView implements Transform<Constructor, String>, HasThrowsView<Constructor>, HasGenericsView<Constructor>, HasFieldsView<Constructor>, HasJavadocView<Constructor>, HasAnnotationUsageView<Constructor>, HasCodeView<Constructor>, HasModifiersView<Constructor> { @Override public String fieldSeparator(Constructor model) { if (model.getFields().size() >= 3 || model.getFields().stream() .anyMatch(f -> !f.getAnnotations().isEmpty())) { return "," + Formatting.nl() + Formatting.tab() + Formatting.tab(); } else return ", "; } @Override public String throwsSuffix(Constructor model) { return " "; } @Override public Optional<String> transform(Generator gen, Constructor model) {<FILL_FUNCTION_BODY>} /** * Renders the name of this constructor. In java, this is the name of the * class or enum that the constructor is in. * * @param gen the generator * @param model the constructor * @return the rendered name */ private static <T extends HasName<T>> Optional<String> renderName(Generator gen, Constructor model) { requireNonNulls(gen, model); return gen.getRenderStack() .fromTop(HasName.class) .map(HasName<T>::getName) .map(Formatting::shortName) .findFirst(); } private boolean splitFields(Constructor model) { return model.getFields().size() >= 3 || model.getFields().stream() .anyMatch(f -> !f.getAnnotations().isEmpty()); } }
requireNonNulls(gen, model); return Optional.of( renderJavadoc(gen, model) + renderAnnotations(gen, model) + renderModifiers(gen, model, PUBLIC, PRIVATE, PROTECTED) + renderGenerics(gen, model) + renderName(gen, model) .orElseThrow(() -> new UnsupportedOperationException( "Could not find a nameable parent of constructor." )) + ((splitFields(model)) ? "(" + Formatting.nl() + Formatting.tab() + Formatting.tab() : "(") + renderFields(gen, model) + ") " + renderThrows(gen, model) + renderCode(gen, model) );
452
192
644
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/EnumView.java
EnumView
onBeforeFields
class EnumView extends ClassOrInterfaceView<Enum> { @Override protected String renderDeclarationType() { return ENUM_STRING; } @Override public String extendsOrImplementsInterfaces() { return IMPLEMENTS_STRING; } @Override protected String renderSupertype(Generator gen, Enum model) { return ""; } @Override protected String onBeforeFields(Generator gen, Enum model) {<FILL_FUNCTION_BODY>} @Override protected String renderConstructors(Generator gen, Enum model) { requireNonNulls(gen, model); return gen.onEach(model.getConstructors()) .collect(joining(Formatting.dnl())); } }
requireNonNulls(gen, model); final List<String> constants = model.getConstants().stream() .map(c -> gen.on(c).get()).collect(toList()); Formatting.alignTabs(constants); return constants.stream().collect( joinIfNotEmpty( (!model.getConstants().isEmpty() && (!model.getConstants().get(0).getValues().isEmpty() || !model.getConstants().get(0).getAnnotations().isEmpty())) ? "," + Formatting.nl() : ", ", "", ";" ) );
191
167
358
<methods>public java.lang.String fieldSeparator(com.speedment.common.codegen.model.Enum) ,public java.lang.String fieldSuffix() ,public Optional<java.lang.String> transform(com.speedment.common.codegen.Generator, com.speedment.common.codegen.model.Enum) <variables>protected static final java.lang.String CLASS_STRING,private static final java.util.regex.Pattern EMPTY_BLOCK,protected static final java.lang.String ENUM_STRING,protected static final java.lang.String EXTENDS_STRING,protected static final java.lang.String IMPLEMENTS_STRING,protected static final java.lang.String INTERFACE_STRING
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/FieldView.java
FieldView
transform
class FieldView implements Transform<Field, String>, HasNameView<Field>, HasJavadocView<Field>, HasModifiersView<Field>, HasTypeView<Field>, HasValueView<Field>, HasAnnotationUsageView<Field> { @Override public Optional<String> transform(Generator gen, Field model) {<FILL_FUNCTION_BODY>} @Override public String annotationSeparator() { return " "; } }
requireNonNulls(gen, model); return Optional.of( renderJavadoc(gen, model) + renderModifiers(gen, model) + renderAnnotations(gen, model) + renderType(gen, model) + renderName(gen, model) + renderValue(gen, model) );
128
94
222
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/FileView.java
FileView
transform
class FileView implements Transform<File, String>, HasLicenseTermView<File>, HasImportsView<File>, HasJavadocView<File>, HasClassesView<File> { @Override public Optional<String> transform(Generator gen, File model) {<FILL_FUNCTION_BODY>} /** * Renders the 'package'-part of the file. In java, the package should only * be present if the file is located in a directory in the sources folder. * If the file is in the global package, an empty string will be returned. * <p> * The package part will be suffixed by two new line characters if a package * was outputted. * <p> * Example: <pre>"package com.speedment.example;\n\n"</pre> * * @param file the file * @return the package part or an empty string */ private String renderPackage(File file) { final Optional<String> name = fileToClassName(file.getName()); if (name.isPresent()) { final Optional<String> pack = packageName(name.get()); if (pack.isPresent()) { return "package " + pack.get() + ";" + dnl(); } } return ""; } }
requireNonNulls(gen, model); final DependencyManager mgr = gen.getDependencyMgr(); mgr.clearDependencies(); final String pack = fileToClassName(model.getName()) .flatMap(Formatting::packageName) .orElse(""); mgr.setCurrentPackage(pack); final Optional<String> view = Optional.of( renderLicenseTerm(gen, model) + renderJavadoc(gen, model) + renderPackage(model) + renderImports(gen, model) + renderClasses(gen, model) ); mgr.unsetCurrentPackage(pack); return view;
341
187
528
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/ImportView.java
ImportView
shouldImport
class ImportView implements Transform<Import, String> { @Override public Optional<String> transform(Generator gen, Import model) { requireNonNulls(gen, model); final String name = stripGenerics(model.getType().getTypeName()) .replace('$', '.'); if (!model.getModifiers().isEmpty() || shouldImport(gen, model.getType())) { return Optional.of( "import " + gen.onEach(model.getModifiers()).collect(joinIfNotEmpty(" ", "", " ")) + name + model.getStaticMember().map(str -> "." + str).orElse("") + ";" ).filter(x -> { gen.getDependencyMgr().load(name); return true; }); } else { return Optional.empty(); } } /** * Returns <code>true</code> if the specified type requires an explicit * import. If the type has already been imported or is part of a package * that does not need to be imported, <code>false</code> is returned. * * @param gen the generator * @param type the type to import * @return <code>true</code> if it should be imported explicitly */ private boolean shouldImport(Generator gen, Type type) {<FILL_FUNCTION_BODY>} }
final DependencyManager mgr = gen.getDependencyMgr(); final String typeName = stripGenerics(type.getTypeName()); if (mgr.isIgnored(typeName)) { return false; } if (mgr.isLoaded(typeName)) { return false; } final Optional<String> current = mgr.getCurrentPackage(); final Optional<String> suggested = packageName(typeName); // TODO: Inner classes might still be imported explicitly. return !(current.isPresent() && suggested.isPresent() && current.get().equals(suggested.get()));
354
167
521
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/InitalizerView.java
InitalizerView
transform
class InitalizerView implements Transform<Initializer, String>, HasModifiersView<Initializer>, HasCodeView<Initializer> { @Override public Optional<String> transform(Generator gen, Initializer model) {<FILL_FUNCTION_BODY>} }
requireNonNull(gen); requireNonNull(model); return Optional.of( renderModifiers(gen, model) + renderCode(gen, model) );
73
51
124
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/InterfaceFieldView.java
InterfaceFieldView
transform
class InterfaceFieldView implements Transform<InterfaceField, String>, HasNameView<InterfaceField>, HasJavadocView<InterfaceField>, HasModifiersView<InterfaceField>, HasTypeView<InterfaceField>, HasValueView<InterfaceField>, HasAnnotationUsageView<InterfaceField> { @Override public Optional<String> transform(Generator gen, InterfaceField model) {<FILL_FUNCTION_BODY>} @Override public String annotationSeparator() { return " "; } }
requireNonNulls(gen, model); // We intentionally avoid modifiers on fields. return Optional.of( renderJavadoc(gen, model) + renderAnnotations(gen, model) + renderType(gen, model) + renderName(gen, model) + renderValue(gen, model) );
137
90
227
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/JavadocView.java
JavadocView
groupOf
class JavadocView implements Transform<Javadoc, String>, HasJavadocTagsView<Javadoc> { private static final int BLOCK_WIDTH = 80; private static final String JAVADOC_DELIMITER = nl() + " * "; private static final String JAVADOC_PREFIX = "/**" + nl() + " * "; private static final String JAVADOC_SUFFIX = nl() + " */"; @Override public Optional<String> transform(Generator gen, Javadoc model) { requireNonNulls(gen, model); final int blockWidth = BLOCK_WIDTH - 3 - currentTabLevel(gen); final String formattedText = formatText(model.getText(), 0, blockWidth).toString(); final Map<String, List<JavadocTag>> tagGroups = model.getTags().stream() .collect(Collectors.groupingBy( JavadocView::groupOf, TreeMap::new, Collectors.toList() )); final String tagSection = tagGroups.values().stream().map(tags -> { final List<StringBuilder> rowBuilders = new ArrayList<>(tags.size()); // Create a new row builder for each tag and initiate it with the // tag name tags.forEach(tag -> { final StringBuilder row = new StringBuilder("@").append(tag.getName()); if (tag.getText().isPresent()) { row.append(tag.getValue().map(v -> " " + v).orElse("")); } rowBuilders.add(row); }); // Determine the column width of the widest tag name and use that // for padding. final int indentTo = rowBuilders.stream() .mapToInt(StringBuilder::length) .map(i -> i + 1) // Add one extra space to each row. .max().orElse(0); // If empty, do no padding. rowBuilders.forEach(row -> { final int padding = indentTo - row.length(); if (padding > 0) { row.append(repeat(" ", padding)); } }); // All the rows are now of the same width. Go through the remaining // content and add it to the text, padding in each new line with the // same amount. for (int i = 0; i < rowBuilders.size(); i++) { final JavadocTag tag = tags.get(i); final StringBuilder row = rowBuilders.get(i); final String content; if (tag.getText().isPresent()) { content = tag.getText().orElse(""); } else { content = Stream.of( tag.getValue().orElse(null), tag.getText().orElse(null) ).filter(Objects::nonNull).collect(joining(" ")); } row.append(formatText(content, indentTo, blockWidth)); } // Concatenate the rows, separating them with new-line characters. return rowBuilders.stream() .map(StringBuilder::toString) .collect(joining(nl())); }).collect(joining(dnl())); return Optional.of( JAVADOC_PREFIX + Stream.of(formattedText, tagSection) .filter(Objects::nonNull) .filter(s -> !s.isEmpty()) .collect(joining(dnl())) .replace(nl(), JAVADOC_DELIMITER) + JAVADOC_SUFFIX ); } private static StringBuilder formatText(String text, int indentTo, int blockWidth) { final StringBuilder row = new StringBuilder(); final AtomicInteger col = new AtomicInteger(indentTo); Stream.of(text.split(" ")) .map(s -> s.replace("\t", tab())) .forEachOrdered(str -> { final String[] words = str.split(nl()); for (int i = 0; i < words.length; i++) { final String word = words[i]; // If the were forced to do a line-break, make sure to tab // into the current level and reset the counter. if (i > 0) { row.append(nl()).append(repeat(" ", indentTo)); col.set(indentTo); } // If this new word is about to push us over the blockWidth, // create a new line and reset the column counter. final int extraSpace = col.get() > indentTo ? 1 : 0; if (col.get() + word.length() + extraSpace > blockWidth) { row.append(nl()).append(repeat(" ", indentTo)); col.set(indentTo); } // If this is not the first input on the line, add a space. if (col.get() > indentTo) { row.append(" "); col.incrementAndGet(); } // Write the word and increment the column counter. row.append(word); col.addAndGet(word.length()); } }); return row; } private static int currentTabLevel(Generator gen) { final int level = (int) gen.getRenderStack() .fromTop(HasJavadoc.class) .distinct() .count(); if (level <= 2) { return 0; } else { return (level - 2) * Formatting.tab().length(); } } private static String groupOf(JavadocTag tag) {<FILL_FUNCTION_BODY>} }
switch (tag.getName()) { case "param" : case "return" : return "group_0"; case "throws" : return "group_1"; case "author" : case "deprecated" : case "since" : case "version" : return "group_2"; case "see" : return "group_3"; default : return "group_4"; }
1,474
116
1,590
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/LicenseTermView.java
LicenseTermView
transform
class LicenseTermView implements Transform<LicenseTerm, String> { private static final String LICENSE_DELIMITER = nl() + " *"; private static final String LICENSE_PREFIX = "/*" + LICENSE_DELIMITER; private static final String LICENSE_SUFFIX = nl() + " */"; @Override public Optional<String> transform(Generator gen, LicenseTerm model) {<FILL_FUNCTION_BODY>} }
requireNonNull(gen); requireNonNull(model); return Optional.of( Stream.of(model.getText().split(nl())) /* .filter(s -> !s.isEmpty())*/ /* .filter(s -> !nl().equals(s))*/ .map(s -> s.isEmpty() ? s : " " + s) .collect(joining(LICENSE_DELIMITER, LICENSE_PREFIX, LICENSE_SUFFIX)) );
121
129
250
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/value/ArrayValueView.java
ArrayValueView
transform
class ArrayValueView implements Transform<ArrayValue, String> { @Override public Optional<String> transform(Generator gen, ArrayValue model) {<FILL_FUNCTION_BODY>} }
requireNonNulls(gen, model); return Optional.of( gen.onEach(model.getValue()).collect( Collectors.joining(", ", "{", "}") ) );
49
62
111
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/view/value/EnumValueView.java
EnumValueView
transform
class EnumValueView implements Transform<EnumValue, String> { @Override public Optional<String> transform(Generator gen, EnumValue model) {<FILL_FUNCTION_BODY>} }
requireNonNulls(gen, model); return Optional.of( gen.on(model.getType()).orElse("") + "." + model.getValue() );
51
55
106
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/AnnotationImpl.java
AnnotationImpl
hashCode
class AnnotationImpl implements Annotation { private String name; private Javadoc javadoc; private final List<AnnotationUsage> annotations; private final List<Field> fields; private final List<Import> imports; private final Set<Modifier> modifiers; /** * Initializes this annotation using a name. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Annotation#of(java.lang.String)} method! * * @param name the name */ public AnnotationImpl(String name) { this.name = requireNonNull(name); this.javadoc = null; this.annotations = new ArrayList<>(); this.fields = new ArrayList<>(); this.imports = new ArrayList<>(); this.modifiers = EnumSet.noneOf(Modifier.class); } /** * Copy constructor. * * @param prototype the prototype */ protected AnnotationImpl(Annotation prototype) { requireNonNull(prototype); name = prototype.getName(); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); fields = Copier.copy(prototype.getFields()); imports = Copier.copy(prototype.getImports()); modifiers = Copier.copy(prototype.getModifiers(), Modifier::copy, EnumSet.noneOf(Modifier.class)); } @Override public Annotation setName(String name) { this.name = requireNonNull(name); return this; } @Override public String getName() { return name; } @Override public List<Field> getFields() { return fields; } @Override public Annotation set(Javadoc doc) { this.javadoc = doc.setParent(this); return this; } @Override public Optional<Javadoc> getJavadoc() { return Optional.ofNullable(javadoc); } @Override public List<Import> getImports() { return imports; } @Override public Set<Modifier> getModifiers() { return modifiers; } @Override public List<AnnotationUsage> getAnnotations() { return annotations; } @Override public AnnotationImpl copy() { return new AnnotationImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AnnotationImpl other = (AnnotationImpl) obj; if (!Objects.equals(this.name, other.name)) { return false; } if (!Objects.equals(this.javadoc, other.javadoc)) { return false; } if (!Objects.equals(this.annotations, other.annotations)) { return false; } if (!Objects.equals(this.fields, other.fields)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } return Objects.equals(this.modifiers, other.modifiers); } }
int hash = 7; hash = 41 * hash + Objects.hashCode(this.name); hash = 41 * hash + Objects.hashCode(this.javadoc); hash = 41 * hash + Objects.hashCode(this.annotations); hash = 41 * hash + Objects.hashCode(this.fields); hash = 41 * hash + Objects.hashCode(this.imports); hash = 41 * hash + Objects.hashCode(this.modifiers); return hash;
907
133
1,040
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/ClassImpl.java
ClassImpl
hashCode
class ClassImpl extends ClassOrInterfaceImpl<Class> implements Class { private Type superType; private final List<Constructor> constructors; /** * Initializes this class using a name. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Class#of(java.lang.String)} method! * * @param name the name */ public ClassImpl(String name) { super(name); superType = null; constructors = new ArrayList<>(); } /** * Copy constructor. * * @param prototype the prototype */ protected ClassImpl(Class prototype) { super (prototype); this.superType = prototype.getSupertype().orElse(null); this.constructors = Copier.copy(prototype.getConstructors()); } @Override public Class setSupertype(Type superType) { this.superType = superType; return this; } @Override public Optional<Type> getSupertype() { return Optional.ofNullable(superType); } @Override public List<Constructor> getConstructors() { return constructors; } @Override public ClassImpl copy() { return new ClassImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } final ClassImpl other = (ClassImpl) obj; if (!Objects.equals(this.superType, other.superType)) { return false; } return Objects.equals(this.constructors, other.constructors); } }
int hash = super.hashCode(); hash = 11 * hash + Objects.hashCode(this.superType); hash = 11 * hash + Objects.hashCode(this.constructors); return hash;
461
58
519
<methods>public boolean equals(java.lang.Object) ,public List<com.speedment.common.codegen.model.AnnotationUsage> getAnnotations() ,public List<ClassOrInterface<?>> getClasses() ,public List<com.speedment.common.codegen.model.Field> getFields() ,public List<com.speedment.common.codegen.model.Generic> getGenerics() ,public List<com.speedment.common.codegen.model.Import> getImports() ,public List<com.speedment.common.codegen.model.Initializer> getInitializers() ,public List<java.lang.reflect.Type> getInterfaces() ,public Optional<com.speedment.common.codegen.model.Javadoc> getJavadoc() ,public List<com.speedment.common.codegen.model.Method> getMethods() ,public Set<com.speedment.common.codegen.model.modifier.Modifier> getModifiers() ,public java.lang.String getName() ,public Optional<HasClasses<?>> getParent() ,public int hashCode() ,public com.speedment.common.codegen.model.Class set(com.speedment.common.codegen.model.Javadoc) ,public com.speedment.common.codegen.model.Class setName(java.lang.String) ,public com.speedment.common.codegen.model.Class setParent(HasClasses<?>) <variables>private final non-sealed List<com.speedment.common.codegen.model.AnnotationUsage> annotations,private final non-sealed List<ClassOrInterface<?>> classes,private final non-sealed List<com.speedment.common.codegen.model.Field> fields,private final non-sealed List<com.speedment.common.codegen.model.Generic> generics,private final non-sealed List<com.speedment.common.codegen.model.Import> imports,private final non-sealed List<com.speedment.common.codegen.model.Initializer> initalizers,private final non-sealed List<java.lang.reflect.Type> interfaces,private com.speedment.common.codegen.model.Javadoc javadoc,private final non-sealed List<com.speedment.common.codegen.model.Method> methods,private final non-sealed Set<com.speedment.common.codegen.model.modifier.Modifier> modifiers,private java.lang.String name,private HasClasses<?> parent
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/ConstructorImpl.java
ConstructorImpl
equals
class ConstructorImpl implements Constructor { private HasConstructors<?> parent; private Javadoc javadoc; private final List<Import> imports; private final List<AnnotationUsage> annotations; private final List<Generic> generics; private final List<Field> params; private final List<String> code; private final Set<Modifier> modifiers; private final Set<Type> exceptions; /** * Initializes this constructor. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Constructor#of()} method! */ public ConstructorImpl() { javadoc = null; imports = new ArrayList<>(); annotations = new ArrayList<>(); generics = new ArrayList<>(); params = new ArrayList<>(); code = new ArrayList<>(); modifiers = new HashSet<>(); exceptions = new HashSet<>(); } /** * Copy constructor. * * @param prototype the prototype */ private ConstructorImpl(final Constructor prototype) { javadoc = requireNonNull(prototype).getJavadoc().map(Copier::copy).orElse(null); imports = Copier.copy(prototype.getImports()); annotations = Copier.copy(prototype.getAnnotations()); generics = Copier.copy(prototype.getGenerics()); params = Copier.copy(prototype.getFields()); code = Copier.copy(prototype.getCode(), c -> c); modifiers = Copier.copy(prototype.getModifiers(), Modifier::copy, EnumSet.noneOf(Modifier.class)); exceptions = new LinkedHashSet<>(prototype.getExceptions()); } @Override public Constructor setParent(HasConstructors<?> parent) { this.parent = parent; return this; } @Override public Optional<HasConstructors<?>> getParent() { return Optional.ofNullable(parent); } @Override public List<Import> getImports() { return imports; } @Override public List<Field> getFields() { return params; } @Override public List<String> getCode() { return code; } @Override public Set<Modifier> getModifiers() { return modifiers; } @Override public Constructor set(Javadoc doc) { javadoc = doc.setParent(this); return this; } @Override public Optional<Javadoc> getJavadoc() { return Optional.ofNullable(javadoc); } @Override public List<AnnotationUsage> getAnnotations() { return annotations; } @Override public List<Generic> getGenerics() { return generics; } @Override public Set<Type> getExceptions() { return exceptions; } @Override public ConstructorImpl copy() { return new ConstructorImpl(this); } @Override public int hashCode() { int hash = 5; hash = 43 * hash + HashUtil.identityHashForParent(this); // Avoid stack overflow hash = 43 * hash + Objects.hashCode(this.javadoc); hash = 43 * hash + Objects.hashCode(this.imports); hash = 43 * hash + Objects.hashCode(this.annotations); hash = 43 * hash + Objects.hashCode(this.generics); hash = 43 * hash + Objects.hashCode(this.params); hash = 43 * hash + Objects.hashCode(this.code); hash = 43 * hash + Objects.hashCode(this.modifiers); hash = 43 * hash + Objects.hashCode(this.exceptions); return hash; } @Override public boolean equals(Object obj) {<FILL_FUNCTION_BODY>} }
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ConstructorImpl other = (ConstructorImpl) obj; if (!Objects.equals(this.parent, other.parent)) { return false; } if (!Objects.equals(this.javadoc, other.javadoc)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } if (!Objects.equals(this.annotations, other.annotations)) { return false; } if (!Objects.equals(this.generics, other.generics)) { return false; } if (!Objects.equals(this.params, other.params)) { return false; } if (!Objects.equals(this.code, other.code)) { return false; } if (!Objects.equals(this.modifiers, other.modifiers)) { return false; } return Objects.equals(this.exceptions, other.exceptions);
1,040
302
1,342
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/EnumConstantImpl.java
EnumConstantImpl
equals
class EnumConstantImpl implements EnumConstant { private Enum parent; private String name; private Javadoc javadoc; private final List<Import> imports; private final List<ClassOrInterface<?>> classes; private final List<Initializer> initializers; private final List<Method> methods; private final List<Field> fields; private final List<Value<?>> values; private final List<AnnotationUsage> annotations; /** * Initializes this enum constant using a name. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link EnumConstant#of(java.lang.String)} method! * * @param name the name */ public EnumConstantImpl(String name) { this.name = requireNonNull(name); this.imports = new ArrayList<>(); this.classes = new ArrayList<>(); this.initializers = new ArrayList<>(); this.methods = new ArrayList<>(); this.fields = new ArrayList<>(); this.values = new ArrayList<>(); this.annotations = new ArrayList<>(); } /** * Copy constructor. * * @param prototype the prototype */ protected EnumConstantImpl(EnumConstant prototype) { name = requireNonNull(prototype).getName(); javadoc = prototype.getJavadoc().orElse(null); imports = Copier.copy(prototype.getImports()); classes = Copier.copy(prototype.getClasses(), ClassOrInterface::copy); initializers = Copier.copy(prototype.getInitializers(), HasCopy::copy); methods = Copier.copy(prototype.getMethods(), HasCopy::copy); fields = Copier.copy(prototype.getFields(), HasCopy::copy); values = Copier.copy(prototype.getValues(), HasCopy::copy); annotations = Copier.copy(prototype.getAnnotations(), HasCopy::copy); } @Override public EnumConstant setParent(Enum parent) { this.parent = parent; return this; } @Override public Optional<Enum> getParent() { return Optional.ofNullable(parent); } @Override public List<Import> getImports() { return imports; } @Override public EnumConstant setName(String name) { this.name = requireNonNull(name); return this; } @Override public String getName() { return name; } @Override public List<Value<?>> getValues() { return values; } @Override public EnumConstant set(Javadoc doc) { this.javadoc = doc.setParent(this); return this; } @Override public Optional<Javadoc> getJavadoc() { return Optional.ofNullable(javadoc); } @Override public List<ClassOrInterface<?>> getClasses() { return classes; } @Override public List<Initializer> getInitializers() { return initializers; } @Override public List<Method> getMethods() { return methods; } @Override public List<Field> getFields() { return fields; } @Override public List<AnnotationUsage> getAnnotations() { return annotations; } @Override public EnumConstantImpl copy() { return new EnumConstantImpl(this); } @Override public boolean equals(Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { return Objects.hash(name, javadoc, imports, classes, initializers, methods, fields, values, annotations) + HashUtil.identityHashForParent(this); } }
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final EnumConstantImpl that = (EnumConstantImpl) o; return Objects.equals(parent, that.parent) && Objects.equals(name, that.name) && Objects.equals(javadoc, that.javadoc) && Objects.equals(imports, that.imports) && Objects.equals(classes, that.classes) && Objects.equals(initializers, that.initializers) && Objects.equals(methods, that.methods) && Objects.equals(fields, that.fields) && Objects.equals(values, that.values) && Objects.equals(annotations, that.annotations);
1,013
199
1,212
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/FieldImpl.java
FieldImpl
equals
class FieldImpl implements Field { private HasFields<?> parent; private String name; private Type type; private Value<?> value; private Javadoc javadoc; private final List<Import> imports; private final List<AnnotationUsage> annotations; private final Set<Modifier> modifiers; /** * Initializes this field using a name and a type. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Field#of(String, Type)} method! * * @param name the name * @param type the type */ public FieldImpl(String name, Type type) { this.name = requireNonNull(name); this.type = requireNonNull(type); this.value = null; this.javadoc = null; this.imports = new ArrayList<>(); this.annotations = new ArrayList<>(); this.modifiers = EnumSet.noneOf(Modifier.class); } /** * Copy constructor. * * @param prototype the prototype */ protected FieldImpl(Field prototype) { name = requireNonNull(prototype).getName(); type = prototype.getType(); imports = Copier.copy(prototype.getImports()); value = prototype.getValue().map(Copier::copy).orElse(null); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); modifiers = Copier.copy(prototype.getModifiers(), Modifier::copy, EnumSet.noneOf(Modifier.class)); } @Override public Field setParent(HasFields<?> parent) { this.parent = parent; return this; } @Override public Optional<HasFields<?>> getParent() { return Optional.ofNullable(parent); } @Override public List<Import> getImports() { return imports; } @Override public String getName() { return name; } @Override public Field setName(String name) { this.name = requireNonNull(name); return this; } @Override public Type getType() { return type; } @Override public Field set(Type type) { this.type = requireNonNull(type); return this; } @Override public Set<Modifier> getModifiers() { return modifiers; } @Override public Field set(Javadoc doc) { javadoc = doc.setParent(this); return this; } @Override public Optional<Javadoc> getJavadoc() { return Optional.ofNullable(javadoc); } @Override public Field set(Value<?> val) { this.value = val; return this; } @Override public Optional<Value<?>> getValue() { return Optional.ofNullable(value); } @Override public List<AnnotationUsage> getAnnotations() { return annotations; } @Override public FieldImpl copy() { return new FieldImpl(this); } @Override public int hashCode() { int hash = 3; hash = 29 * hash + HashUtil.identityHashForParent(this); hash = 29 * hash + Objects.hashCode(this.name); hash = 29 * hash + Objects.hashCode(this.type); hash = 29 * hash + Objects.hashCode(this.value); hash = 29 * hash + Objects.hashCode(this.javadoc); hash = 29 * hash + Objects.hashCode(this.imports); hash = 29 * hash + Objects.hashCode(this.annotations); hash = 29 * hash + Objects.hashCode(this.modifiers); return hash; } @Override public boolean equals(Object obj) {<FILL_FUNCTION_BODY>} }
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final FieldImpl other = (FieldImpl) obj; if (!Objects.equals(this.parent, other.parent)) { return false; } if (!Objects.equals(this.name, other.name)) { return false; } if (!Objects.equals(this.type, other.type)) { return false; } if (!Objects.equals(this.value, other.value)) { return false; } if (!Objects.equals(this.javadoc, other.javadoc)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } if (!Objects.equals(this.annotations, other.annotations)) { return false; } return Objects.equals(this.modifiers, other.modifiers);
1,061
272
1,333
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/ImportImpl.java
ImportImpl
equals
class ImportImpl implements Import { private HasImports<?> parent; private Type type; private String staticMember; private final Set<Modifier> modifiers; /** * Initializes this import using a type. * <p> * <em>Warning!</em> This class should not be instantiated directly but * using the {@link Import#of(Type)} method! * * @param type the type */ public ImportImpl(Type type) { this.type = requireNonNull(type); this.staticMember = null; this.modifiers = EnumSet.noneOf(Modifier.class); } /** * Copy constructor. * * @param prototype the prototype */ protected ImportImpl(Import prototype) { type = prototype.getType(); modifiers = Copier.copy(prototype.getModifiers(), Modifier::copy, EnumSet.noneOf(Modifier.class)); } @Override public Import setParent(HasImports<?> parent) { this.parent = parent; return this; } @Override public Optional<HasImports<?>> getParent() { return Optional.ofNullable(parent); } @Override public Import set(Type type) { this.type = requireNonNull(type); return this; } @Override public Type getType() { return type; } @Override public Set<Modifier> getModifiers() { return this.modifiers; } @Override public Optional<String> getStaticMember() { return Optional.ofNullable(staticMember); } @Override public Import setStaticMember(String member) { staticMember = member; return this; } @Override public ImportImpl copy() { return new ImportImpl(this); } @Override public int hashCode() { int hash = 5; hash = 29 * hash + HashUtil.identityHashForParent(this); hash = 29 * hash + Objects.hashCode(this.type); hash = 29 * hash + Objects.hashCode(this.staticMember); hash = 29 * hash + Objects.hashCode(this.modifiers); return hash; } @Override public boolean equals(Object obj) {<FILL_FUNCTION_BODY>} }
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ImportImpl other = (ImportImpl) obj; if (!Objects.equals(this.parent, other.parent)) { return false; } if (!Objects.equals(this.staticMember, other.staticMember)) { return false; } if (!Objects.equals(this.type, other.type)) { return false; } return Objects.equals(this.modifiers, other.modifiers);
629
168
797
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/InterfaceMethodImpl.java
InterfaceMethodImpl
hashCode
class InterfaceMethodImpl implements InterfaceMethod { private final Method m; /** * Wraps the specified method. * * @param wrapped the inner method */ public InterfaceMethodImpl(Method wrapped) { this.m = requireNonNull(wrapped); } @Override public InterfaceMethod setParent(Interface parent) { m.setParent(parent); return this; } @Override public Optional<Interface> getParent() { return m.getParent().map(Interface.class::cast); } @Override public String getName() { return m.getName(); } @Override public Type getType() { return m.getType(); } @Override public List<Field> getFields() { return m.getFields(); } @Override public List<String> getCode() { return m.getCode(); } @Override public Set<Modifier> getModifiers() { return m.getModifiers(); } @Override public Optional<Javadoc> getJavadoc() { return m.getJavadoc(); } @Override public List<AnnotationUsage> getAnnotations() { return m.getAnnotations(); } @Override public List<Import> getImports() { return m.getImports(); } @Override public InterfaceMethod setName(String name) { m.setName(name); return this; } @Override public InterfaceMethod set(Type type) { m.set(type); return this; } @Override public List<Generic> getGenerics() { return m.getGenerics(); } @Override public InterfaceMethod set(Javadoc doc) { m.set(doc); doc.setParent(this); return this; } @Override public Set<Type> getExceptions() { return m.getExceptions(); } @Override public InterfaceMethodImpl copy() { return new InterfaceMethodImpl(m.copy()); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final InterfaceMethodImpl other = (InterfaceMethodImpl) obj; return Objects.equals(this.m, other.m); } }
int hash = 7; hash = 11 * hash + Objects.hashCode(this.m); return hash;
680
34
714
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/JavadocImpl.java
JavadocImpl
hashCode
class JavadocImpl implements Javadoc { private HasJavadoc<?> parent; private String text; private final List<Import> imports; private final List<JavadocTag> tags; /** * Initializes this javadoc block. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Javadoc#of()} method! */ public JavadocImpl() { text = ""; tags = new ArrayList<>(); imports = new ArrayList<>(); } /** * Initializes this javadoc block using a text. The text may have multiple * lines separated by new-line characters. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Javadoc#of(java.lang.String)} method! * * @param text the text */ public JavadocImpl(final String text) { this.text = requireNonNull(text); this.tags = new ArrayList<>(); this.imports = new ArrayList<>(); } /** * Copy constructor. * * @param prototype the prototype */ protected JavadocImpl(final Javadoc prototype) { text = requireNonNull(prototype).getText(); tags = Copier.copy(prototype.getTags()); imports = Copier.copy(prototype.getImports()); } @Override public Javadoc setParent(HasJavadoc<?> parent) { this.parent = parent; return this; } @Override public Optional<HasJavadoc<?>> getParent() { return Optional.ofNullable(parent); } @Override public List<Import> getImports() { return imports; } @Override public String getText() { return text; } @Override public Javadoc setText(String text) { this.text = text; return this; } @Override public List<JavadocTag> getTags() { return tags; } @Override public JavadocImpl copy() { return new JavadocImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final JavadocImpl other = (JavadocImpl) obj; if (!Objects.equals(this.parent, other.parent)) { return false; } if (!Objects.equals(this.text, other.text)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } return Objects.equals(this.tags, other.tags); } }
int hash = 7; hash = 29 * hash + HashUtil.identityHashForParent(this); hash = 29 * hash + Objects.hashCode(this.text); hash = 29 * hash + Objects.hashCode(this.imports); hash = 29 * hash + Objects.hashCode(this.tags); return hash;
806
92
898
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/JavadocTagImpl.java
JavadocTagBase
hashCode
class JavadocTagBase implements JavadocTag { private String name; private String value; private String text; private final List<Import> imports; JavadocTagBase(String name) { this.name = requireNonNull(name); this.value = null; this.text = null; this.imports = new ArrayList<>(); } JavadocTagBase(String name, String text) { this.name = requireNonNull(name); this.value = null; this.text = text; this.imports = new ArrayList<>(); } JavadocTagBase(String name, String value, String text) { this.name = requireNonNull(name); this.value = value; this.text = text; this.imports = new ArrayList<>(); } JavadocTagBase(JavadocTag prototype) { requireNonNull(prototype); this.name = prototype.getName(); this.value = prototype.getValue().orElse(null); this.text = prototype.getText().orElse(null); this.imports = Copier.copy(prototype.getImports()); } @Override public Optional<String> getValue() { return Optional.ofNullable(value); } @Override public JavadocTag setValue(String value) { this.value = value; return this; } @Override public List<Import> getImports() { return imports; } @Override public Optional<String> getText() { return Optional.ofNullable(text); } @Override public JavadocTag setText(String text) { this.text = text; return this; } @Override public JavadocTag setName(String name) { this.name = requireNonNull(name); return this; } @Override public String getName() { return name; } @Override public JavadocTagImpl copy() { return new JavadocTagImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final JavadocTagBase other = (JavadocTagBase) obj; if (!Objects.equals(this.name, other.name)) { return false; } if (!Objects.equals(this.value, other.value)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } return Objects.equals(this.text, other.text); } }
int hash = 3; hash = 67 * hash + Objects.hashCode(this.name); hash = 67 * hash + Objects.hashCode(this.value); hash = 67 * hash + Objects.hashCode(this.text); hash = 67 * hash + Objects.hashCode(this.imports); return hash;
764
92
856
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/MethodImpl.java
MethodImpl
hashCode
class MethodImpl implements Method { private HasMethods<?> parent; private String name; private Type type; private Javadoc javadoc; private final List<AnnotationUsage> annotations; private final List<Import> imports; private final List<Generic> generics; private final List<Field> params; private final List<String> code; private final Set<Modifier> modifiers; private final Set<Type> exceptions; /** * Initializes this method using a name and a type. * <p> * <b>Warning!</b> This class should not be instantiated directly but using * the {@link Method#of(String, Type)} method! * * @param name the name * @param type the type */ public MethodImpl(String name, Type type) { this.name = requireNonNull(name); this.type = requireNonNull(type); this.javadoc = null; this.annotations = new ArrayList<>(); this.imports = new ArrayList<>(); this.generics = new ArrayList<>(); this.params = new ArrayList<>(); this.code = new ArrayList<>(); this.modifiers = EnumSet.noneOf(Modifier.class); this.exceptions = new HashSet<>(); } /** * Copy constructor. * * @param prototype the prototype */ protected MethodImpl(final Method prototype) { parent = prototype.getParent().orElse(null); name = requireNonNull(prototype).getName(); type = requireNonNull(prototype.getType()); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); imports = Copier.copy(prototype.getImports()); generics = Copier.copy(prototype.getGenerics()); params = Copier.copy(prototype.getFields()); code = Copier.copy(prototype.getCode(), s -> s); modifiers = Copier.copy(prototype.getModifiers(), Modifier::copy, EnumSet.noneOf(Modifier.class)); exceptions = new HashSet<>(prototype.getExceptions()); } @Override public Method setParent(HasMethods<?> parent) { this.parent = parent; return this; } @Override public Optional<HasMethods<?>> getParent() { return Optional.ofNullable(parent); } @Override public String getName() { return name; } @Override public Method setName(String name) { this.name = requireNonNull(name); return this; } @Override public List<Import> getImports() { return imports; } @Override public Type getType() { return type; } @Override public Method set(Type type) { this.type = requireNonNull(type); return this; } @Override public List<Field> getFields() { return params; } @Override public List<String> getCode() { return code; } @Override public Set<Modifier> getModifiers() { return modifiers; } @Override public Method set(Javadoc doc) { javadoc = doc.setParent(this); return this; } @Override public Optional<Javadoc> getJavadoc() { return Optional.ofNullable(javadoc); } @Override public List<AnnotationUsage> getAnnotations() { return annotations; } @Override public List<Generic> getGenerics() { return generics; } @Override public Set<Type> getExceptions() { return exceptions; } @Override public MethodImpl copy() { return new MethodImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final MethodImpl other = (MethodImpl) obj; if (!Objects.equals(this.parent, other.parent)) { return false; } if (!Objects.equals(this.name, other.name)) { return false; } if (!Objects.equals(this.type, other.type)) { return false; } if (!Objects.equals(this.javadoc, other.javadoc)) { return false; } if (!Objects.equals(this.annotations, other.annotations)) { return false; } if (!Objects.equals(this.imports, other.imports)) { return false; } if (!Objects.equals(this.generics, other.generics)) { return false; } if (!Objects.equals(this.params, other.params)) { return false; } if (!Objects.equals(this.code, other.code)) { return false; } if (!Objects.equals(this.modifiers, other.modifiers)) { return false; } return Objects.equals(this.exceptions, other.exceptions); } }
int hash = 7; hash = 71 * hash + HashUtil.identityHashForParent(this); hash = 71 * hash + Objects.hashCode(this.name); hash = 71 * hash + Objects.hashCode(this.type); hash = 71 * hash + Objects.hashCode(this.javadoc); hash = 71 * hash + Objects.hashCode(this.annotations); hash = 71 * hash + Objects.hashCode(this.imports); hash = 71 * hash + Objects.hashCode(this.generics); hash = 71 * hash + Objects.hashCode(this.params); hash = 71 * hash + Objects.hashCode(this.code); hash = 71 * hash + Objects.hashCode(this.modifiers); hash = 71 * hash + Objects.hashCode(this.exceptions); return hash;
1,428
230
1,658
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/value/AnonymousValueImpl.java
AnonymousValueImpl
equals
class AnonymousValueImpl implements AnonymousValue { private final List<Value<?>> args; private final List<Import> imports; private final List<Type> typeParams; private final List<Field> fields; private final List<Method> methods; private final List<Initializer> initializers; private final List<ClassOrInterface<?>> innerClasses; private Type value; public AnonymousValueImpl() { this.args = new ArrayList<>(); this.imports = new ArrayList<>(); this.typeParams = new ArrayList<>(); this.fields = new ArrayList<>(); this.methods = new ArrayList<>(); this.initializers = new ArrayList<>(); this.innerClasses = new ArrayList<>(); } private AnonymousValueImpl(AnonymousValue prototype) { this.args = Copier.copy(prototype.getValues(), HasCopy::copy); this.imports = Copier.copy(prototype.getImports()); this.typeParams = new ArrayList<>(prototype.getTypeParameters()); this.fields = Copier.copy(prototype.getFields()); this.methods = Copier.copy(prototype.getMethods()); this.initializers = Copier.copy(prototype.getInitializers()); this.innerClasses = Copier.copy(prototype.getClasses(), ClassOrInterface::copy); this.value = prototype.getValue(); } @Override public Type getValue() { return value; } @Override public List<Value<?>> getValues() { return args; } @Override public List<Import> getImports() { return imports; } @Override public List<Type> getTypeParameters() { return typeParams; } @Override public List<Field> getFields() { return fields; } @Override public List<Method> getMethods() { return methods; } @Override public List<Initializer> getInitializers() { return initializers; } @Override public List<ClassOrInterface<?>> getClasses() { return innerClasses; } @Override public AnonymousValue setValue(Type value) { this.value = value; return this; } @Override public AnonymousValue copy() { return new AnonymousValueImpl(this); } @Override public boolean equals(Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { return Objects.hash(args, imports, typeParams, fields, methods, initializers, innerClasses, value); } }
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final AnonymousValueImpl that = (AnonymousValueImpl) o; return Objects.equals(args, that.args) && Objects.equals(imports, that.imports) && Objects.equals(typeParams, that.typeParams) && Objects.equals(fields, that.fields) && Objects.equals(methods, that.methods) && Objects.equals(initializers, that.initializers) && Objects.equals(innerClasses, that.innerClasses) && Objects.equals(value, that.value);
693
172
865
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/model/value/EnumValueImpl.java
EnumValueImpl
hashCode
class EnumValueImpl extends ValueImpl<String> implements EnumValue { private Type type; public EnumValueImpl(Type type, String value) { super (value); this.type = type; } protected EnumValueImpl(EnumValue prototype) { this (prototype.getType(), prototype.getValue()); } @Override public EnumValueImpl set(Type type) { this.type = type; return this; } @Override public Type getType() { return type; } @Override public EnumValueImpl copy() { return new EnumValueImpl(this); } @Override public int hashCode() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } final EnumValue other = (EnumValue) obj; return Objects.equals(this.type, other.getType()); } }
int hash = 7; hash = 79 * hash + super.hashCode(); hash = 79 * hash + Objects.hashCode(this.type); return hash;
261
48
309
<methods>public void <init>(java.lang.String) ,public abstract ValueImpl<java.lang.String> copy() ,public boolean equals(java.lang.Object) ,public java.lang.String getValue() ,public int hashCode() ,public Value<java.lang.String> setValue(java.lang.String) <variables>private java.lang.String value
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/util/NullUtil.java
NullUtil
requireNonNullElements
class NullUtil { private NullUtil() {} /** * Checks if this set is non null and also that all members are non-null. * If a null is detected a NullPointerException is thrown. * * @param <T> the item type * @param <C> the collection type * @param collection to check * @return the same array instance as provided * * @throws NullPointerException if a null is found in the set or if the * set itself is null */ public static <T, C extends Collection<T>> C requireNonNullElements(C collection) { requireNonNull(collection, "The provided collection is null."); collection.forEach(t -> { if (t == null) { throw new NullPointerException( "An item in the collection is null." ); } }); return collection; } /** * Checks if this array is non null and also that all members are non-null. * If a null is detected a NullPointerException is thrown. * * @param <T> array type * @param array to check * @return the same array instance as provided * * @throws NullPointerException if a null is found in the array or if the * array itself is null */ public static <T> T[] requireNonNullElements(T[] array) {<FILL_FUNCTION_BODY>} /** * Checks if all parameters are non-null. If a null is detected a * {@code NullPointerException} is thrown. * * @param <T> array type * @param t0 to check * * @throws NullPointerException if a null is found in the parameters */ public static <T> void requireNonNulls(T t0) { requireNonNull(t0, paramIsNullText(0)); } /** * Checks if all parameters are non-null. If a null is detected a * {@code NullPointerException} is thrown. * * @param <T> array type * @param t0 to check * @param t1 to check * * @throws NullPointerException if a null is found in the parameters */ public static <T> void requireNonNulls(T t0, T t1) { requireNonNull(t0, paramIsNullText(0)); requireNonNull(t1, paramIsNullText(1)); } /** * Checks if all parameters are non-null. If a null is detected a * {@code NullPointerException} is thrown. * * @param <T> array type * @param t0 to check * @param t1 to check * @param t2 to check * * @throws NullPointerException if a null is found in the parameters */ public static <T> void requireNonNulls(T t0, T t1, T t2) { requireNonNull(t0, paramIsNullText(0)); requireNonNull(t1, paramIsNullText(1)); requireNonNull(t2, paramIsNullText(2)); } private static String paramIsNullText(int x) { return "Parameter " + x + " is null."; } }
requireNonNull(array, "The provided array is null."); int len = array.length; for (int i = 0; i < len; i++) { if (array[i] == null) { throw new NullPointerException("Item " + i + " in the array " + Arrays.toString(array) + " is null"); } } return array;
863
98
961
<no_super_class>
speedment_speedment
speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/util/CollectorUtil.java
CollectorUtil
joinIfNotEmpty
class CollectorUtil { private CollectorUtil() { } /** * Similar to the * {@link Collectors#joining(CharSequence, CharSequence, CharSequence)} * method except that this method surrounds the result with the specified * {@code prefix} and {@code suffix} even if the stream is empty. * * @param delimiter the delimiter to separate the strings * @param prefix the prefix to put before the result * @param suffix the suffix to put after the result * @return a {@link Collector} for joining string elements */ public static Collector<String, ?, String> joinIfNotEmpty(String delimiter, String prefix, String suffix) {<FILL_FUNCTION_BODY>} }
return Collector.of( () -> new StringJoiner(delimiter), StringJoiner::add, StringJoiner::merge, s -> s.length() > 0 ? prefix + s + suffix : s.toString() );
193
70
263
<no_super_class>
speedment_speedment
speedment/common-parent/codegenxml/src/main/java/com/speedment/common/codegenxml/internal/XmlDeclarationImpl.java
XmlDeclarationImpl
toString
class XmlDeclarationImpl implements XmlDeclaration { private final List<Attribute> attributes; public XmlDeclarationImpl() { this.attributes = new ArrayList<>(); } @Override public List<Attribute> attributes() { return attributes; } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "<?xml " + attributes().stream() .map(a -> ".") .collect(joining("", " ", "")) + "?>";
95
46
141
<no_super_class>
speedment_speedment
speedment/common-parent/codegenxml/src/main/java/com/speedment/common/codegenxml/internal/view/AttributeView.java
AttributeView
transform
class AttributeView implements Transform<Attribute, String>, HasNameView<Attribute>, HasValueView<Attribute> { @Override public Optional<String> transform(Generator gen, Attribute model) {<FILL_FUNCTION_BODY>} }
return Optional.of(transformName(model) + (model.isEscape() ? transformValue(model) : model.getValue() ).map(s -> "=\"" + s + "\"").orElse("") );
67
66
133
<no_super_class>
speedment_speedment
speedment/common-parent/codegenxml/src/main/java/com/speedment/common/codegenxml/internal/view/ContentElementView.java
ContentElementView
transform
class ContentElementView implements Transform<ContentElement, String>, HasValueView<ContentElement> { @Override public Optional<String> transform(Generator gen, ContentElement model) {<FILL_FUNCTION_BODY>} }
if (model.isEscape()) { return transformValue(model); } else { return model.getValue(); }
61
37
98
<no_super_class>
speedment_speedment
speedment/common-parent/codegenxml/src/main/java/com/speedment/common/codegenxml/internal/view/TagElementView.java
TagElementView
transform
class TagElementView implements Transform<TagElement, String>, HasNameView<TagElement>, HasElementsView<TagElement>, HasAttributesView<TagElement> { @Override public Optional<String> transform(Generator gen, TagElement model) {<FILL_FUNCTION_BODY>} }
return Optional.of("<" + transformName(model) + transformAttributes(gen, model) + (model.elements().isEmpty() ? '/' : "") + '>' + transformElements(gen, model) + (model.elements().isEmpty() ? "" : new StringBuilder() .append("</") .append(transformName(model)) .append('>')) );
83
107
190
<no_super_class>
speedment_speedment
speedment/common-parent/collection/src/main/java/com/speedment/common/collection/LongCache.java
LongCache
getOrCompute
class LongCache<K> { private final AtomicBoolean free; private final LinkedHashMap<K, Long> cache; /** * Creates a new {@code LongCache} with the specified maximum size. * * @param maxSize the maximum size */ public LongCache(int maxSize) { free = new AtomicBoolean(true); cache = new LinkedHashMap<K, Long>(maxSize, 0.75f, true) { private static final long serialVersionUID = 1L; @Override protected boolean removeEldestEntry(Map.Entry<K, Long> eldest) { return size() > maxSize; } }; } /** * This method will return the value for the specified key if it is cached, * and if not, will calculate the value using the supplied method. The * computed value may or may not be stored in the cache afterwards. This * method is guaranteed to be lock-free, and might calculate the value * instead of using the cached one to avoid blocking. * * @param key the key to retrieve the value for * @param compute method to use to compute the value if it is not cached * @return the cached or computed value */ public long getOrCompute(K key, LongSupplier compute) {<FILL_FUNCTION_BODY>} @Override public String toString() { return "LongCache{cache=" + cache + '}'; } }
if (free.compareAndSet(true, false)) { try { return cache.computeIfAbsent(key, k -> compute.getAsLong()); } finally { free.set(true); } } else { return compute.getAsLong(); }
377
76
453
<no_super_class>
speedment_speedment
speedment/common-parent/combinatorics/src/main/java/com/speedment/common/combinatorics/internal/CombinationUtil.java
CombinationUtil
combinationHelper
class CombinationUtil { private CombinationUtil() {} /** * Creates and returns all possible combinations of the given elements. * * The order of the combinations in the stream is unspecified. * * @param <T> element type * @param items to combine * @return all possible combinations of the given elements */ @SafeVarargs @SuppressWarnings("varargs") // Creating a List from an array is safe public static <T> Stream<List<T>> of(final T... items) { return IntStream.rangeClosed(1, items.length) .mapToObj(r -> { @SuppressWarnings("unchecked") final T[] data = (T[]) new Object[r]; return combinationHelper(items, data, 0, items.length - 1, 0, r); }).flatMap(identity()); } /** * Creates and returns all possible combinations of the given elements. * * The order of the combinations in the stream is unspecified. * * @param <T> element type * @param items to combine * @return all possible combinations of the given elements */ @SuppressWarnings("unchecked") public static <T> Stream<List<T>> of(final Collection<T> items) { return of((T[]) items.toArray()); } private static <T> Stream<List<T>> combinationHelper( T[] arr, T[] data, int start, int end, int index, int r) {<FILL_FUNCTION_BODY>} private static <T> List<T> asList(T[] array, int newSize) { return Stream.of(array) .limit(newSize) .collect(Collectors.toList()); } }
// Current combination is ready to be printed, print it if (index == r) { return Stream.of(asList(data, r)); } // replace index with all possible elements. The condition // "end-i+1 >= r-index" makes sure that including one element // at index will make a combination with remaining elements // at remaining positions return IntStream.rangeClosed(start, end) .filter(i -> end - i + 1 >= r - index) .mapToObj(i -> { data[index] = arr[i]; return combinationHelper(arr, data, i + 1, end, index + 1, r); }).flatMap(identity());
469
179
648
<no_super_class>
speedment_speedment
speedment/common-parent/combinatorics/src/main/java/com/speedment/common/combinatorics/internal/PermutationUtil.java
PermutationUtil
permutationHelper
class PermutationUtil { private PermutationUtil() {} public static long factorial(final int n) { if (n > 20 || n < 0) { throw new IllegalArgumentException(n + " is out of range"); } return LongStream.rangeClosed(2, n).reduce(1, (a, b) -> a * b); } public static <T> List<T> permutation(final long no, final List<T> items) { return permutationHelper(no, new LinkedList<>(Objects.requireNonNull(items)), new ArrayList<>()); } private static <T> List<T> permutationHelper(final long no, final LinkedList<T> in, final List<T> out) {<FILL_FUNCTION_BODY>} @SafeVarargs @SuppressWarnings("varargs") // Creating a List from an array is safe public static <T> Stream<Stream<T>> of(final T... items) { return of(Arrays.asList(items)); } public static <T> Stream<Stream<T>> of(final List<T> items) { return LongStream.range(0, factorial(items.size())) .mapToObj(no -> permutation(no, items).stream()); } }
if (in.isEmpty()) { return out; } final long subFactorial = factorial(in.size() - 1); out.add(in.remove((int) (no / subFactorial))); return permutationHelper((int) (no % subFactorial), in, out);
336
78
414
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/exception/NotInjectableException.java
NotInjectableException
message
class NotInjectableException extends RuntimeException { private static final long serialVersionUID = 7548382043527278597L; public NotInjectableException(Class<?> clazz) { super(message(clazz)); } public NotInjectableException(Class<?> clazz, Throwable cause) { super(message(clazz), cause); } private static String message(Class<?> clazz) {<FILL_FUNCTION_BODY>} }
return "Class '" + clazz + "' can't be injected.";
141
22
163
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/Injectable.java
Injectable
supplier
class Injectable<T> { private final Class<T> cls; private final Supplier<T> supplier; Injectable(Class<T> cls, Supplier<T> supplier) { this.cls = requireNonNull(cls); this.supplier = supplier; // Nullable } public Class<T> get() { return cls; } boolean hasSupplier() { return supplier != null; } public Supplier<T> supplier() {<FILL_FUNCTION_BODY>} @Override public boolean equals(Object o) { if (this == o) return true; if (o == null) { return false; } if (getClass() != o.getClass()) { return false; } final Injectable<?> that = (Injectable<?>) o; return cls.equals(that.cls) && Objects.equals(supplier, that.supplier); } @Override public int hashCode() { return Objects.hash(cls, supplier); } }
return Optional.ofNullable(supplier).orElseThrow( () -> new UnsupportedOperationException(format( "Injectable %s does not have a supplier.", cls.getName() )) );
292
60
352
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/dependency/DependencyNodeImpl.java
DependencyNodeImpl
canBe
class DependencyNodeImpl implements DependencyNode { private final Class<?> representedType; private final Set<Dependency> dependencies; private final List<Execution<?>> executions; private State currentState; public DependencyNodeImpl(Class<?> representedType) { this.representedType = requireNonNull(representedType); this.dependencies = newSetFromMap(new ConcurrentHashMap<>()); this.executions = new CopyOnWriteArrayList<>(); this.currentState = State.CREATED; } @Override public Class<?> getRepresentedType() { return representedType; } @Override public Set<Dependency> getDependencies() { return dependencies; } @Override public List<Execution<?>> getExecutions() { return executions; } @Override public State getCurrentState() { return currentState; } @Override public void setState(State newState) { currentState = requireNonNull(newState); } @Override public boolean canBe(State state) {<FILL_FUNCTION_BODY>} @Override public boolean is(State state) { return currentState.ordinal() >= state.ordinal(); } }
// Make sure all dependencies of the executions have been satisfied. return executions.stream() .filter(e -> e.getState().ordinal() <= state.ordinal()) .flatMap(e -> e.getDependencies().stream()) .map(Dependency::getNode) .allMatch(node -> node.is(state));
342
90
432
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/execution/ExecutionOneParamBuilderImpl.java
ExecutionOneParamBuilderImpl
build
class ExecutionOneParamBuilderImpl<T, P0> extends AbstractExecutionBuilder<T> implements ExecutionOneParamBuilder<T, P0> { private final Class<P0> param0; private final State state0; private BiConsumer<T, P0> executeAction; ExecutionOneParamBuilderImpl( Class<T> component, State state, Class<P0> param0, State state0) { super(component, state); this.param0 = requireNonNull(param0); this.state0 = requireNonNull(state0); } @Override public <P1> ExecutionTwoParamBuilder<T, P0, P1> withState( State state1, Class<P1> param1) { return new ExecutionTwoParamBuilderImpl<>( getComponent(), getState(), param0, state0, param1, state1 ); } @Override public ExecutionBuilder<T> withExecute(BiConsumer<T, P0> executeAction) { this.executeAction = requireNonNull(executeAction); return this; } @Override public Execution<T> build(DependencyGraph graph) {<FILL_FUNCTION_BODY>} }
requireNonNull(executeAction, "No execution has been specified."); final DependencyNode node0 = graph.get(param0); final Dependency dep0 = new DependencyImpl(node0, state0); return new AbstractExecution<T>( getComponent(), getState(), singleton(dep0), MissingArgumentStrategy.THROW_EXCEPTION) { @Override public boolean invoke(T component, ClassMapper classMapper) { final P0 arg0 = classMapper.apply(param0); executeAction.accept(component, arg0); return true; } };
326
162
488
<methods><variables>private final non-sealed Class<T> component,private final non-sealed com.speedment.common.injector.State state
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/execution/ExecutionThreeParamBuilderImpl.java
ExecutionThreeParamBuilderImpl
build
class ExecutionThreeParamBuilderImpl<T, P0, P1, P2> extends AbstractExecutionBuilder<T> implements ExecutionThreeParamBuilder<T, P0, P1, P2> { private final Class<P0> param0; private final Class<P1> param1; private final Class<P2> param2; private final State state0; private final State state1; private final State state2; private QuadConsumer<T, P0, P1, P2> executeAction; ExecutionThreeParamBuilderImpl( Class<T> component, State state, Class<P0> param0, State state0, Class<P1> param1, State state1, Class<P2> param2, State state2) { super(component, state); this.param0 = requireNonNull(param0); this.state0 = requireNonNull(state0); this.param1 = requireNonNull(param1); this.state1 = requireNonNull(state1); this.param2 = requireNonNull(param2); this.state2 = requireNonNull(state2); } @Override public ExecutionBuilder<T> withExecute(QuadConsumer<T, P0, P1, P2> executeAction) { this.executeAction = requireNonNull(executeAction); return this; } @Override public Execution<T> build(DependencyGraph graph) {<FILL_FUNCTION_BODY>} }
requireNonNull(executeAction, "No execution has been specified."); final DependencyNode node0 = graph.get(param0); final Dependency dep0 = new DependencyImpl(node0, state0); final DependencyNode node1 = graph.get(param1); final Dependency dep1 = new DependencyImpl(node1, state1); final DependencyNode node2 = graph.get(param2); final Dependency dep2 = new DependencyImpl(node2, state2); return new AbstractExecution<T>( getComponent(), getState(), unmodifiableSet(dep0, dep1, dep2), MissingArgumentStrategy.THROW_EXCEPTION) { @Override public boolean invoke(T component, Execution.ClassMapper classMapper) { final P0 arg0 = classMapper.apply(param0); final P1 arg1 = classMapper.apply(param1); final P2 arg2 = classMapper.apply(param2); executeAction.accept(component, arg0, arg1, arg2); return true; } };
388
297
685
<methods><variables>private final non-sealed Class<T> component,private final non-sealed com.speedment.common.injector.State state
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/execution/ExecutionZeroParamBuilderImpl.java
ExecutionZeroParamBuilderImpl
build
class ExecutionZeroParamBuilderImpl<T> extends AbstractExecutionBuilder<T> implements ExecutionZeroParamBuilder<T> { private Consumer<T> executeAction; public ExecutionZeroParamBuilderImpl(Class<T> component, State state) { super(component, state); } @Override public <P0> ExecutionOneParamBuilder<T, P0> withState( State state0, Class<P0> param0) { return new ExecutionOneParamBuilderImpl<>( getComponent(), getState(), param0, state0 ); } @Override public ExecutionBuilder<T> withExecute(Consumer<T> executeAction) { this.executeAction = requireNonNull(executeAction); return this; } @Override public Execution<T> build(DependencyGraph graph) {<FILL_FUNCTION_BODY>} }
requireNonNull(executeAction, "No execution has been specified."); return new AbstractExecution<T>( getComponent(), getState(), emptySet(), MissingArgumentStrategy.THROW_EXCEPTION) { @Override public boolean invoke(T component, ClassMapper classMapper) { executeAction.accept(component); return true; } };
235
100
335
<methods><variables>private final non-sealed Class<T> component,private final non-sealed com.speedment.common.injector.State state
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/InjectorUtil.java
InjectorUtil
findIn
class InjectorUtil { private InjectorUtil() {} public static <T> T findIn( Class<T> type, Injector injector, List<Object> instances, boolean required) {<FILL_FUNCTION_BODY>} public static <T> Stream<T> findAll( Class<T> type, Injector injector, List<Object> instances) { if (Injector.class.isAssignableFrom(type)) { @SuppressWarnings("unchecked") final T casted = (T) injector; return Stream.of(casted); } return instances.stream() .filter(inst -> type.isAssignableFrom(inst.getClass())) .map(type::cast); } }
final Optional<T> found = findAll(type, injector, instances) .findFirst(); // Order is important. if (required) { return found.orElseThrow(() -> new IllegalArgumentException( "Could not find any installed implementation of " + type.getName() + "." ) ); } else { return found.orElse(null); }
221
107
328
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/PropertiesUtil.java
PropertiesUtil
loadProperties
class PropertiesUtil { private PropertiesUtil() {} public static Properties loadProperties(Logger logger, File configFile) {<FILL_FUNCTION_BODY>} public static <T> void configureParams(T instance, Properties properties, InjectorProxy injectorProxy) { requireNonNull(instance); requireNonNull(properties); requireNonNull(injectorProxy); traverseFields(instance.getClass()) .filter(f -> f.isAnnotationPresent(Config.class)) .forEach(f -> configure(instance, properties, injectorProxy, f)); } private static <T> void configure(T instance, Properties properties, InjectorProxy injectorProxy, Field f) { final Config config = f.getAnnotation(Config.class); final String serialized; if (properties.containsKey(config.name())) { serialized = properties.getProperty(config.name()); } else { serialized = config.value(); } trySetField(instance, f, serialized, injectorProxy, config); } private static <T> void trySetField(T instance, Field f, String serialized, InjectorProxy injectorProxy, Config config) { ReflectionUtil.parse(f.getType(), serialized) .ifPresent(object -> { try { injectorProxy.set(f, instance, object); } catch (final ReflectiveOperationException ex) { throw new InjectorException( "Failed to set config parameter '" + config.name() + "' in class '" + instance.getClass().getName() + "'.", ex ); } }); } }
final Properties properties = new Properties(); if (configFile.exists() && configFile.canRead()) { try (final InputStream in = new FileInputStream(configFile)) { properties.load(in); } catch (final IOException ex) { final String err = "Error loading default settings from " + configFile.getAbsolutePath() + "-file."; logger.error(ex, err); throw new InjectorException(err, ex); } } else { logger.info( "No configuration file '" + configFile.getAbsolutePath() + "' found." ); } return properties;
422
163
585
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/StringUtil.java
StringUtil
commaAnd
class StringUtil { private StringUtil() {} /** * Returns the specified words separated with commas and the word 'and' as * appropriate. * * @param words the words to join * @return the human-readable joined string */ public static String commaAnd(String... words) {<FILL_FUNCTION_BODY>} private static String joinWordsWithAnd(String[] words) { final StringJoiner join = new StringJoiner(", ", "", " and "); for (int i = 0; i < words.length - 1; i++) { join.add(words[i]); } return join.toString() + words[words.length - 1]; } }
switch (words.length) { case 0: return ""; case 1: return words[0]; case 2: return words[0] + " and " + words[1]; default: return joinWordsWithAnd(words); }
189
69
258
<no_super_class>
speedment_speedment
speedment/common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/UrlUtil.java
UrlUtil
tryCreateURL
class UrlUtil { private UrlUtil() {} public static Object tryCreateURL(String serialized) {<FILL_FUNCTION_BODY>} }
Object object; try { object = new URL(serialized); } catch (final MalformedURLException ex) { throw new IllegalArgumentException(String.format( "Specified URL '%s' is malformed.", serialized ), ex); } return object;
45
74
119
<no_super_class>
speedment_speedment
speedment/common-parent/invariant/src/main/java/com/speedment/common/invariant/DoubleRangeUtil.java
DoubleRangeUtil
requireNotEquals
class DoubleRangeUtil { private DoubleRangeUtil() {} /** * Returns the given value if it is positive (greater than {@code 0}). * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is not positive */ public static double requirePositive(double val) { if (Double.compare(val, 0d) <= 0) { throw new IllegalArgumentException(val + IS_NOT_POSITIVE); } return val; } /** * Returns the given value if it is negative (less than {@code 0}). * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is not negative */ public static double requireNegative(double val) { if (Double.compare(val, 0d) >= 0) { throw new IllegalArgumentException(val + IS_NOT_NEGATIVE); } return val; } /** * Returns the given value if it is equal to {@code 0}. * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is not 0 */ public static double requireZero(double val) { if (Double.compare(val, 0d) != 0) { throw new IllegalArgumentException(val + IS_NOT_ZERO); } return val; } /** * Returns the given value if it is not positive (less than or equal to * {@code 0}). * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is positive */ public static double requireNonPositive(double val) { if (Double.compare(val, 0d) > 0) { throw new IllegalArgumentException(val + IS_POSITIVE); } return val; } /** * Returns the given value if it is not negative (greater than or equal to * {@code 0}). * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is negative */ public static double requireNonNegative(double val) { if (Double.compare(val, 0d) < 0) { throw new IllegalArgumentException(val + IS_NEGATIVE); } return val; } /** * Returns the given value if it is not {@code 0}. * * @param val to check * @return the given value * * @throws IllegalArgumentException if the given value is zero */ public static double requireNonZero(double val) { if (Double.compare(val, 0d) == 0) { throw new IllegalArgumentException(val + IS_ZERO); } return val; } public static double requireEquals(double val, double otherVal) { if (Double.compare(val, otherVal) != 0) { throw new IllegalArgumentException(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static double requireNotEquals(double val, double otherVal) { if (val == otherVal) { throw new IllegalArgumentException(val + IS_EQUAL_TO + otherVal); } return val; } public static double requireInRange(double val, double first, double lastExclusive) { if (val < first || val >= lastExclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static double requireInRangeClosed(double val, double first, double lastInclusive) { if (val < first || val > lastInclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val; } /** * Returns the given value if it is positive. * * @param <E> RuntimeException type * * @param val to check * @param exceptionConstructor to use when throwing exception * @return the given value * * @throws RuntimeException if the given value is not positive */ public static <E extends RuntimeException> double requirePositive(double val, Function<String, E> exceptionConstructor) { if (val <= 0) { throw exceptionConstructor.apply(val + IS_NOT_POSITIVE); } return val; } public static <E extends RuntimeException> double requireNegative(double val, Function<String, E> exceptionConstructor) { if (val >= 0) { throw exceptionConstructor.apply(val + IS_NOT_NEGATIVE); } return val; } public static <E extends RuntimeException> double requireZero(double val, Function<String, E> exceptionConstructor) { if (val != 0) { throw exceptionConstructor.apply(val + IS_NOT_ZERO); } return val; } public static <E extends RuntimeException> double requireNonPositive(double val, Function<String, E> exceptionConstructor) { if (val > 0) { throw exceptionConstructor.apply(val + IS_POSITIVE); } return val; } public static <E extends RuntimeException> double requireNonNegative(double val, Function<String, E> exceptionConstructor) { if (val < 0) { throw exceptionConstructor.apply(val + IS_NEGATIVE); } return val; } public static <E extends RuntimeException> double requireNonZero(double val, Function<String, E> exceptionConstructor) { if (val == 0) { throw exceptionConstructor.apply(val + IS_ZERO); } return val; } public static <E extends RuntimeException> double requireEquals(double val, double otherVal, Function<String, E> exceptionConstructor) { if (val != otherVal) { throw exceptionConstructor.apply(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static <E extends RuntimeException> double requireNotEquals(double val, double otherVal, Function<String, E> exceptionConstructor) {<FILL_FUNCTION_BODY>} public static <E extends RuntimeException> double requireInRange(double val, double first, double lastExclusive, Function<String, E> exceptionConstructor) { if (val < first || val >= lastExclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static <E extends RuntimeException> double requireInRangeClosed(double val, double first, double lastInclusive, Function<String, E> exceptionConstructor) { if (val < first || val > lastInclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val; } }
if (val == otherVal) { throw exceptionConstructor.apply(val + IS_EQUAL_TO + otherVal); } return val;
1,877
42
1,919
<no_super_class>
speedment_speedment
speedment/common-parent/invariant/src/main/java/com/speedment/common/invariant/IntRangeUtil.java
IntRangeUtil
requirePositive
class IntRangeUtil { private IntRangeUtil() {} /** * Returns the given value if it is positive. * * @param val to check * @return the given value * @throws IllegalArgumentException if the given value is not positive */ public static int requirePositive(int val) { if (val < 1) { throw new IllegalArgumentException(val + IS_NOT_POSITIVE); } return val; } public static int requireNegative(int val) { if (val > -1) { throw new IllegalArgumentException(val + IS_NOT_NEGATIVE); } return val; } public static int requireZero(int val) { if (val != 0) { throw new IllegalArgumentException(val + IS_NOT_ZERO); } return val; } public static int requireNonPositive(int val) { if (val > 0) { throw new IllegalArgumentException(val + IS_POSITIVE); } return val; } public static int requireNonNegative(int val) { if (val < 0) { throw new IllegalArgumentException(val + IS_NEGATIVE); } return val; } public static int requireNonZero(int val) { if (val == 0) { throw new IllegalArgumentException(val + IS_ZERO); } return val; } public static int requireEquals(int val, int otherVal) { if (val != otherVal) { throw new IllegalArgumentException(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static int requireNotEquals(int val, int otherVal) { if (val == otherVal) { throw new IllegalArgumentException(val + IS_EQUAL_TO + otherVal); } return val; } public static int requireInRange(int val, int first, int lastExclusive) { if (val < first || val >= lastExclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static int requireInRangeClosed(int val, int first, int lastInclusive) { if (val < first || val > lastInclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val; } /** * Returns the given value if it is positive. * * @param <E> RuntimeException type * @param val to check * @param exceptionConstructor to use when throwing exception * @return the given value * @throws RuntimeException if the given value is not positive */ public static <E extends RuntimeException> int requirePositive(int val, Function<String, E> exceptionConstructor) {<FILL_FUNCTION_BODY>} public static <E extends RuntimeException> int requireNegative(int val, Function<String, E> exceptionConstructor) { if (val > -1) { throw exceptionConstructor.apply(val + IS_NOT_NEGATIVE); } return val; } public static <E extends RuntimeException> int requireZero(int val, Function<String, E> exceptionConstructor) { if (val != 0) { throw exceptionConstructor.apply(val + IS_NOT_ZERO); } return val; } public static <E extends RuntimeException> int requireNonPositive(int val, Function<String, E> exceptionConstructor) { if (val > 0) { throw exceptionConstructor.apply(val + IS_POSITIVE); } return val; } public static <E extends RuntimeException> int requireNonNegative(int val, Function<String, E> exceptionConstructor) { if (val < 0) { throw exceptionConstructor.apply(val + IS_NEGATIVE); } return val; } public static <E extends RuntimeException> int requireNonZero(int val, Function<String, E> exceptionConstructor) { if (val == 0) { throw exceptionConstructor.apply(val + IS_ZERO); } return val; } public static <E extends RuntimeException> int requireEquals(int val, int otherVal, Function<String, E> exceptionConstructor) { if (val != otherVal) { throw exceptionConstructor.apply(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static <E extends RuntimeException> int requireNotEquals(int val, int otherVal, Function<String, E> exceptionConstructor) { if (val == otherVal) { throw exceptionConstructor.apply(val + IS_EQUAL_TO + otherVal); } return val; } public static <E extends RuntimeException> int requireInRange(int val, int first, int lastExclusive, Function<String, E> exceptionConstructor) { if (val < first || val >= lastExclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static <E extends RuntimeException> int requireInRangeClosed(int val, int first, int lastInclusive, Function<String, E> exceptionConstructor) { if (val < first || val > lastInclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val; } }
if (val < 1) { throw exceptionConstructor.apply(val + IS_NOT_POSITIVE); } return val;
1,449
38
1,487
<no_super_class>
speedment_speedment
speedment/common-parent/invariant/src/main/java/com/speedment/common/invariant/LongRangeUtil.java
LongRangeUtil
requireInRangeClosed
class LongRangeUtil { private LongRangeUtil() {} /** * Returns the given value if it is positive. * * @param val to check * @return the given value * @throws IllegalArgumentException if the given value is not positive */ public static long requirePositive(long val) { if (val < 1) { throw new IllegalArgumentException(val + IS_NOT_POSITIVE); } return val; } public static long requireNegative(long val) { if (val > -1) { throw new IllegalArgumentException(val + IS_NOT_NEGATIVE); } return val; } public static long requireZero(long val) { if (val != 0) { throw new IllegalArgumentException(val + IS_NOT_ZERO); } return val; } public static long requireNonPositive(long val) { if (val > 0) { throw new IllegalArgumentException(val + IS_POSITIVE); } return val; } public static long requireNonNegative(long val) { if (val < 0) { throw new IllegalArgumentException(val + IS_NEGATIVE); } return val; } public static long requireNonZero(long val) { if (val == 0) { throw new IllegalArgumentException(val + IS_ZERO); } return val; } public static long requireEquals(long val, long otherVal) { if (val != otherVal) { throw new IllegalArgumentException(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static long requireNotEquals(long val, long otherVal) { if (val == otherVal) { throw new IllegalArgumentException(val + IS_EQUAL_TO + otherVal); } return val; } public static long requireInRange(long val, long first, long lastExclusive) { if (val < first || val >= lastExclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static long requireInRangeClosed(long val, long first, long lastInclusive) { if (val < first || val > lastInclusive) { throw new IllegalArgumentException(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val; } /** * Returns the given value if it is positive. * * @param <E> RuntimeException type * @param val to check * @param exceptionConstructor to use when throwing exception * @return the given value * @throws RuntimeException if the given value is not positive */ public static <E extends RuntimeException> long requirePositive(long val, Function<String, E> exceptionConstructor) { if (val < 1) { throw exceptionConstructor.apply(val + IS_NOT_POSITIVE); } return val; } public static <E extends RuntimeException> long requireNegative(long val, Function<String, E> exceptionConstructor) { if (val > -1) { throw exceptionConstructor.apply(val + IS_NOT_NEGATIVE); } return val; } public static <E extends RuntimeException> long requireZero(long val, Function<String, E> exceptionConstructor) { if (val != 0) { throw exceptionConstructor.apply(val + IS_NOT_ZERO); } return val; } public static <E extends RuntimeException> long requireNonPositive(long val, Function<String, E> exceptionConstructor) { if (val > 0) { throw exceptionConstructor.apply(val + IS_POSITIVE); } return val; } public static <E extends RuntimeException> long requireNonNegative(long val, Function<String, E> exceptionConstructor) { if (val < 0) { throw exceptionConstructor.apply(val + IS_NEGATIVE); } return val; } public static <E extends RuntimeException> long requireNonZero(long val, Function<String, E> exceptionConstructor) { if (val == 0) { throw exceptionConstructor.apply(val + IS_ZERO); } return val; } public static <E extends RuntimeException> long requireEquals(long val, long otherVal, Function<String, E> exceptionConstructor) { if (val != otherVal) { throw exceptionConstructor.apply(val + IS_NOT_EQUAL_TO + otherVal); } return val; } public static <E extends RuntimeException> long requireNotEquals(long val, long otherVal, Function<String, E> exceptionConstructor) { if (val == otherVal) { throw exceptionConstructor.apply(val + IS_EQUAL_TO + otherVal); } return val; } public static <E extends RuntimeException> long requireInRange(long val, long first, long lastExclusive, Function<String, E> exceptionConstructor) { if (val < first || val >= lastExclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastExclusive + ")"); } return val; } public static <E extends RuntimeException> long requireInRangeClosed(long val, long first, long lastInclusive, Function<String, E> exceptionConstructor) {<FILL_FUNCTION_BODY>} }
if (val < first || val > lastInclusive) { throw exceptionConstructor.apply(val + IS_NOT_IN_THE_RANGE + first + ", " + lastInclusive + "]"); } return val;
1,429
59
1,488
<no_super_class>
speedment_speedment
speedment/common-parent/jvm-version/src/main/java/com/speedment/common/jvm_version/internal/InternalJvmVersion.java
InternalJvmVersion
version
class InternalJvmVersion { private final String specificationTitle; private final String specificationVersion; private final String specificationVendor; private final String implementationTitle; private final String implementationVersion; private final String implementationVendor; private final int major; private final int minor; private final int security; public InternalJvmVersion() { specificationTitle = System.getProperty("java.vm.specification.name"); specificationVersion = System.getProperty("java.vm.specification.version"); specificationVendor = System.getProperty("java.vm.specification.vendor"); implementationTitle = System.getProperty("java.specification.name"); major = version("major", 1); minor = version("minor", 2); security = version("security", 3); implementationVersion = String.format("%d.%d.%d", major, minor, security); implementationVendor = System.getProperty("java.specification.vendor"); } public String getSpecificationTitle() { return specificationTitle; } public String getSpecificationVersion() { return specificationVersion; } public String getSpecificationVendor() { return specificationVendor; } public String getImplementationTitle() { return implementationTitle; } public String getImplementationVersion() { return implementationVersion; } public String getImplementationVendor() { return implementationVendor; } /** * Returns the <a href="#major">major</a> version number. * * @return The major version number */ public int major() { return major; } /** * Returns the <a href="#minor">minor</a> version number or zero if it was * not set. * * @return The minor version number or zero if it was not set */ public int minor() { return minor; } /** * Returns the <a href="#security">security</a> version number or zero if it * was not set. * * @return The security version number or zero if it was not set */ public int security() { return security; } private int version(String java9Name, int java8Index) {<FILL_FUNCTION_BODY>} }
try { // Try Java 9 first final Method method = Runtime.class.getDeclaredMethod("version"); if (method != null) { final Object version = method.invoke(Runtime.getRuntime()); final Class<?> clazz = Class.forName("java.lang.Runtime$Version"); return (Integer) clazz.getDeclaredMethod(java9Name).invoke(version); } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException unused) { // we are pre Java 9 } try { return Integer.parseInt(System.getProperty("java.runtime.version").split("([\\._-])")[java8Index]); } catch (Exception t) { return 0; }
603
196
799
<no_super_class>
speedment_speedment
speedment/common-parent/logger/src/main/java/com/speedment/common/logger/internal/AbstractLoggerFactory.java
AbstractLoggerFactory
makeNameFrom
class AbstractLoggerFactory implements LoggerFactory { private final Map<String, Logger> loggers; private final Set<LoggerEventListener> listeners; private LoggerFormatter formatter; AbstractLoggerFactory() { loggers = new ConcurrentHashMap<>(); formatter = StandardFormatters.PLAIN_FORMATTER; listeners = Collections.newSetFromMap(new ConcurrentHashMap<>()); } @Override public Logger create(Class<?> binding) { requireNonNull(binding); return acquireLogger(makeNameFrom(binding)); } protected String makeNameFrom(Class<?> binding) {<FILL_FUNCTION_BODY>} @Override public Logger create(String binding) { requireNonNull(binding); return acquireLogger(binding); } @Override public synchronized void setFormatter(LoggerFormatter formatter) { this.formatter = Objects.requireNonNull(formatter); forEachLogger(l -> l.setFormatter(formatter)); } @Override public synchronized LoggerFormatter getFormatter() { return formatter; } protected Logger acquireLogger(String binding) { requireNonNull(binding); return loggers.computeIfAbsent(binding, b -> { final Logger log = make(b, formatter); listeners.forEach(log::addListener); return log; }); } public abstract Logger make(String binding, LoggerFormatter formatter); @Override public void addListener(LoggerEventListener listener) { requireNonNull(listener); if (listeners.add(listener)) { forEachLogger(l -> l.addListener(listener)); } } @Override public void removeListener(LoggerEventListener listener) { requireNonNull(listener); if (listeners.remove(listener)) { forEachLogger(l -> l.removeListener(listener)); } } private void forEachLogger(Consumer<Logger> consumer) { requireNonNull(consumer); loggers().map(Entry::getValue).forEach(consumer); } @Override public Stream<LoggerEventListener> listeners() { return listeners.stream(); } @Override public Stream<Entry<String, Logger>> loggers() { return loggers.entrySet().stream(); } @Override public void setLevel(String path, Level level) { requireNonNull(path); requireNonNull(level); loggers() .filter(e -> e.getKey().startsWith(path) ) .map(Entry::getValue).forEach((Logger l) -> l.setLevel(level) ); } @Override public void setLevel(Class<?> binding, Level level) { requireNonNull(binding); requireNonNull(level); setLevel(makeNameFrom(binding), level); } }
requireNonNull(binding); final String[] tokens = binding.getName().split("\\."); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < tokens.length; i++) { if (i == tokens.length - 1) { sb.append(tokens[i]); } else { sb.append(tokens[i].charAt(0)).append('.'); } } return sb.toString();
771
118
889
<no_super_class>
speedment_speedment
speedment/common-parent/logger/src/main/java/com/speedment/common/logger/internal/formatter/PlainFormatter.java
PlainFormatter
apply
class PlainFormatter implements LoggerFormatter { @Override public String apply(Level level, String name, String message) {<FILL_FUNCTION_BODY>} }
requireNonNull(level); requireNonNull(name); return new StringBuilder() .append(Instant.now().truncatedTo(ChronoUnit.MILLIS).toString()) .append(" ") .append(level.toText()) .append(" [") .append(Thread.currentThread().getName()) .append("] (") .append(name) .append(") - ") .append(message) .toString();
48
123
171
<no_super_class>
speedment_speedment
speedment/common-parent/mapstream/src/main/java/com/speedment/common/mapstream/util/CollectorUtil.java
CollectorUtil
groupBy
class CollectorUtil { private CollectorUtil() {} /** * Returns a new {@link MapStream} where the elements have been grouped together using * the specified function. * * @param <T> the stream element type * @param <C> the type of the key to group by * @param grouper the function to use for grouping * @return a {@link MapStream} grouped by key */ public static <T, C> Collector<T, ?, MapStream<C, List<T>>> groupBy(Function<T, C> grouper) {<FILL_FUNCTION_BODY>} protected static class GroupHolder<C, T> { private final Function<T, C> grouper; private final Map<C, List<T>> elements; private final Function<C, List<T>> createList = c -> new ArrayList<>(); protected GroupHolder(Function<T, C> grouper) { this.grouper = grouper; this.elements = new HashMap<>(); } public void add(T element) { final C key = grouper.apply(element); elements.computeIfAbsent(key, createList) .add(element); } public GroupHolder<C, T> merge(GroupHolder<C, T> holder) { holder.elements.entrySet().forEach(e -> elements.computeIfAbsent(e.getKey(), createList) .addAll(e.getValue()) ); return this; } public MapStream<C, List<T>> finisher() { return MapStream.of(elements); } } }
return Collector.of( () -> new GroupHolder<>(grouper), GroupHolder::add, GroupHolder::merge, GroupHolder::finisher );
438
50
488
<no_super_class>
speedment_speedment
speedment/common-parent/rest/src/main/java/com/speedment/common/rest/AbstractOption.java
AbstractOption
equals
class AbstractOption implements Option { private final String key; private final String value; AbstractOption(String key, String value) { this.key = requireNonNull(key); this.value = requireNonNull(value); } @Override public final String getKey() { return key; } @Override public final String getValue() { return value; } @Override public final int hashCode() { int hash = 5; hash = 53 * hash + Objects.hashCode(this.key); hash = 53 * hash + Objects.hashCode(this.value); return hash; } @Override public final boolean equals(Object obj) {<FILL_FUNCTION_BODY>} @Override public String toString() { return key + '=' + value; } }
if (this == obj) return true; else if (obj == null) return false; else if (getClass() != obj.getClass()) return false; final Option other = (Option) obj; return Objects.equals(this.key, other.getKey()) && Objects.equals(this.value, other.getValue());
232
90
322
<no_super_class>
speedment_speedment
speedment/common-parent/rest/src/main/java/com/speedment/common/rest/Response.java
Response
decodeJson
class Response { private final int status; private final String text; private final Map<String, List<String>> headers; public Response(int status, String text, Map<String, List<String>> headers) { this.status = status; this.text = requireNonNull(text); this.headers = requireNonNull(headers); } public int getStatus() { return status; } public String getText() { return text; } public Map<String, List<String>> getHeaders() { return headers; } public boolean success() { switch (status) { case 200: case 201: case 202: case 203: case 204: case 205: case 206: return true; default: return false; } } public Optional<Object> decodeJson() {<FILL_FUNCTION_BODY>} public Stream<Object> decodeJsonArray() { @SuppressWarnings("unchecked") final Collection<Object> results = (Collection<Object>) Json.fromJson(text); return results.stream(); } }
if (!success()) { return Optional.empty(); } else { return Optional.ofNullable(Json.fromJson(text)); }
315
40
355
<no_super_class>
speedment_speedment
speedment/common-parent/rest/src/main/java/com/speedment/common/rest/RestException.java
RestException
message
class RestException extends RuntimeException { private static final long serialVersionUID = 1783560981699960801L; private final Rest.Protocol protocol; private final Rest.Method method; private final String host; private final int port; private final String username; private final String path; public RestException(Throwable cause, Rest.Protocol protocol, Rest.Method method, String username, String host, int port, String path, Option[] options) { super(message(protocol, method, username, host, port, path, options), cause); this.protocol = requireNonNull(protocol); this.method = requireNonNull(method); this.host = requireNonNull(host); this.port = port; this.username = username; this.path = path; } @Override public String toString() { return "RestException{" + "protocol=" + protocol + ", method=" + method + ", host='" + host + '\'' + ", port=" + port + ", username='" + username + '\'' + ", path='" + path + '\'' + '}'; } private static String message(Rest.Protocol protocol, Rest.Method method, String username, String host, int port, String path, Option[] options) {<FILL_FUNCTION_BODY>} }
final StringBuilder str = new StringBuilder("Exception while invoking "); str.append(method).append(' '); if (username != null) str.append(username).append('@'); str.append(protocol.name().toLowerCase()).append("://"); str.append(host); if (port > 0) str.append(':').append(port); if (!path.isEmpty() && !path.equals("/")) { if (!path.startsWith("/")) str.append('/'); str.append(path); } final Param[] params = Stream.of(options) .filter(Objects::nonNull) .filter(o -> o.getType() == PARAM) .filter(Param.class::isInstance) .map(Param.class::cast) .toArray(Param[]::new); if (params.length > 0) { str.append( Arrays.stream(params) .map(Param::toString) .collect(joining("&", "?", "")) ); } return str.toString();
362
279
641
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID
speedment_speedment
speedment/common-parent/singletonstream/src/main/java/com/speedment/common/singletonstream/internal/SingletonPrimitiveIteratorOfLong.java
SingletonPrimitiveIteratorOfLong
next
class SingletonPrimitiveIteratorOfLong implements PrimitiveIterator.OfLong { private final long element; private boolean hasNext = true; public SingletonPrimitiveIteratorOfLong(long element) { this.element = element; } @Override public boolean hasNext() { return hasNext; } @Override public long nextLong() { if (hasNext) { hasNext = false; return element; } throw new NoSuchElementException(); } @Override public Long next() {<FILL_FUNCTION_BODY>} @Override public void remove() { throw new UnsupportedOperationException(); } @Override public void forEachRemaining(LongConsumer action) { requireNonNull(action); if (hasNext) { action.accept(element); hasNext = false; } } }
if (!hasNext) { throw new NoSuchElementException(); } return nextLong();
237
29
266
<no_super_class>
speedment_speedment
speedment/common-parent/singletonstream/src/main/java/com/speedment/common/singletonstream/internal/SingletonPrimitiveSpliteratorOfInt.java
SingletonPrimitiveSpliteratorOfInt
tryAdvance
class SingletonPrimitiveSpliteratorOfInt implements Spliterator.OfInt { private final int element; private long estimatedSize = 1; public SingletonPrimitiveSpliteratorOfInt(int element) { this.element = element; } @Override public OfInt trySplit() { return null; } @Override public boolean tryAdvance(IntConsumer consumer) {<FILL_FUNCTION_BODY>} @Override public void forEachRemaining(IntConsumer consumer) { tryAdvance(consumer); } @Override public long estimateSize() { return estimatedSize; } @Override public int characteristics() { return Spliterator.NONNULL | Spliterator.SIZED | Spliterator.SUBSIZED | Spliterator.IMMUTABLE | Spliterator.DISTINCT | Spliterator.ORDERED; } }
Objects.requireNonNull(consumer); if (estimatedSize > 0) { estimatedSize--; consumer.accept(element); return true; } return false;
242
53
295
<no_super_class>
speedment_speedment
speedment/common-parent/singletonstream/src/main/java/com/speedment/common/singletonstream/internal/SingletonPrimitiveSpliteratorOfLong.java
SingletonPrimitiveSpliteratorOfLong
tryAdvance
class SingletonPrimitiveSpliteratorOfLong implements Spliterator.OfLong { private final long element; private long estimatedSize = 1; public SingletonPrimitiveSpliteratorOfLong(long element) { this.element = element; } @Override public OfLong trySplit() { return null; } @Override public boolean tryAdvance(LongConsumer consumer) {<FILL_FUNCTION_BODY>} @Override public void forEachRemaining(LongConsumer consumer) { tryAdvance(consumer); } @Override public long estimateSize() { return estimatedSize; } @Override public int characteristics() { return Spliterator.NONNULL | Spliterator.SIZED | Spliterator.SUBSIZED | Spliterator.IMMUTABLE | Spliterator.DISTINCT | Spliterator.ORDERED; } }
Objects.requireNonNull(consumer); if (estimatedSize > 0) { estimatedSize--; consumer.accept(element); return true; } return false;
242
53
295
<no_super_class>
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/TupleBuilder.java
Builder17
add
class Builder17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> extends BaseBuilder<Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> { public <T17> Builder18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> add(T17 e17) {<FILL_FUNCTION_BODY>} }
current = Tuples.of( current.get(0), current.get(1), current.get(2), current.get(3), current.get(4), current.get(5), current.get(6), current.get(7), current.get(8), current.get(9), current.get(10), current.get(11), current.get(12), current.get(13), current.get(14), current.get(15), current.get(16), e17 ); return new Builder18<>();
233
174
407
<no_super_class>
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/BasicAbstractTuple.java
BasicAbstractTuple
equals
class BasicAbstractTuple<T extends BasicTuple<R>, R> implements BasicTuple<R> { protected final Object[] values; @SuppressWarnings("rawtypes") protected final Class<? extends T> baseClass; @SuppressWarnings("rawtypes") BasicAbstractTuple(Class<? extends T> baseClass, Object... values) { requireNonNull(values); this.baseClass = requireNonNull(baseClass); if (!isNullable()) { for (Object v : values) { requireNonNull(v, () -> getClass().getName() + " cannot hold null values."); } } // Defensive copying this.values = Arrays.copyOf(values, values.length); if (values.length != degree()) { throw new IllegalArgumentException( "A Tuple of degree " + degree() + " must contain exactly " + degree() + " elements. Element length was " + values.length); } } /** * Returns if this Tuple can contain null elements. * * @return if this Tuple can contain null elements */ protected abstract boolean isNullable(); protected int assertIndexBounds(int index) { if (index < 0 || index >= degree()) { throw new IndexOutOfBoundsException("index " + index + " is illegal. The degree of this Tuple is " + degree() + "."); } return index; } @Override public int hashCode() { return Objects.hash(values); } @Override public boolean equals(Object obj) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + " " + Stream.of(values) .map(Objects::toString) .collect(joining(", ", "{", "}")); } @Override public <C> Stream<C> streamOf(Class<C> clazz) { requireNonNull(clazz); return Stream.of(values) .filter(clazz::isInstance) .map(clazz::cast); } }
if (obj == null) { return false; } if (!baseClass.isInstance(obj)) { return false; } if (obj instanceof BasicAbstractTuple) { @SuppressWarnings("unchecked") final BasicAbstractTuple<?, ?> tuple = (BasicAbstractTuple<?, ?>) obj; // Faster return Arrays.equals(this.values, tuple.values); } // Must be a BasicTuple since baseClass is a BasicTuple @SuppressWarnings("unchecked") final BasicTuple<?> tuple = (BasicTuple<?>) obj; final int capacity = tuple.degree(); for (int i = 0; i < capacity; i++) { if (!Objects.equals(get(i), tuple.get(i))) { return false; } } return true;
551
226
777
<no_super_class>
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple11MapperImpl.java
Tuple11MapperImpl
apply
class Tuple11MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends AbstractTupleMapper<T, Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> implements TupleMapper<T, Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple11 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 */ public Tuple11MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10) { super(11); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); } @Override public Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t) );
991
115
1,106
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple12MapperImpl.java
Tuple12MapperImpl
apply
class Tuple12MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> extends AbstractTupleMapper<T, Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> implements TupleMapper<T, Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple12 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 */ public Tuple12MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11) { super(12); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); } @Override public Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t) );
1,080
125
1,205
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple14MapperImpl.java
Tuple14MapperImpl
apply
class Tuple14MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> extends AbstractTupleMapper<T, Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> implements TupleMapper<T, Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple14 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 */ public Tuple14MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13) { super(14); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); } @Override public Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t) );
1,258
145
1,403
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple15MapperImpl.java
Tuple15MapperImpl
apply
class Tuple15MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> extends AbstractTupleMapper<T, Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> implements TupleMapper<T, Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple15 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 * @param m14 mapper to apply for element 14 */ public Tuple15MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13, Function<T, T14> m14) { super(15); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); set(14, m14); } @Override public Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } public Function<T, T14> get14() { return getAndCast(14); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t), get14().apply(t) );
1,347
155
1,502
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple18MapperImpl.java
Tuple18MapperImpl
apply
class Tuple18MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> extends AbstractTupleMapper<T, Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> implements TupleMapper<T, Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple18 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 * @param m14 mapper to apply for element 14 * @param m15 mapper to apply for element 15 * @param m16 mapper to apply for element 16 * @param m17 mapper to apply for element 17 */ public Tuple18MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13, Function<T, T14> m14, Function<T, T15> m15, Function<T, T16> m16, Function<T, T17> m17) { super(18); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); set(14, m14); set(15, m15); set(16, m16); set(17, m17); } @Override public Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } public Function<T, T14> get14() { return getAndCast(14); } public Function<T, T15> get15() { return getAndCast(15); } public Function<T, T16> get16() { return getAndCast(16); } public Function<T, T17> get17() { return getAndCast(17); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t), get14().apply(t), get15().apply(t), get16().apply(t), get17().apply(t) );
1,614
185
1,799
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple19MapperImpl.java
Tuple19MapperImpl
apply
class Tuple19MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> extends AbstractTupleMapper<T, Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> implements TupleMapper<T, Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple19 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 * @param m14 mapper to apply for element 14 * @param m15 mapper to apply for element 15 * @param m16 mapper to apply for element 16 * @param m17 mapper to apply for element 17 * @param m18 mapper to apply for element 18 */ public Tuple19MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13, Function<T, T14> m14, Function<T, T15> m15, Function<T, T16> m16, Function<T, T17> m17, Function<T, T18> m18) { super(19); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); set(14, m14); set(15, m15); set(16, m16); set(17, m17); set(18, m18); } @Override public Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } public Function<T, T14> get14() { return getAndCast(14); } public Function<T, T15> get15() { return getAndCast(15); } public Function<T, T16> get16() { return getAndCast(16); } public Function<T, T17> get17() { return getAndCast(17); } public Function<T, T18> get18() { return getAndCast(18); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t), get14().apply(t), get15().apply(t), get16().apply(t), get17().apply(t), get18().apply(t) );
1,703
195
1,898
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple6MapperImpl.java
Tuple6MapperImpl
apply
class Tuple6MapperImpl<T, T0, T1, T2, T3, T4, T5> extends AbstractTupleMapper<T, Tuple6<T0, T1, T2, T3, T4, T5>> implements TupleMapper<T, Tuple6<T0, T1, T2, T3, T4, T5>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple6 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 */ public Tuple6MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5) { super(6); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); } @Override public Tuple6<T0, T1, T2, T3, T4, T5> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t) );
581
69
650
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple7MapperImpl.java
Tuple7MapperImpl
apply
class Tuple7MapperImpl<T, T0, T1, T2, T3, T4, T5, T6> extends AbstractTupleMapper<T, Tuple7<T0, T1, T2, T3, T4, T5, T6>> implements TupleMapper<T, Tuple7<T0, T1, T2, T3, T4, T5, T6>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple7 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 */ public Tuple7MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6) { super(7); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); } @Override public Tuple7<T0, T1, T2, T3, T4, T5, T6> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t) );
657
78
735
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple8MapperImpl.java
Tuple8MapperImpl
apply
class Tuple8MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7> extends AbstractTupleMapper<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> implements TupleMapper<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple8 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 */ public Tuple8MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7) { super(8); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); } @Override public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t) );
733
87
820
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nonnullable/mapper/Tuple9MapperImpl.java
Tuple9MapperImpl
apply
class Tuple9MapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8> extends AbstractTupleMapper<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> implements TupleMapper<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple9 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 */ public Tuple9MapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8) { super(9); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); } @Override public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } }
return Tuples.of( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t) );
809
96
905
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple10OfNullablesMapperImpl.java
Tuple10OfNullablesMapperImpl
apply
class Tuple10OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> extends AbstractTupleMapper<T, Tuple10OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> implements TupleMapper<T, Tuple10OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple10 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 */ public Tuple10OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9) { super(10); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); } @Override public Tuple10OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t) );
907
110
1,017
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple11OfNullablesMapperImpl.java
Tuple11OfNullablesMapperImpl
apply
class Tuple11OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends AbstractTupleMapper<T, Tuple11OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> implements TupleMapper<T, Tuple11OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple11 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 */ public Tuple11OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10) { super(11); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); } @Override public Tuple11OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t) );
1,006
120
1,126
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple14OfNullablesMapperImpl.java
Tuple14OfNullablesMapperImpl
apply
class Tuple14OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> extends AbstractTupleMapper<T, Tuple14OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> implements TupleMapper<T, Tuple14OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple14 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 */ public Tuple14OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13) { super(14); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); } @Override public Tuple14OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t) );
1,273
150
1,423
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple15OfNullablesMapperImpl.java
Tuple15OfNullablesMapperImpl
apply
class Tuple15OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> extends AbstractTupleMapper<T, Tuple15OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> implements TupleMapper<T, Tuple15OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple15 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 * @param m14 mapper to apply for element 14 */ public Tuple15OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13, Function<T, T14> m14) { super(15); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); set(14, m14); } @Override public Tuple15OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } public Function<T, T14> get14() { return getAndCast(14); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t), get14().apply(t) );
1,362
160
1,522
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple19OfNullablesMapperImpl.java
Tuple19OfNullablesMapperImpl
apply
class Tuple19OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> extends AbstractTupleMapper<T, Tuple19OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> implements TupleMapper<T, Tuple19OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple19 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 * @param m9 mapper to apply for element 9 * @param m10 mapper to apply for element 10 * @param m11 mapper to apply for element 11 * @param m12 mapper to apply for element 12 * @param m13 mapper to apply for element 13 * @param m14 mapper to apply for element 14 * @param m15 mapper to apply for element 15 * @param m16 mapper to apply for element 16 * @param m17 mapper to apply for element 17 * @param m18 mapper to apply for element 18 */ public Tuple19OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8, Function<T, T9> m9, Function<T, T10> m10, Function<T, T11> m11, Function<T, T12> m12, Function<T, T13> m13, Function<T, T14> m14, Function<T, T15> m15, Function<T, T16> m16, Function<T, T17> m17, Function<T, T18> m18) { super(19); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); set(9, m9); set(10, m10); set(11, m11); set(12, m12); set(13, m13); set(14, m14); set(15, m15); set(16, m16); set(17, m17); set(18, m18); } @Override public Tuple19OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } public Function<T, T9> get9() { return getAndCast(9); } public Function<T, T10> get10() { return getAndCast(10); } public Function<T, T11> get11() { return getAndCast(11); } public Function<T, T12> get12() { return getAndCast(12); } public Function<T, T13> get13() { return getAndCast(13); } public Function<T, T14> get14() { return getAndCast(14); } public Function<T, T15> get15() { return getAndCast(15); } public Function<T, T16> get16() { return getAndCast(16); } public Function<T, T17> get17() { return getAndCast(17); } public Function<T, T18> get18() { return getAndCast(18); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t), get9().apply(t), get10().apply(t), get11().apply(t), get12().apply(t), get13().apply(t), get14().apply(t), get15().apply(t), get16().apply(t), get17().apply(t), get18().apply(t) );
1,718
200
1,918
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple8OfNullablesMapperImpl.java
Tuple8OfNullablesMapperImpl
apply
class Tuple8OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7> extends AbstractTupleMapper<T, Tuple8OfNullables<T0, T1, T2, T3, T4, T5, T6, T7>> implements TupleMapper<T, Tuple8OfNullables<T0, T1, T2, T3, T4, T5, T6, T7>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple8 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 */ public Tuple8OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7) { super(8); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); } @Override public Tuple8OfNullables<T0, T1, T2, T3, T4, T5, T6, T7> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t) );
748
92
840
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/common-parent/tuple/src/main/java/com/speedment/common/tuple/internal/nullable/mapper/Tuple9OfNullablesMapperImpl.java
Tuple9OfNullablesMapperImpl
apply
class Tuple9OfNullablesMapperImpl<T, T0, T1, T2, T3, T4, T5, T6, T7, T8> extends AbstractTupleMapper<T, Tuple9OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8>> implements TupleMapper<T, Tuple9OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8>> { /** * Constructs a {@link TupleMapper } that can create {@link Tuple9 }. * * @param m0 mapper to apply for element 0 * @param m1 mapper to apply for element 1 * @param m2 mapper to apply for element 2 * @param m3 mapper to apply for element 3 * @param m4 mapper to apply for element 4 * @param m5 mapper to apply for element 5 * @param m6 mapper to apply for element 6 * @param m7 mapper to apply for element 7 * @param m8 mapper to apply for element 8 */ public Tuple9OfNullablesMapperImpl( Function<T, T0> m0, Function<T, T1> m1, Function<T, T2> m2, Function<T, T3> m3, Function<T, T4> m4, Function<T, T5> m5, Function<T, T6> m6, Function<T, T7> m7, Function<T, T8> m8) { super(9); set(0, m0); set(1, m1); set(2, m2); set(3, m3); set(4, m4); set(5, m5); set(6, m6); set(7, m7); set(8, m8); } @Override public Tuple9OfNullables<T0, T1, T2, T3, T4, T5, T6, T7, T8> apply(T t) {<FILL_FUNCTION_BODY>} public Function<T, T0> get0() { return getAndCast(0); } public Function<T, T1> get1() { return getAndCast(1); } public Function<T, T2> get2() { return getAndCast(2); } public Function<T, T3> get3() { return getAndCast(3); } public Function<T, T4> get4() { return getAndCast(4); } public Function<T, T5> get5() { return getAndCast(5); } public Function<T, T6> get6() { return getAndCast(6); } public Function<T, T7> get7() { return getAndCast(7); } public Function<T, T8> get8() { return getAndCast(8); } }
return TuplesOfNullables.ofNullables( get0().apply(t), get1().apply(t), get2().apply(t), get3().apply(t), get4().apply(t), get5().apply(t), get6().apply(t), get7().apply(t), get8().apply(t) );
824
101
925
<methods>public final int degree() ,public final Function<T,?> get(int) <variables>private final non-sealed Function<T,?>[] mappers
speedment_speedment
speedment/generator-parent/generator-core/src/main/java/com/speedment/generator/core/internal/util/InternalHashUtil.java
InternalHashUtil
md5
class InternalHashUtil { private InternalHashUtil() {} private static final String ALGORITHM = "MD5"; private static final Charset CHARSET = StandardCharsets.UTF_8; public static boolean compare(Path contentPath, Path checksumPath) { final String expected = HashUtil.md5(contentPath); final String actual = load(checksumPath).get(0); return expected.equals(actual); } public static boolean compare(Path path, String checksum) { final String expected = HashUtil.md5(path); return expected.equals(checksum); } public static boolean compare(String content, String checksum) { final String expected = md5(content); return expected.equals(checksum); } public static String md5(Path path) { return md5(load(path)); } public static String md5(String content) { return md5(Arrays.asList(content.split("\\s+"))); } private static String md5(List<String> rows) { return md5(rows.stream() .map(String::trim) .flatMap(s -> Arrays.stream(s.split("\\s+"))) .collect(joining()) .getBytes(CHARSET) ); } private static String md5(byte[] bytes) {<FILL_FUNCTION_BODY>} private static String bytesToHex(byte[] bytes) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { result.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); } return result.toString(); } private static List<String> load(Path path) { try { return Files.readAllLines(path, CHARSET); } catch (final IOException ex) { throw new SpeedmentException( "Error reading file '" + path + "' for hashing.", ex ); } } }
final MessageDigest md; try { md = MessageDigest.getInstance(ALGORITHM); } catch(final NoSuchAlgorithmException ex) { throw new SpeedmentException( "Could not find hashing algorithm '" + ALGORITHM + "'.", ex ); } return bytesToHex(md.digest(bytes));
545
96
641
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/StandardTranslatorKey.java
StandardTranslatorKey
tableTranslatorKeys
class StandardTranslatorKey { private StandardTranslatorKey() {} public static final TranslatorKey<Project, Interface> APPLICATION = TranslatorKey.of("Application", Interface.class); public static final TranslatorKey<Project, Interface> GENERATED_APPLICATION = TranslatorKey.of("GeneratedApplication", Interface.class); public static final TranslatorKey<Project, Class> APPLICATION_IMPL = TranslatorKey.of("ApplicationImpl", Class.class); public static final TranslatorKey<Project, Class> GENERATED_APPLICATION_IMPL = TranslatorKey.of("GeneratedApplicationImpl", Class.class); public static final TranslatorKey<Project, Class> APPLICATION_BUILDER = TranslatorKey.of("ApplicationBuilder", Class.class); public static final TranslatorKey<Project, Class> GENERATED_APPLICATION_BUILDER = TranslatorKey.of("GeneratedApplicationBuilder", Class.class); public static final TranslatorKey<Project, Class> GENERATED_METADATA = TranslatorKey.of("GeneratedMetadata", Class.class); public static final TranslatorKey<Project, Class> INJECTOR_PROXY = TranslatorKey.of("InjectorProxy", Class.class); public static final TranslatorKey<Project, Class> ENTRY_POINT = TranslatorKey.of("EntryPoint", Class.class); public static final TranslatorKey<Table, Interface> ENTITY = TranslatorKey.of("Entity", Interface.class); public static final TranslatorKey<Table, Interface> MANAGER = TranslatorKey.of("Manager", Interface.class); public static final TranslatorKey<Table, Interface> GENERATED_ENTITY = TranslatorKey.of("GeneratedEntity", Interface.class); public static final TranslatorKey<Table, Interface> GENERATED_MANAGER = TranslatorKey.of("GeneratedManager", Interface.class); public static final TranslatorKey<Table, Class> ENTITY_IMPL = TranslatorKey.of("EntityImpl", Class.class); public static final TranslatorKey<Table, Class> MANAGER_IMPL = TranslatorKey.of("ManagerImpl", Class.class); public static final TranslatorKey<Table, Class> SQL_ADAPTER = TranslatorKey.of("SqlAdapter", Class.class); public static final TranslatorKey<Table, Class> GENERATED_ENTITY_IMPL = TranslatorKey.of("GeneratedEntityImpl", Class.class); public static final TranslatorKey<Table, Class> GENERATED_MANAGER_IMPL = TranslatorKey.of("GeneratedManagerImpl", Class.class); public static final TranslatorKey<Table, Class> GENERATED_SQL_ADAPTER = TranslatorKey.of("GeneratedSqlAdapter", Class.class); /** * Returns a stream of the standard {@link TranslatorKey Translator Keys} * that is used on a per project basis. * * @return stream of standard project {@link TranslatorKey Translator Keys} */ public static Stream<TranslatorKey<Project, ? extends ClassOrInterface<?>>> projectTranslatorKeys() { return Stream.of( APPLICATION, GENERATED_APPLICATION, APPLICATION_IMPL, GENERATED_APPLICATION_IMPL, APPLICATION_BUILDER, GENERATED_APPLICATION_BUILDER, GENERATED_METADATA, INJECTOR_PROXY, ENTRY_POINT ); } /** * Returns a stream of the standard {@link TranslatorKey Translator Keys} * that is used on a 'per table' basis. * * @return stream of standard table {@link TranslatorKey Translator Keys} */ public static Stream<TranslatorKey<Table, ? extends ClassOrInterface<?>>> tableTranslatorKeys() {<FILL_FUNCTION_BODY>} }
return Stream.of( ENTITY, GENERATED_ENTITY, ENTITY_IMPL, GENERATED_ENTITY_IMPL, MANAGER, GENERATED_MANAGER, MANAGER_IMPL , GENERATED_MANAGER_IMPL );
1,022
82
1,104
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/internal/util/InternalColumnUtil.java
InternalColumnUtil
optionalGetterName
class InternalColumnUtil { private InternalColumnUtil() {} public static boolean usesOptional(Column col) { return col.isNullable() && HasNullable.ImplementAs.OPTIONAL == col.getNullableImplementation(); } public static Optional<String> optionalGetterName(TypeMapperComponent typeMappers, Column column) {<FILL_FUNCTION_BODY>} }
final Type colType = typeMappers.get(column).getJavaType(column); final String getterName; if (usesOptional(column)) { if (Double.class.getName().equals(colType.getTypeName())) { getterName = ".getAsDouble()"; } else if (Integer.class.getName().equals(colType.getTypeName())) { getterName = ".getAsInt()"; } else if (Long.class.getName().equals(colType.getTypeName())) { getterName = ".getAsLong()"; } else { getterName = ".get()"; } } else { return Optional.empty(); } return Optional.of(getterName);
104
189
293
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/internal/util/InternalForeignKeyUtil.java
InternalForeignKeyUtil
getReferenceFieldType
class InternalForeignKeyUtil { private InternalForeignKeyUtil() {} public static ForeignKeyUtil.ReferenceFieldType getReferenceFieldType( final File file, final Table table, final Column column, final Type entityType, final Injector injector ) {<FILL_FUNCTION_BODY>} public static Optional<? extends ForeignKeyColumn> getForeignKey(Table table, Column column) { requireNonNull(table); requireNonNull(column); return table.foreignKeys() .filter(HasEnabled::test) .filter(fk -> fk.foreignKeyColumns().count() == 1) // We can only handle one column FKs... .flatMap(ForeignKey::foreignKeyColumns) .filter(fkc -> fkc.findForeignTable().map(Table::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled Table .filter(fkc -> fkc.findForeignColumn().map(Column::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled column .filter(fkc -> DocumentDbUtil.isSame(column, fkc.findColumn().orElse(null))) .findFirst(); } }
requireNonNull(file); requireNonNull(table); requireNonNull(column); requireNonNull(entityType); requireNonNull(injector); final TypeMapper<?, ?> tm = injector.getOrThrow(TypeMapperComponent.class).get(column); final Type javaType = tm.getJavaType(column); final Type databaseType = SimpleType.create(column.getDatabaseType()); final TypeMapper.Category category = tm.getJavaTypeCategory(column); return ForeignKeyUtil.getForeignKey(table, column) // If this is a foreign key. .map(fkc -> { final Type type; final Type fkType = new TranslatorSupport<>(injector, fkc.findForeignTable().orElseThrow( () -> new SpeedmentException( "Could not find referenced foreign table '" + fkc.getForeignTableName() + "'." ))).entityType(); file.add(Import.of(fkType)); switch (category) { case STRING : type = SimpleParameterizedType.create( StringForeignKeyField.class, entityType, databaseType, fkType ); break; case BYTE : type = SimpleParameterizedType.create( ByteForeignKeyField.class, entityType, databaseType, fkType ); break; case SHORT : type = SimpleParameterizedType.create( ShortForeignKeyField.class, entityType, databaseType, fkType ); break; case INT : type = SimpleParameterizedType.create( IntForeignKeyField.class, entityType, databaseType, fkType ); break; case LONG : type = SimpleParameterizedType.create( LongForeignKeyField.class, entityType, databaseType, fkType ); break; case FLOAT : type = SimpleParameterizedType.create( FloatForeignKeyField.class, entityType, databaseType, fkType ); break; case DOUBLE : type = SimpleParameterizedType.create( DoubleForeignKeyField.class, entityType, databaseType, fkType ); break; case CHAR : type = SimpleParameterizedType.create( CharForeignKeyField.class, entityType, databaseType, fkType ); break; case ENUM : type = SimpleParameterizedType.create( EnumForeignKeyField.class, entityType, databaseType, javaType, fkType ); break; case BOOLEAN : throw new UnsupportedOperationException( "Boolean foreign key fields are not supported." ); case COMPARABLE : type = SimpleParameterizedType.create( ComparableForeignKeyField.class, entityType, databaseType, javaType, fkType ); break; case REFERENCE : throw new UnsupportedOperationException( "Foreign key types that are not either primitive " + "or comparable are not supported." ); default : throw new UnsupportedOperationException( "Unknown enum constant '" + category + "'." ); } return new ForeignKeyUtil.ReferenceFieldType(type); // If it is not a foreign key }).orElseGet(() -> { final Type type; switch (category) { case STRING : type = SimpleParameterizedType.create( StringField.class, entityType, databaseType ); break; case BYTE : type = SimpleParameterizedType.create( ByteField.class, entityType, databaseType ); break; case SHORT : type = SimpleParameterizedType.create( ShortField.class, entityType, databaseType ); break; case INT : type = SimpleParameterizedType.create( IntField.class, entityType, databaseType ); break; case LONG : type = SimpleParameterizedType.create( LongField.class, entityType, databaseType ); break; case FLOAT : type = SimpleParameterizedType.create( FloatField.class, entityType, databaseType ); break; case DOUBLE : type = SimpleParameterizedType.create( DoubleField.class, entityType, databaseType ); break; case CHAR : type = SimpleParameterizedType.create( CharField.class, entityType, databaseType ); break; case BOOLEAN : type = SimpleParameterizedType.create( BooleanField.class, entityType, databaseType ); break; case ENUM : type = SimpleParameterizedType.create( EnumField.class, entityType, databaseType, javaType ); break; case COMPARABLE : type = SimpleParameterizedType.create( ComparableField.class, entityType, databaseType, javaType ); break; case REFERENCE : type = SimpleParameterizedType.create( ReferenceField.class, entityType, databaseType, javaType ); break; default : throw new UnsupportedOperationException( "Unknown enum constant '" + category + "'." ); } return new ForeignKeyUtil.ReferenceFieldType(type); });
328
1,529
1,857
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/lifecycle/ApplicationImplTranslator.java
ApplicationImplTranslator
getJavadocRepresentText
class ApplicationImplTranslator extends AbstractJavaClassTranslator<Project, Class> { public ApplicationImplTranslator(Injector injector, Project project) { super(injector, project, Class::of); } @Override protected String getClassOrInterfaceName() { return getSupport().typeName(getSupport().projectOrThrow()) + "ApplicationImpl"; } @Override protected Class makeCodeGenModel(File file) { return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((clazz, project) -> clazz.public_().final_() .setSupertype(generatedImplType()) .add(applicationType()) ).build(); } @Override protected String getJavadocRepresentText() {<FILL_FUNCTION_BODY>} private Type applicationType() { return SimpleType.create( getSupport().basePackageName() + "." + getSupport().typeName(getSupport().projectOrThrow()) + "Application" ); } private Type generatedImplType() { return SimpleType.create( getSupport().basePackageName() + ".generated.Generated" + getSupport().typeName(getSupport().projectOrThrow()) + "ApplicationImpl" ); } }
return "The default {@link " + Speedment.class.getName() + "} implementation class for the {@link " + Project.class.getName() + "} named " + getSupport().projectOrThrow().getId() + ".";
331
60
391
<methods>public com.speedment.common.codegen.model.Constructor copyConstructor(java.lang.reflect.Type, com.speedment.generator.translator.AbstractJavaClassTranslator.CopyConstructorMode) ,public com.speedment.common.codegen.model.Constructor emptyConstructor() ,public com.speedment.common.codegen.model.Field fieldFor(com.speedment.runtime.config.Column) ,public com.speedment.common.codegen.model.File get() ,public com.speedment.common.codegen.Generator getCodeGenerator() ,public final com.speedment.runtime.config.Project getDocument() ,public final TranslatorSupport<com.speedment.runtime.config.Project> getSupport() ,public boolean isInGeneratedPackage() ,public Stream<BiConsumer<com.speedment.common.codegen.model.File,Builder<com.speedment.common.codegen.model.Class>>> listeners() ,public void onMake(BiConsumer<com.speedment.common.codegen.model.File,Builder<com.speedment.common.codegen.model.Class>>) <variables>protected static final java.lang.String FINDER_METHOD_PREFIX,protected static final java.lang.String GETTER_METHOD_PREFIX,private static final java.lang.String JAVADOC_MESSAGE,protected static final java.lang.String SETTER_METHOD_PREFIX,private final non-sealed com.speedment.runtime.config.Project document,private final non-sealed com.speedment.common.codegen.Generator generator,private final non-sealed com.speedment.runtime.core.component.InfoComponent infoComponent,private final non-sealed com.speedment.common.injector.Injector injector,private final non-sealed List<BiConsumer<com.speedment.common.codegen.model.File,Builder<com.speedment.common.codegen.model.Class>>> listeners,private final non-sealed Function<java.lang.String,com.speedment.common.codegen.model.Class> mainModelConstructor,private final non-sealed com.speedment.runtime.typemapper.TypeMapperComponent typeMappers
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/manager/GeneratedManagerImplTranslator.java
GeneratedManagerImplTranslator
makeCodeGenModel
class GeneratedManagerImplTranslator extends AbstractEntityAndManagerTranslator<Class> { private static final String FIELDS_METHOD = "fields"; private static final String PRIMARY_KEYS_FIELDS_METHOD = "primaryKeyFields"; public GeneratedManagerImplTranslator(Injector injector, Table table) { super(injector, table, Class::of); } @Override protected Class makeCodeGenModel(File file) {<FILL_FUNCTION_BODY>} @Override protected String getJavadocRepresentText() { return "The generated base implementation for the manager of every {@link " + getSupport().entityType().getTypeName() + "} entity."; } @Override protected String getClassOrInterfaceName() { return getSupport().generatedManagerImplName(); } @Override public boolean isInGeneratedPackage() { return true; } }
return newBuilder(file, getSupport().generatedManagerImplName()) //////////////////////////////////////////////////////////////////// // The table specific methods. // //////////////////////////////////////////////////////////////////// .forEveryTable((clazz, table) -> { file.add(Import.of(getSupport().managerType())); file.add(Import.of(getSupport().entityImplType())); clazz .public_() .abstract_() .setSupertype(SimpleParameterizedType.create( table.isView() ? AbstractViewManager.class : AbstractManager.class, getSupport().entityType() )) .add(getSupport().generatedManagerType()) .add(Field.of("tableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())).private_().final_()) .add(Constructor.of().protected_() .add("this.tableIdentifier = " + TableIdentifier.class.getSimpleName() + ".of(" + Stream.of(getSupport().dbmsOrThrow().getId(), getSupport().schemaOrThrow().getId(), getSupport().tableOrThrow().getId()) .map(s -> "\"" + s + "\"").collect(joining(", ")) + ");") ) .add(Method.of("create", SimpleParameterizedType.create(getSupport().entityType())) .public_().add(OVERRIDE) .add("return new " + getSupport().entityImplName() + "();") ) .add(Method.of("getTableIdentifier", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType())) .public_().add(OVERRIDE) .add("return tableIdentifier;") ) .add( Method.of(FIELDS_METHOD, DefaultType.stream( SimpleParameterizedType.create( com.speedment.runtime.field.Field.class, getSupport().entityType() ) ) ) .public_().add(OVERRIDE) .add("return " + getSupport().managerName() + ".FIELDS.stream();") ) .add(generateFields(getSupport(), file, PRIMARY_KEYS_FIELDS_METHOD, () -> table.primaryKeyColumns() .sorted(comparing(PrimaryKeyColumn::getOrdinalPosition)) .filter(HasEnabled::test) .map(HasColumn::findColumn) .filter(Optional::isPresent) .map(Optional::get) )); }) .build();
239
638
877
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/manager/GeneratedManagerTranslator.java
GeneratedManagerTranslator
makeCodeGenModel
class GeneratedManagerTranslator extends AbstractEntityAndManagerTranslator<Interface> { public GeneratedManagerTranslator(Injector injector, Table table) { super(injector, table, Interface::of); } @Override protected Interface makeCodeGenModel(File file) {<FILL_FUNCTION_BODY>} @Override protected String getJavadocRepresentText() { return "The generated base interface for the manager of every {@link " + getSupport().entityType().getTypeName() + "} entity."; } @Override protected String getClassOrInterfaceName() { return getSupport().generatedManagerName(); } @Override public boolean isInGeneratedPackage() { return true; } }
return newBuilder(file, getSupport().generatedManagerName()) .forEveryTable((intf, table) -> { file.add(Import.of(getSupport().entityType())); file.add(Import.of(Collections.class).setStaticMember("unmodifiableList").static_()); file.add(Import.of(Arrays.class).setStaticMember("asList").static_()); intf.public_() .add(SimpleParameterizedType.create(Manager.class, getSupport().entityType())) .add( Field.of( "IDENTIFIER", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType()) ).set(Value.ofInvocation(TableIdentifier.class, "of", Stream.<HasAlias>of( table.getParentOrThrow().getParentOrThrow(), table.getParentOrThrow(), table ).map(HasName::getName) .map(Value::ofText) .toArray(Value[]::new) )) ) .add(Field.of("FIELDS", list(SimpleParameterizedType.create( com.speedment.runtime.field.Field.class, getSupport().entityType()) )).set(Value.ofReference("unmodifiableList(asList(" + Formatting.nl() + Formatting.indent( table.columns() .sorted(comparing(Column::getOrdinalPosition)) .filter(HasEnabled::isEnabled) .map(Column::getJavaName) .map(getSupport().namer()::javaStaticFieldName) .map(field -> getSupport().typeName() + "." + field) .collect(joining("," + Formatting.nl())) ) + Formatting.nl() + "))"))) .add(Method.of("getEntityClass", classOf(getSupport().entityType())) .default_().add(OVERRIDE) .add("return " + getSupport().entityName() + ".class;") ); }).build();
198
514
712
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/manager/SqlAdapterTranslator.java
SqlAdapterTranslator
makeCodeGenModel
class SqlAdapterTranslator extends AbstractEntityAndManagerTranslator<Class> { public SqlAdapterTranslator(Injector injector, Table table) { super(injector, table, Class::of); } @Override protected Class makeCodeGenModel(File file) {<FILL_FUNCTION_BODY>} @Override protected String getJavadocRepresentText() { return "The SqlAdapter for every {@link " + getSupport().entityType().getTypeName() + "} entity."; } @Override protected String getClassOrInterfaceName() { return getSupport().sqlAdapterName(); } }
return newBuilder(file, getClassOrInterfaceName()) .forEveryProject((intf, project) -> intf.public_() .setSupertype(getSupport().generatedSqlAdapterType()) ) .build();
170
63
233
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-standard/src/main/java/com/speedment/generator/standard/util/FkHolder.java
FkHolder
foreignKeyWasNullException
class FkHolder { private final CodeGenerationComponent codeGenerationComponent; private final ForeignKey fk; private final ForeignKeyColumn fkc; private final Column column; private final Table table; private final Column foreignColumn; private final Table foreignTable; public FkHolder(Injector injector, ForeignKey fk) { requireNonNull(injector); requireNonNull(fk); this.codeGenerationComponent = injector.getOrThrow(CodeGenerationComponent.class); this.fk = fk; this.fkc = fk.foreignKeyColumns().findFirst().orElseThrow(this::noEnabledForeignKeyException); this.column = fkc.findColumnOrThrow(); this.table = ancestor(column, Table.class).orElseThrow(NoSuchElementException::new); this.foreignColumn = fkc.findForeignColumn().orElseThrow(this::foreignKeyWasNullException); this.foreignTable = fkc.findForeignTable().orElseThrow(this::foreignKeyWasNullException); } public Column getColumn() { return column; } public Table getTable() { return table; } public Column getForeignColumn() { return foreignColumn; } public Table getForeignTable() { return foreignTable; } public JavaClassTranslator<Table, Interface> getEmt() { @SuppressWarnings("unchecked") final JavaClassTranslator<Table, Interface> translator = (JavaClassTranslator<Table, Interface>) codeGenerationComponent.findTranslator(getTable(), StandardTranslatorKey.MANAGER); return translator; } public JavaClassTranslator<Table, Interface> getForeignEmt() { @SuppressWarnings("unchecked") final JavaClassTranslator<Table, Interface> translator = (JavaClassTranslator<Table, Interface>) codeGenerationComponent.findTranslator(getForeignTable(), StandardTranslatorKey.MANAGER); return translator; } private IllegalStateException noEnabledForeignKeyException() { return new IllegalStateException( "FK " + fk.getId() + " does not have an enabled ForeignKeyColumn" ); } private SpeedmentException foreignKeyWasNullException() {<FILL_FUNCTION_BODY>} }
return new SpeedmentException( "Could not find referenced foreign column '" + fkc.getForeignColumnName() + "' in table '" + fkc.getForeignTableName() + "'." );
638
58
696
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-translator/src/main/java/com/speedment/generator/translator/AbstractEntityAndManagerTranslator.java
AbstractEntityAndManagerTranslator
typeOfPK
class AbstractEntityAndManagerTranslator<T extends ClassOrInterface<T>> extends AbstractJavaClassTranslator<Table, T> { protected AbstractEntityAndManagerTranslator( final Injector injector, final Table table, final Function<String, T> modelConstructor ) { super(injector, table, modelConstructor); } protected Type typeOfPK() {<FILL_FUNCTION_BODY>} private Stream<Column> columnsFromPks() { return primaryKeyColumns().map(pk -> { try { return pk.findColumnOrThrow(); } catch (final NoSuchElementException ex) { throw new SpeedmentTranslatorException( "Could not find any column belonging to primary key '" + pk.getId() + "'.", ex ); } }); } }
final long pks = primaryKeyColumns().count(); if (pks == 0) { return DefaultType.list(DefaultType.WILDCARD); } final Column firstColumn = columnsFromPks() .findFirst().orElseThrow(() -> new SpeedmentTranslatorException( "Table '" + table().get().getId() + "' did not contain any primary key columns." )); Type firstType = typeMappers().get(firstColumn).getJavaType(firstColumn); if (DefaultType.isPrimitive(firstType)) { firstType = DefaultType.wrapperFor(firstType); } if (pks == 1) { return firstType; } else if (columnsFromPks() .map(c -> typeMappers().get(c).getJavaType(c)) .allMatch(firstType::equals)) { return DefaultType.list(firstType); } else { return DefaultType.list(DefaultType.WILDCARD); }
217
265
482
<methods>public com.speedment.common.codegen.model.Constructor copyConstructor(java.lang.reflect.Type, com.speedment.generator.translator.AbstractJavaClassTranslator.CopyConstructorMode) ,public com.speedment.common.codegen.model.Constructor emptyConstructor() ,public com.speedment.common.codegen.model.Field fieldFor(com.speedment.runtime.config.Column) ,public com.speedment.common.codegen.model.File get() ,public com.speedment.common.codegen.Generator getCodeGenerator() ,public final com.speedment.runtime.config.Table getDocument() ,public final TranslatorSupport<com.speedment.runtime.config.Table> getSupport() ,public boolean isInGeneratedPackage() ,public Stream<BiConsumer<com.speedment.common.codegen.model.File,Builder<T>>> listeners() ,public void onMake(BiConsumer<com.speedment.common.codegen.model.File,Builder<T>>) <variables>protected static final java.lang.String FINDER_METHOD_PREFIX,protected static final java.lang.String GETTER_METHOD_PREFIX,private static final java.lang.String JAVADOC_MESSAGE,protected static final java.lang.String SETTER_METHOD_PREFIX,private final non-sealed com.speedment.runtime.config.Table document,private final non-sealed com.speedment.common.codegen.Generator generator,private final non-sealed com.speedment.runtime.core.component.InfoComponent infoComponent,private final non-sealed com.speedment.common.injector.Injector injector,private final non-sealed List<BiConsumer<com.speedment.common.codegen.model.File,Builder<T>>> listeners,private final non-sealed Function<java.lang.String,T> mainModelConstructor,private final non-sealed com.speedment.runtime.typemapper.TypeMapperComponent typeMappers
speedment_speedment
speedment/generator-parent/generator-translator/src/main/java/com/speedment/generator/translator/internal/SimpleTranslator.java
SimpleTranslator
get
class SimpleTranslator <DOC extends Document & HasName & HasMainInterface, T extends ClassOrInterface<T>> implements JavaClassTranslator<DOC, T> { private final Injector injector; private final GeneratorFunction<DOC, T> creator; private final DOC document; private final boolean generated; public SimpleTranslator( Injector injector, DOC document, GeneratorFunction<DOC, T> creator, boolean generated) { this.creator = requireNonNull(creator); this.document = requireNonNull(document); this.injector = requireNonNull(injector); this.generated = generated; } @Override public File get() {<FILL_FUNCTION_BODY>} @Override public TranslatorSupport<DOC> getSupport() { return new TranslatorSupport<>(injector, document); } @Override public DOC getDocument() { return document; } @Override public boolean isInGeneratedPackage() { return generated; } @Override public Generator getCodeGenerator() { return Generator.forJava(); } @Override public void onMake(BiConsumer<File, Builder<T>> action) { // This implementation doesn't use listeners. } @Override public Stream<BiConsumer<File, Builder<T>>> listeners() { return Stream.empty(); } }
final T generatedClass = creator.generate(document); final File file = File.of(getSupport().baseDirectoryName() + "/" + (isInGeneratedPackage() ? "generated/" : "") + generatedClass.getName() + ".java" ); file.add(generatedClass); file.call(new AutoImports(getCodeGenerator().getDependencyMgr())); file.call(new AlignTabs<>()); return file;
391
116
507
<no_super_class>
speedment_speedment
speedment/generator-parent/generator-translator/src/main/java/com/speedment/generator/translator/internal/component/CodeGenerationComponentImpl.java
TranslatorSettings
createDecorated
class TranslatorSettings<DOC extends HasName & HasMainInterface, T extends ClassOrInterface<T>> { private final String key; private final List<TranslatorDecorator<DOC, T>> decorators; private TranslatorConstructor<DOC, T> constructor; public TranslatorSettings(String key) { this.key = requireNonNull(key); this.decorators = new CopyOnWriteArrayList<>(); } public String key() { return key; } public TranslatorConstructor<DOC, T> getConstructor() { return constructor; } public void setConstructor(TranslatorConstructor<DOC, T> constructor) { this.constructor = constructor; } public List<TranslatorDecorator<DOC, T>> decorators() { return decorators; } public JavaClassTranslator<DOC, T> createDecorated(Injector injector, DOC document) {<FILL_FUNCTION_BODY>} }
@SuppressWarnings("unchecked") final JavaClassTranslator<DOC, T> translator = (JavaClassTranslator<DOC, T>) getConstructor().apply(injector, document); injector.inject(translator); decorators.stream() .map(injector::inject) .forEachOrdered(dec -> dec.apply(translator)); return translator;
263
117
380
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/EnumGeneratorComponent.java
EnumGeneratorComponent
installDecorators
class EnumGeneratorComponent { static InjectBundle include() { return InjectBundle.of( StandardTypeMapperComponent.class, StandardCodeGenerationComponent.class, DelegatePropertyEditorComponent.class ); } @ExecuteBefore(RESOLVED) public void installDecorators( final Injector injector, @WithState(INITIALIZED) final TypeMapperComponent typeMappers, @WithState(INITIALIZED) final CodeGenerationComponent codeGen, @WithState(RESOLVED) final PropertyEditorComponent editors ) {<FILL_FUNCTION_BODY>} }
typeMappers.install(String.class, StringToEnumTypeMapper::new); typeMappers.install(Integer.class, IntegerToEnumTypeMapper::new); codeGen.add( Table.class, StandardTranslatorKey.GENERATED_ENTITY, new GeneratedEntityDecorator(injector) ); editors.install( HasEnumConstantsProperty.class, HasEnumConstantsUtil.ENUM_CONSTANTS, CommaSeparatedStringEditor::new );
166
135
301
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/IntegerToEnumTypeMapper.java
IntegerToEnumTypeMapper
toDatabaseType
class IntegerToEnumTypeMapper<T extends Enum<T>> implements TypeMapper<Integer, T> { private final AtomicReference<T[]> cachedConstants; @Inject public Injector injector; public IntegerToEnumTypeMapper() { cachedConstants = new AtomicReference<>(); } @Override public String getLabel() { return "Integer to Enum"; } @Override public boolean isToolApplicable() { return false; } @Override public Type getJavaType(Column column) { requireNonNull(injector, IntegerToEnumTypeMapper.class.getSimpleName() + ".getJavaType(Column) is not available if instantiated " + "without injector." ); return new GeneratedEnumType( EnumGeneratorUtil.enumNameOf(column, injector), EnumGeneratorUtil.enumConstantsOf(column) ); } @Override public TypeMapper.Category getJavaTypeCategory(Column column) { return Category.ENUM; } @Override public T toJavaType(Column column, Class<?> entityType, Integer value) { if (value == null) { return null; } else { if (cachedConstants.get() == null) { synchronized (cachedConstants) { if (cachedConstants.get() == null) { cachedConstants.set(constants(column, entityType)); } } } return cachedConstants.get()[value]; } } private T[] constants(Column column, Class<?> entityType) { final Class<?> enumClass = classesIn(entityType) // Include only enum subclasses .filter(Enum.class::isAssignableFrom) // Include only enums with the correct name .filter(c -> c.getSimpleName().equalsIgnoreCase( column.getJavaName().replace("_", "") )) // Return it as the enumClass or throw an exception. .findAny() .orElseThrow(() -> new NoSuchElementException("Unable to find Enum class because entity " + entityType.getSimpleName() + " has no enum value for column " + column.getId())); final Method values; try { values = enumClass.getMethod("values"); } catch (final NoSuchMethodException ex) { throw new IllegalArgumentException("Could not find 'values()'-method in enum class '" + enumClass.getName() + "'.", ex); } try { @SuppressWarnings("unchecked") final T[] result = (T[]) values.invoke(null); return result; } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException("Error executing 'values()' in generated enum class '" + enumClass.getName() + "'.", ex); } } @Override public Integer toDatabaseType(T constant) {<FILL_FUNCTION_BODY>} }
if (constant == null) { return null; } else { final Class<?> enumClass = constant.getClass(); final Method ordinal; try { ordinal = enumClass.getMethod("ordinal"); } catch (final NoSuchMethodException ex) { throw new IllegalArgumentException("Could not find generated 'ordinal()'-method in enum class '" + constant.getClass().getName() + "'.", ex); } try { @SuppressWarnings("unchecked") final Integer result = (Integer) ordinal.invoke(constant); return result; } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException("Error executing 'ordinal()' in generated enum class '" + constant.getClass().getName() + "'.", ex); } }
769
207
976
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/StringToEnumTypeMapper.java
StringToEnumTypeMapper
toJavaType
class StringToEnumTypeMapper<T extends Enum<T>> implements TypeMapper<String, T> { private final AtomicReference<Class<?>> cachedEnum; @Inject public Injector injector; public StringToEnumTypeMapper() { cachedEnum = new AtomicReference<>(); } @Override public String getLabel() { return "String to Enum"; } @Override public Type getJavaType(Column column) { requireNonNull(injector, StringToEnumTypeMapper.class.getSimpleName() + ".getJavaType(Column) is not available if instantiated without injector." ); return new GeneratedEnumType( EnumGeneratorUtil.enumNameOf(column, injector), EnumGeneratorUtil.enumConstantsOf(column) ); } @Override public Category getJavaTypeCategory(Column column) { return Category.ENUM; } @Override public T toJavaType(Column column, Class<?> entityType, String value) {<FILL_FUNCTION_BODY>} private Class<?> enumClass(Column column, Class<?> entityType) { return EnumGeneratorUtil.classesIn(entityType) // Include only enum subclasses .filter(Enum.class::isAssignableFrom) // Include only enums with the correct name .filter(c -> c.getSimpleName().equalsIgnoreCase( column.getJavaName().replace("_", "") )) // Include only enums with a method called fromDatabase() // that takes the right parameters .filter(c -> Stream.of(c.getMethods()) .filter(m -> m.getName().equals(FROM_DATABASE_METHOD)) .anyMatch(m -> { final Class<?>[] params = m.getParameterTypes(); return params.length == 1 && params[0] == column.findDatabaseType(); }) ) // Return it as the enumClass or throw an exception. .findAny() .orElseThrow(() -> new NoSuchElementException("No enum class with a '" + FROM_DATABASE_METHOD + "' method found for " + column.getId() + " entityType " + entityType)); } @Override public String toDatabaseType(T constant) { if (constant == null) { return null; } else { final Class<?> enumClass = constant.getClass(); final Method toDatabase; try { toDatabase = enumClass.getMethod(TO_DATABASE_METHOD); } catch (final NoSuchMethodException ex) { throw new IllegalArgumentException( "Could not find generated '" + TO_DATABASE_METHOD + "'-method in enum class '" + constant.getClass().getName() + "'.", ex ); } try { @SuppressWarnings("unchecked") final String result = (String) toDatabase.invoke(constant); return result; } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException("Error executing '" + TO_DATABASE_METHOD + "' in generated enum class '" + constant.getClass().getName() + "'.", ex); } } } }
if (value == null) { return null; } else { if (cachedEnum.get() == null) { synchronized (cachedEnum) { if (cachedEnum.get() == null) { cachedEnum.set(enumClass(column, entityType)); } } } final Class<?> enumClass = cachedEnum.get(); final Method fromDatabase; try { fromDatabase = enumClass.getMethod(FROM_DATABASE_METHOD, String.class); } catch (final NoSuchMethodException ex) { // This cannot happen because we ensure that this method actually do exist above. throw new IllegalArgumentException("Could not find generated '" + FROM_DATABASE_METHOD + "'-method in enum class '" + enumClass.getName() + "'.", ex); } try { @SuppressWarnings("unchecked") final T result = (T) fromDatabase.invoke(null, value); return result; } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException( "Error executing '" + FROM_DATABASE_METHOD + "' in generated enum class '" + enumClass.getName() + "'.", ex ); } }
843
323
1,166
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/internal/EnumGeneratorUtil.java
EnumGeneratorUtil
classesIn
class EnumGeneratorUtil { private EnumGeneratorUtil() {} /** * Returns the full name of the enum that will be generated for * the specified column. * * @param column the column that should be implemented as an enum * @param injector the injector used in the platform * @return full name for the enum */ public static String enumNameOf(Column column, Injector injector) { final TranslatorSupport<Table> support = new TranslatorSupport<>(injector, column.getParentOrThrow()); final String shortName = support.namer().javaTypeName(column.getJavaName()); return support.generatedEntityType().getTypeName() + "." + shortName; } /** * Returns a list of all the enum constants in a particular column. * The list is created each time this method is called and is therefore * safe to edit without affecting the column. * <p> * If no enum constants was specified in the column, an exception is * thrown. * * @param column the column to retrieve the constants from * @return list of the constants */ public static List<String> enumConstantsOf(Column column) { final Optional<String> ec = column.getEnumConstants(); final String[] enumConstants = ec .orElseThrow(() -> new NoSuchElementException( "Column '" + column.getId() + "' in table '" + column.getParentOrThrow().getId() + "' was marked as an enum but no enum constants was specified." )) .split(","); return Stream.of(enumConstants) .sorted() .collect(toList()); } /** * Returns a stream of classes located inside the specified class. If the * specified class is {@code null}, then an empty stream is returned. * * @param entityClass the class to look in (can be {code null}) * @return stream of classes */ public static Stream<Class<?>> classesIn(Class<?> entityClass) {<FILL_FUNCTION_BODY>} }
if (entityClass == null) { return Stream.empty(); } else { return Stream.concat(Stream.concat(Stream.of(entityClass.getDeclaredClasses()), Stream.of(entityClass.getSuperclass()) .flatMap(EnumGeneratorUtil::classesIn) ), Stream.of(entityClass.getInterfaces()) .flatMap(EnumGeneratorUtil::classesIn) ); }
540
107
647
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/internal/GeneratedEnumType.java
GeneratedEnumType
equals
class GeneratedEnumType implements Type { private final String typeName; private final List<String> constants; public GeneratedEnumType(String typeName, List<String> constants) { this.typeName = requireNonNull(typeName); this.constants = unmodifiableList(new ArrayList<>(constants)); } public List<String> getEnumConstants() { return constants; } @Override public String getTypeName() { return typeName; } @Override public boolean equals(Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { int result = getTypeName().hashCode(); result = 31 * result + constants.hashCode(); return result; } }
if (this == o) return true; if (!(o instanceof Type)) { return false; } if (o instanceof GeneratedEnumType) { final GeneratedEnumType that = (GeneratedEnumType) o; return typeName.equals(that.typeName) && constants.equals(that.constants); } else { return typeName.equals(((Type) o).getTypeName()); }
205
111
316
<no_super_class>
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/internal/ui/EnumCell.java
MyStringConverter
fromString
class MyStringConverter extends StringConverter<String> { @Override public String toString(String value) { return (value != null) ? value : ""; } @Override public String fromString(String value) {<FILL_FUNCTION_BODY>} }
// Avoid false positives (ie showing an error that we match ourselves) if (value.equalsIgnoreCase(labelString)) { return value; } else if (value.isEmpty()) { LOGGER.info("An enum field cannot be empty. Please remove the field instead."); return labelString; } // Make sure this is not a duplicate entry final AtomicBoolean duplicate = new AtomicBoolean(false); strings.stream() .filter(elem -> elem.equalsIgnoreCase(value)) .forEach(elem -> duplicate.set(true)); if (duplicate.get()){ LOGGER.info("Enum cannot contain the same constant twice"); return labelString; // Make sure this entry contains only legal characters } else if ( !value.matches("([\\w\\-\\_\\ ]+)")) { LOGGER.info("Enum should only contain letters, number, underscore and/or dashes"); return labelString; // Warn if it contains a space } else if (value.contains(" ")) { LOGGER.warn("Enum spaces will be converted to underscores in Java"); return value; } else { return value; }
75
301
376
<methods>public void <init>() ,public void <init>(StringConverter<java.lang.String>) ,public void cancelEdit() ,public final ObjectProperty<StringConverter<java.lang.String>> converterProperty() ,public static Callback<ListView<java.lang.String>,ListCell<java.lang.String>> forListView() ,public static Callback<ListView<T>,ListCell<T>> forListView(StringConverter<T>) ,public final StringConverter<java.lang.String> getConverter() ,public final void setConverter(StringConverter<java.lang.String>) ,public void startEdit() ,public void updateItem(java.lang.String, boolean) <variables>private ObjectProperty<StringConverter<java.lang.String>> converter,private javafx.scene.control.TextField textField
speedment_speedment
speedment/plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/internal/ui/SingleColumnManager.java
SingleColumnManager
toString
class SingleColumnManager implements Manager<String> { private final StreamSupplierComponent streamSupplierComponent; private final StringField<String, String> field; private final TableIdentifier<String> tableId; SingleColumnManager( final StreamSupplierComponent streamSupplierComponent, @Config(name="temp.dbms", value="") final String dbms, @Config(name="temp.schema", value="") final String schema, @Config(name="temp.table", value="") final String table, @Config(name="temp.column", value="") final String column ) { this.streamSupplierComponent = requireNonNull(streamSupplierComponent); requireNonNull(dbms); requireNonNull(schema); requireNonNull(table); requireNonNull(column); this.tableId = TableIdentifier.of(dbms, schema, table); this.field = StringField.create( new TempColumnIdentifier(dbms, schema, table, column), e -> e, (e, s) -> {}, TypeMapper.identity(), false ); } @ExecuteBefore(State.INITIALIZED) public void configureManagerComponent(@WithState(State.INITIALIZED) ManagerComponent managerComponent) { managerComponent.put(this); } @Override public TableIdentifier<String> getTableIdentifier() { return tableId; } @Override public Class<String> getEntityClass() { return String.class; } @Override public Stream<Field<String>> fields() { return SingletonStream.of(field); } @Override public Stream<Field<String>> primaryKeyFields() { return SingletonStream.of(field); } @Override public Stream<String> stream() { return streamSupplierComponent.stream( getTableIdentifier(), ParallelStrategy.computeIntensityDefault() ); } @Override public String create() { throw newUnsupportedOperationExceptionReadOnly(); } @Override public final String persist(String entity) { throw newUnsupportedOperationExceptionReadOnly(); } @Override public Persister<String> persister() { throw newUnsupportedOperationExceptionReadOnly(); } @Override public Persister<String> persister(HasLabelSet<String> fields) { throw newUnsupportedOperationExceptionReadOnly(); } @Override public final String update(String entity) { throw newUnsupportedOperationExceptionReadOnly(); } @Override public Updater<String> updater() { throw newUnsupportedOperationExceptionReadOnly(); } @Override public Updater<String> updater(HasLabelSet<String> fields) { throw newUnsupportedOperationExceptionReadOnly(); } @Override public final String remove(String entity) { throw newUnsupportedOperationExceptionReadOnly(); } @Override public Remover<String> remover() { throw newUnsupportedOperationExceptionReadOnly(); } @Override public String toString() {<FILL_FUNCTION_BODY>} private static UnsupportedOperationException newUnsupportedOperationExceptionReadOnly() { return new UnsupportedOperationException("This manager is read-only."); } }
return getClass().getSimpleName() + "{tableId: " + tableId.toString() + "}";
855
34
889
<no_super_class>
speedment_speedment
speedment/plugin-parent/json-stream/src/main/java/com/speedment/plugins/json/internal/JsonComponentImpl.java
JsonComponentImpl
of
class JsonComponentImpl implements JsonComponent { private final ProjectComponent projectComponent; public JsonComponentImpl(ProjectComponent projectComponent) { this.projectComponent = requireNonNull(projectComponent); } @Override public <ENTITY> JsonEncoder<ENTITY> noneOf(Manager<ENTITY> manager) { return new JsonEncoderImpl<>(projectComponent.getProject(), manager); } @Override public <ENTITY> JsonEncoder<ENTITY> allOf(Manager<ENTITY> manager) { requireNonNull(manager); final JsonEncoder<ENTITY> formatter = noneOf(manager); manager.fields() .forEachOrdered(f -> formatter.put(jsonField(projectComponent.getProject(), f.identifier()), f.getter()::apply ) ); return formatter; } @SafeVarargs @SuppressWarnings("varargs") @Override public final <ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY>... fields) {<FILL_FUNCTION_BODY>} }
requireNonNull(manager); requireNonNullElements(fields); final JsonEncoder<ENTITY> formatter = noneOf(manager); final Set<String> fieldNames = Stream.of(fields) .map(Field::identifier) .map(ColumnIdentifier::getColumnId) .collect(toSet()); manager.fields() .filter(f -> fieldNames.contains(f.identifier().getColumnId())) .forEachOrdered(f -> formatter.put(jsonField(projectComponent.getProject(), f.identifier()), f.getter()::apply ) ); return formatter;
291
164
455
<no_super_class>
speedment_speedment
speedment/runtime-parent/runtime-application/src/main/java/com/speedment/runtime/application/RuntimeBundle.java
RuntimeBundle
injectables
class RuntimeBundle implements InjectBundle { @Override public Stream<Class<?>> injectables() {<FILL_FUNCTION_BODY>} }
return InjectBundle.of( DelegateInfoComponent.class, DelegateConnectionPoolComponent.class, DelegateDbmsHandlerComponent.class, DelegateEntityManager.class, DelegateManagerComponent.class, DelegatePasswordComponent.class, DelegateProjectComponent.class, DelegateResultSetMapperComponent.class, DelegateSqlStreamSupplierComponent.class, DelegateSqlPersistenceComponent.class, DelegateStatisticsReporterComponent.class, DelegateStatisticsReporterSchedulerComponent.class, DelegateSqlStreamOptimizerComponent.class, DelegateSqlStreamTerminatorComponent.class, DelegateTransactionComponent.class, DelegateDriverComponent.class, DefaultConnectionDecorator.class ) .injectables();
42
217
259
<no_super_class>
speedment_speedment
speedment/runtime-parent/runtime-compute/src/main/java/com/speedment/runtime/compute/internal/BinaryJoiningExpressionImpl.java
BinaryJoiningExpressionImpl
apply
class BinaryJoiningExpressionImpl<T> implements JoiningExpression<T> { private final CharSequence separator; private final CharSequence prefix; private final CharSequence suffix; private final ToString<T> first; private final ToString<T> second; public BinaryJoiningExpressionImpl( final CharSequence separator, final CharSequence prefix, final CharSequence suffix, final ToString<T> first, final ToString<T> second) { this.separator = requireNonNull(separator); this.prefix = requireNonNull(prefix); this.suffix = requireNonNull(suffix); this.first = requireNonNull(first); this.second = requireNonNull(second); } @Override public List<ToString<T>> expressions() { return Arrays.asList(first, second); } @Override public CharSequence prefix() { return prefix; } @Override public CharSequence suffix() { return suffix; } @Override public CharSequence separator() { return separator; } @Override public String apply(T object) {<FILL_FUNCTION_BODY>} }
final StringJoiner joiner = new StringJoiner(separator, prefix, suffix); joiner.add(first.apply(object)); joiner.add(second.apply(object)); return joiner.toString();
316
58
374
<no_super_class>
speedment_speedment
speedment/runtime-parent/runtime-compute/src/main/java/com/speedment/runtime/compute/internal/ToBooleanNullableImpl.java
ToBooleanNullableImpl
compare
class ToBooleanNullableImpl<T> implements NullableExpression<T, ToBoolean<T>>, ToBooleanNullable<T> { private final ToBoolean<T> original; private final Predicate<T> isNull; public ToBooleanNullableImpl(ToBoolean<T> original, Predicate<T> isNull) { this.original = requireNonNull(original); this.isNull = requireNonNull(isNull); } @Override public ToBoolean<T> inner() { return original; } @Override public Predicate<T> isNullPredicate() { return isNull; } @Override public Boolean apply(T t) { return isNull.test(t) ? null : original.applyAsBoolean(t); } @Override public boolean applyAsBoolean(T t) { return original.applyAsBoolean(t); } @Override public ToBoolean<T> orThrow() { return original; } @Override public ToBoolean<T> orElseGet(ToBoolean<T> getter) { return t -> isNull.test(t) ? getter.applyAsBoolean(t) : original.applyAsBoolean(t); } @Override public ToBoolean<T> orElse(Boolean value) { return t -> isNull.test(t) ? value : original.applyAsBoolean(t); } @Override public ToDoubleNullable<T> mapToDoubleIfPresent(BooleanToDoubleFunction mapper) { return t -> isNull.test(t) ? null : mapper.applyAsDouble(original.applyAsBoolean(t)); } @Override public ToBooleanNullable<T> mapIfPresent(BooleanUnaryOperator mapper) { return t -> isNull.test(t) ? null : mapper.applyAsBoolean(original.applyAsBoolean(t)); } @Override public long hash(T object) { if (isNull.test(object)) { return 2; } else { return original.applyAsBoolean(object) ? 1 : 0; } } @Override public int compare(T first, T second) {<FILL_FUNCTION_BODY>} @Override public boolean isNull(T object) { return isNull.test(object); } @Override public boolean isNotNull(T object) { return !isNull.test(object); } @Override public boolean equals(Object o) { if (this == o) return true; else if (!(o instanceof NullableExpression)) return false; final NullableExpression<?, ?> that = (NullableExpression<?, ?>) o; return Objects.equals(original, that.inner()) && Objects.equals(isNull, that.isNullPredicate()); } @Override public int hashCode() { return Objects.hash(original, isNull); } }
final boolean f = isNull(first); final boolean s = isNull(second); if (f && s) return 0; else if (f) return 1; else if (s) return -1; else return Boolean.compare( original.applyAsBoolean(first), original.applyAsBoolean(second) );
776
90
866
<no_super_class>