Skip to content

Commit

Permalink
Rename Identifier methods with getXXX
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Sep 28, 2016
1 parent 899de9c commit 6554988
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 38 deletions.
Expand Up @@ -28,9 +28,9 @@
import java.util.stream.Stream;

import static com.speedment.plugins.json.internal.JsonUtil.jsonField;
import static java.util.stream.Collectors.toSet;
import static com.speedment.runtime.util.NullUtil.requireNonNullElements;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toSet;

/**
*
Expand All @@ -56,8 +56,7 @@ public <ENTITY> JsonEncoder<ENTITY> allOf(Manager<ENTITY> manager) {

manager.fields()
.forEachOrdered(f -> {
formatter.put(
jsonField(projectComponent.getProject(), f.identifier()),
formatter.put(jsonField(projectComponent.getProject(), f.identifier()),
f.getter()::apply
);
});
Expand All @@ -75,14 +74,13 @@ public final <ENTITY> JsonEncoder<ENTITY> of(Manager<ENTITY> manager, Field<ENTI

final Set<String> fieldNames = Stream.of(fields)
.map(Field::identifier)
.map(FieldIdentifier::columnName)
.map(FieldIdentifier::getColumnName)
.collect(toSet());

manager.fields()
.filter(f -> fieldNames.contains(f.identifier().columnName()))
.filter(f -> fieldNames.contains(f.identifier().getColumnName()))
.forEachOrdered(f
-> formatter.put(
jsonField(projectComponent.getProject(), f.identifier()),
-> formatter.put(jsonField(projectComponent.getProject(), f.identifier()),
f.getter()::apply
)
);
Expand Down
Expand Up @@ -50,26 +50,26 @@ public interface FieldIdentifier<ENTITY> {
*
* @return the {@link Dbms} name
*/
String dbmsName();
String getDbmsName();

/**
* Returns the database name of the {@link Schema} that this field is in.
*
* @return the {@link Schema} name
*/
String schemaName();
String getSchemaName();

/**
* Returns the database name of the {@link Table} that this field is in.
*
* @return the {@link Table} name
*/
String tableName();
String getTableName();

/**
* Returns the database name of the {@link Column} that this field is in.
*
* @return the {@link Column} name
*/
String columnName();
String getColumnName();
}
Expand Up @@ -70,7 +70,7 @@ public interface DatabaseNamingConvention {
* @return the full name
*/
default String fullNameOf(FieldIdentifier<?> fieldIdentifier) {
return fullNameOf(fieldIdentifier.schemaName(), fieldIdentifier.tableName(), fieldIdentifier.columnName());
return fullNameOf(fieldIdentifier.getSchemaName(), fieldIdentifier.getTableName(), fieldIdentifier.getColumnName());
}

/**
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -51,7 +51,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public FK_ENTITY apply(ENTITY entity) {
.orElseThrow(() -> new SpeedmentException(
"Error! Could not find any " +
getTargetManager().getEntityClass().getSimpleName() +
" with '" + getTargetField().identifier().columnName() +
" with '" + getTargetField().identifier().getColumnName() +
"' = '" + value + "'."
));
}
Expand Down
Expand Up @@ -66,11 +66,12 @@
import static com.speedment.runtime.internal.util.document.DocumentDbUtil.*;
import static com.speedment.runtime.internal.util.document.DocumentUtil.Name.DATABASE_NAME;
import com.speedment.runtime.manager.JdbcManagerSupport;
import static com.speedment.runtime.util.NullUtil.requireNonNulls;
import static java.util.Objects.requireNonNull;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.*;

import static com.speedment.runtime.util.NullUtil.requireNonNulls;
import static java.util.Objects.requireNonNull;

/**
*
* @author Emil Forslund
Expand Down Expand Up @@ -136,7 +137,7 @@ public JdbcManagerSupportImpl(
.map(c -> c.getParent())
.map(t -> isSame(table, t.get()))
.orElse(false)
).collect(toMap(f -> f.identifier().columnName(), identity()));
).collect(toMap(f -> f.identifier().getColumnName(), identity()));
}

@Override
Expand Down
Expand Up @@ -137,7 +137,7 @@ protected <ENTITY> SqlPredicateFragment render(ManagerSupport<ENTITY> manager, F
return isNotEmpty(cn);
default:
throw new UnsupportedOperationException(
"Unknown PredicateType " + pt.name() + ". Column name:" + model.getField().identifier().columnName()
"Unknown PredicateType " + pt.name() + ". Column name:" + model.getField().identifier().getColumnName()
);
}
}
Expand Down
Expand Up @@ -260,19 +260,19 @@ public static boolean isUnique(Column column) throws SpeedmentException {
}

public static Optional<? extends Column> referencedColumnIfPresent(Project project, FieldIdentifier<?> identifier) {
return referencedColumnIfPresent(project, identifier.dbmsName(), identifier.schemaName(), identifier.tableName(), identifier.columnName());
return referencedColumnIfPresent(project, identifier.getDbmsName(), identifier.getSchemaName(), identifier.getTableName(), identifier.getColumnName());
}

public static Optional<? extends Table> referencedTableIfPresent(Project project, FieldIdentifier<?> identifier) {
return referencedTableIfPresent(project, identifier.dbmsName(), identifier.schemaName(), identifier.tableName());
return referencedTableIfPresent(project, identifier.getDbmsName(), identifier.getSchemaName(), identifier.getTableName());
}

public static Optional<? extends Schema> referencedSchemaIfPresent(Project project, FieldIdentifier<?> identifier) {
return referencedSchemaIfPresent(project, identifier.dbmsName(), identifier.schemaName());
return referencedSchemaIfPresent(project, identifier.getDbmsName(), identifier.getSchemaName());
}

public static Optional<? extends Dbms> referencedDbmsIfPresent(Project project, FieldIdentifier<?> identifier) {
return referencedDbmsIfPresent(project, identifier.dbmsName());
return referencedDbmsIfPresent(project, identifier.getDbmsName());
}

public static Optional<? extends Column> referencedColumnIfPresent(Project project, String dbmsName, String schemaName, String tableName, String columnName) {
Expand Down Expand Up @@ -301,19 +301,19 @@ public static Optional<? extends Dbms> referencedDbmsIfPresent(Project project,
}

public static Column referencedColumn(Project project, FieldIdentifier<?> identifier) {
return referencedColumn(project, identifier.dbmsName(), identifier.schemaName(), identifier.tableName(), identifier.columnName());
return referencedColumn(project, identifier.getDbmsName(), identifier.getSchemaName(), identifier.getTableName(), identifier.getColumnName());
}

public static Table referencedTable(Project project, FieldIdentifier<?> identifier) {
return referencedTable(project, identifier.dbmsName(), identifier.schemaName(), identifier.tableName());
return referencedTable(project, identifier.getDbmsName(), identifier.getSchemaName(), identifier.getTableName());
}

public static Schema referencedSchema(Project project, FieldIdentifier<?> identifier) {
return referencedSchema(project, identifier.dbmsName(), identifier.schemaName());
return referencedSchema(project, identifier.getDbmsName(), identifier.getSchemaName());
}

public static Dbms referencedDbms(Project project, FieldIdentifier<?> identifier) {
return referencedDbms(project, identifier.dbmsName());
return referencedDbms(project, identifier.getDbmsName());
}

public static Column referencedColumn(Project project, String dbmsName, String schemaName, String tableName, String columnName) {
Expand Down
Expand Up @@ -37,22 +37,22 @@ enum Identifier implements FieldIdentifier<Entity> {
}

@Override
public String columnName() {
public String getColumnName() {
return columnName;
}

@Override
public String dbmsName() {
public String getDbmsName() {
return "my_dbms";
}

@Override
public String schemaName() {
public String getSchemaName() {
return "my_schema";
}

@Override
public String tableName() {
public String getTableName() {
return "my_table";
}
}
Expand Down
Expand Up @@ -30,8 +30,8 @@ public class FieldTest extends BaseFieldTest {

@Test
public void testField() throws Exception {
assertEquals("id", ID.identifier().columnName());
assertEquals("name", NAME.identifier().columnName());
assertEquals("id", ID.identifier().getColumnName());
assertEquals("name", NAME.identifier().getColumnName());
}

}

0 comments on commit 6554988

Please sign in to comment.