Skip to content

Commit

Permalink
Runtime: Remove generic type from Field
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Forslund committed Sep 28, 2016
1 parent 166f909 commit 1c9f01f
Show file tree
Hide file tree
Showing 181 changed files with 377 additions and 2,523 deletions.
Expand Up @@ -66,12 +66,9 @@
import java.util.Optional; import java.util.Optional;
import static com.speedment.common.codegen.internal.util.Formatting.block; import static com.speedment.common.codegen.internal.util.Formatting.block;
import static com.speedment.common.codegen.internal.util.Formatting.indent; import static com.speedment.common.codegen.internal.util.Formatting.indent;
import static com.speedment.common.codegen.internal.util.Formatting.tab;
import com.speedment.generator.util.Primitives;
import com.speedment.runtime.internal.util.document.DocumentDbUtil; import com.speedment.runtime.internal.util.document.DocumentDbUtil;
import com.speedment.runtime.manager.AbstractManager; import com.speedment.runtime.manager.AbstractManager;
import com.speedment.runtime.manager.JdbcManagerSupport; import com.speedment.runtime.manager.JdbcManagerSupport;
import com.speedment.runtime.manager.Manager;
import com.speedment.runtime.manager.ManagerSupport; import com.speedment.runtime.manager.ManagerSupport;
import com.speedment.runtime.field.method.BackwardFinder; import com.speedment.runtime.field.method.BackwardFinder;


Expand Down Expand Up @@ -135,8 +132,7 @@ protected Class makeCodeGenModel(File file) {
// Create corresponding streamer method // Create corresponding streamer method
clazz.add(Method.of(methodName, SimpleParameterizedType.create(BackwardFinder.class, clazz.add(Method.of(methodName, SimpleParameterizedType.create(BackwardFinder.class,
fu.getForeignEmt().getSupport().entityType(), fu.getForeignEmt().getSupport().entityType(),
fu.getEmt().getSupport().entityType(), fu.getEmt().getSupport().entityType()
Primitives.orWrapper(typeMappers.get(fu.getColumn()).getJavaType(fu.getColumn()))
)) ))
.public_().add(OVERRIDE) .public_().add(OVERRIDE)
.add("return " + .add("return " +
Expand Down
Expand Up @@ -45,9 +45,6 @@
import static com.speedment.generator.internal.util.ColumnUtil.usesOptional; import static com.speedment.generator.internal.util.ColumnUtil.usesOptional;
import com.speedment.common.injector.Injector; import com.speedment.common.injector.Injector;
import com.speedment.common.injector.annotation.Inject; import com.speedment.common.injector.annotation.Inject;
import com.speedment.generator.component.TypeMapperComponent;
import com.speedment.generator.util.Primitives;
import com.speedment.runtime.config.mapper.TypeMapper;
import com.speedment.runtime.manager.Manager; import com.speedment.runtime.manager.Manager;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import com.speedment.runtime.field.method.BackwardFinder; import com.speedment.runtime.field.method.BackwardFinder;
Expand All @@ -59,7 +56,6 @@
public final class GeneratedManagerTranslator extends AbstractEntityAndManagerTranslator<Interface> { public final class GeneratedManagerTranslator extends AbstractEntityAndManagerTranslator<Interface> {


private @Inject Injector injector; private @Inject Injector injector;
private @Inject TypeMapperComponent typeMappers;


public GeneratedManagerTranslator(Table table) { public GeneratedManagerTranslator(Table table) {
super(table, Interface::of); super(table, Interface::of);
Expand Down Expand Up @@ -121,11 +117,11 @@ protected Interface makeCodeGenModel(File file) {
/*** Create an additional method for producing a Streamer ***/ /*** Create an additional method for producing a Streamer ***/
intrf.add(Method.of(methodName, SimpleParameterizedType.create(BackwardFinder.class, intrf.add(Method.of(methodName, SimpleParameterizedType.create(BackwardFinder.class,
fu.getForeignEmt().getSupport().entityType(), fu.getForeignEmt().getSupport().entityType(),
fu.getEmt().getSupport().entityType(), fu.getEmt().getSupport().entityType()
Primitives.orWrapper(typeMappers.get(fu.getColumn()).getJavaType(fu.getColumn()))
)).set(Javadoc.of( )).set(Javadoc.of(
"Creates and returns a {@link Streamer}-operation that " + "Creates and returns a {@link " +
"will look up all the {@link " + BackwardFinder.class.getSimpleName() +
"}-operation that will look up all the {@link " +
fu.getForeignEmt().getSupport().entityType().getTypeName() + fu.getForeignEmt().getSupport().entityType().getTypeName() +
" " + " " +
EntityTranslatorSupport.pluralis(fu.getForeignTable(), fu.getForeignEmt().getSupport().namer()) + EntityTranslatorSupport.pluralis(fu.getForeignTable(), fu.getForeignEmt().getSupport().namer()) +
Expand Down
Expand Up @@ -51,8 +51,7 @@ public static Method generateFields(TranslatorSupport<Table> support, File file,
DefaultType.stream( DefaultType.stream(
SimpleParameterizedType.create( SimpleParameterizedType.create(
com.speedment.runtime.field.Field.class, com.speedment.runtime.field.Field.class,
support.entityType(), support.entityType()
DefaultType.WILDCARD
) )
) )
) )
Expand Down

This file was deleted.

Expand Up @@ -61,6 +61,6 @@ public interface JsonComponent {
* @return a new JsonEncoder with the specified fields added to the renderer * @return a new JsonEncoder with the specified fields added to the renderer
*/ */
@SuppressWarnings("varargs") // Using the array in a Stream.of() is safe @SuppressWarnings("varargs") // Using the array in a Stream.of() is safe
<ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY, ?>... fields); <ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY>... fields);


} }
Expand Up @@ -288,13 +288,12 @@ public interface JsonEncoder<ENTITY> {
* *
* @param <FK_ENTITY> the type of the foreign entity * @param <FK_ENTITY> the type of the foreign entity
* @param <FIELD> the type of the field itself * @param <FIELD> the type of the field itself
* @param <V> the type of the value wrapper
* *
* @param field the foreign key field * @param field the foreign key field
* @param encoder encoder for the foreign entity * @param encoder encoder for the foreign entity
* @return a reference to this encoder * @return a reference to this encoder
*/ */
<FK_ENTITY, V, FIELD extends Field<ENTITY, V> & HasFinder<ENTITY, FK_ENTITY, V>> <FK_ENTITY, FIELD extends Field<ENTITY> & HasFinder<ENTITY, FK_ENTITY>>
JsonEncoder<ENTITY> put(FIELD field, JsonEncoder<FK_ENTITY> encoder); JsonEncoder<ENTITY> put(FIELD field, JsonEncoder<FK_ENTITY> encoder);


/**************************************************************************/ /**************************************************************************/
Expand Down Expand Up @@ -379,7 +378,7 @@ <FK_ENTITY> JsonEncoder<ENTITY> putStreamer(
* @param field the field to remove * @param field the field to remove
* @return a reference to this encoder * @return a reference to this encoder
*/ */
JsonEncoder<ENTITY> remove(Field<ENTITY, ?> field); JsonEncoder<ENTITY> remove(Field<ENTITY> field);


/**************************************************************************/ /**************************************************************************/
/* Encode */ /* Encode */
Expand Down
Expand Up @@ -21,13 +21,10 @@
import com.speedment.plugins.json.JsonEncoder; import com.speedment.plugins.json.JsonEncoder;
import static com.speedment.plugins.json.internal.JsonUtil.jsonField; import static com.speedment.plugins.json.internal.JsonUtil.jsonField;
import com.speedment.runtime.component.ProjectComponent; import com.speedment.runtime.component.ProjectComponent;
import com.speedment.runtime.config.Project;
import com.speedment.runtime.config.identifier.FieldIdentifier; import com.speedment.runtime.config.identifier.FieldIdentifier;
import com.speedment.runtime.field.Field; import com.speedment.runtime.field.Field;
import static com.speedment.runtime.internal.util.document.DocumentDbUtil.referencedColumn;
import com.speedment.runtime.manager.Manager; import com.speedment.runtime.manager.Manager;
import static com.speedment.runtime.util.NullUtil.requireNonNullElements; import static com.speedment.runtime.util.NullUtil.requireNonNullElements;
import static com.speedment.runtime.util.NullUtil.requireNonNulls;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import java.util.Set; import java.util.Set;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
Expand Down Expand Up @@ -67,7 +64,7 @@ public <ENTITY> JsonEncoder<ENTITY> allOf(Manager<ENTITY> manager) {
} }


@Override @Override
public <ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY, ?>... fields) { public <ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY>... fields) {
requireNonNull(manager); requireNonNull(manager);
requireNonNullElements(fields); requireNonNullElements(fields);
final JsonEncoder<ENTITY> formatter = noneOf(manager); final JsonEncoder<ENTITY> formatter = noneOf(manager);
Expand Down
Expand Up @@ -165,7 +165,7 @@ public <D> JsonEncoder<ENTITY> putBoolean(BooleanField<ENTITY, D> field) {
return putHelper(field, BooleanField::getter, this::putBoolean); return putHelper(field, BooleanField::getter, this::putBoolean);
} }


private <V, F extends Field<ENTITY, V>, G extends Getter<ENTITY, V>> JsonEncoder<ENTITY> putHelper( private <F extends Field<ENTITY>, G extends Getter<ENTITY>> JsonEncoder<ENTITY> putHelper(
F field, Function<F, G> getter, BiFunction<String, G, JsonEncoder<ENTITY>> putter) { F field, Function<F, G> getter, BiFunction<String, G, JsonEncoder<ENTITY>> putter) {


requireNonNulls(field, getter, putter); requireNonNulls(field, getter, putter);
Expand Down Expand Up @@ -263,7 +263,7 @@ private JsonEncoder<ENTITY> putHelper(String label, Function<ENTITY, String> jso
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public <FK_ENTITY, V, FIELD extends Field<ENTITY, V> & HasFinder<ENTITY, FK_ENTITY, V>> public <FK_ENTITY, FIELD extends Field<ENTITY> & HasFinder<ENTITY, FK_ENTITY>>
JsonEncoder<ENTITY> put(FIELD field, JsonEncoder<FK_ENTITY> encoder) { JsonEncoder<ENTITY> put(FIELD field, JsonEncoder<FK_ENTITY> encoder) {
requireNonNulls(field, encoder); requireNonNulls(field, encoder);
final String columnName = jsonField(project, field.identifier()); final String columnName = jsonField(project, field.identifier());
Expand Down Expand Up @@ -350,7 +350,7 @@ public JsonEncoder<ENTITY> remove(String label) {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public JsonEncoder<ENTITY> remove(Field<ENTITY, ?> field) { public JsonEncoder<ENTITY> remove(Field<ENTITY> field) {
requireNonNull(field); requireNonNull(field);
getters.remove(jsonField(project, field.identifier())); getters.remove(jsonField(project, field.identifier()));
return this; return this;
Expand Down
Expand Up @@ -132,7 +132,7 @@ <ENTITY> void executeInsert(
Dbms dbms, Dbms dbms,
String sql, String sql,
List<?> values, List<?> values,
Collection<Field<ENTITY, ?>> generatedKeyFields, Collection<Field<ENTITY>> generatedKeyFields,
Consumer<List<Long>> generatedKeyConsumer Consumer<List<Long>> generatedKeyConsumer
) throws SQLException; ) throws SQLException;


Expand Down
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -31,7 +15,7 @@
* @see ReferenceField * @see ReferenceField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface BooleanField<ENTITY, D> extends Field<ENTITY, Boolean>, HasBooleanValue<ENTITY, D> { public interface BooleanField<ENTITY, D> extends Field<ENTITY>, HasBooleanValue<ENTITY, D> {




} }
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -34,7 +18,7 @@
* @see ReferenceForeignKeyField * @see ReferenceForeignKeyField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface BooleanForeignKeyField<ENTITY, D, FK_ENTITY> extends BooleanField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY, Boolean> { public interface BooleanForeignKeyField<ENTITY, D, FK_ENTITY> extends BooleanField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY> {




} }
18 changes: 1 addition & 17 deletions runtime/src/main/java/com/speedment/runtime/field/ByteField.java
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -32,7 +16,7 @@
* @see ReferenceField * @see ReferenceField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface ByteField<ENTITY, D> extends Field<ENTITY, Byte>, HasByteValue<ENTITY, D>, HasComparableOperators<ENTITY, Byte> { public interface ByteField<ENTITY, D> extends Field<ENTITY>, HasByteValue<ENTITY, D>, HasComparableOperators<ENTITY, Byte> {




} }
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -34,7 +18,7 @@
* @see ReferenceForeignKeyField * @see ReferenceForeignKeyField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface ByteForeignKeyField<ENTITY, D, FK_ENTITY> extends ByteField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY, Byte> { public interface ByteForeignKeyField<ENTITY, D, FK_ENTITY> extends ByteField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY> {




} }
18 changes: 1 addition & 17 deletions runtime/src/main/java/com/speedment/runtime/field/CharField.java
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -32,7 +16,7 @@
* @see ReferenceField * @see ReferenceField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface CharField<ENTITY, D> extends Field<ENTITY, Character>, HasCharValue<ENTITY, D>, HasComparableOperators<ENTITY, Character> { public interface CharField<ENTITY, D> extends Field<ENTITY>, HasCharValue<ENTITY, D>, HasComparableOperators<ENTITY, Character> {




} }
@@ -1,19 +1,3 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.field; package com.speedment.runtime.field;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
Expand All @@ -34,7 +18,7 @@
* @see ReferenceForeignKeyField * @see ReferenceForeignKeyField
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface CharForeignKeyField<ENTITY, D, FK_ENTITY> extends CharField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY, Character> { public interface CharForeignKeyField<ENTITY, D, FK_ENTITY> extends CharField<ENTITY, D>, HasFinder<ENTITY, FK_ENTITY> {




} }
Expand Up @@ -38,4 +38,4 @@
@Api(version = "3.0") @Api(version = "3.0")
public interface ComparableForeignKeyField<ENTITY, D, V extends Comparable<? super V>, FK> extends public interface ComparableForeignKeyField<ENTITY, D, V extends Comparable<? super V>, FK> extends
ComparableField<ENTITY, D, V>, ComparableField<ENTITY, D, V>,
HasFinder<ENTITY, FK, V> {} HasFinder<ENTITY, FK> {}

0 comments on commit 1c9f01f

Please sign in to comment.