Skip to content

Commit

Permalink
tool-config: Separate tool config HasTypeMapper into trait as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyknic committed Jan 10, 2017
1 parent 38929d7 commit 298188a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 39 deletions.
Expand Up @@ -16,15 +16,13 @@
*/ */
package com.speedment.runtime.field.trait; package com.speedment.runtime.field.trait;



import com.speedment.runtime.typemapper.TypeMapper; import com.speedment.runtime.typemapper.TypeMapper;


/** /**
* *
* @author Emil Forslund * @author Emil Forslund
* @since 3.0.0 * @since 3.0.0
*/ */

public interface HasTypeMapper { public interface HasTypeMapper {


/** /**
Expand Down
Expand Up @@ -25,8 +25,6 @@
import com.speedment.tool.config.trait.*; import com.speedment.tool.config.trait.*;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static javafx.beans.binding.Bindings.createObjectBinding;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;


Expand All @@ -43,6 +41,7 @@ public final class ColumnProperty
HasNameProperty, HasNameProperty,
HasAliasProperty, HasAliasProperty,
HasNullableProperty, HasNullableProperty,
HasTypeMapperProperty,
HasOrdinalPositionProperty { HasOrdinalPositionProperty {


public ColumnProperty(Table parent) { public ColumnProperty(Table parent) {
Expand All @@ -62,15 +61,6 @@ public BooleanProperty autoIncrementProperty() {
public boolean isAutoIncrement() { public boolean isAutoIncrement() {
return autoIncrementProperty().get(); return autoIncrementProperty().get();
} }

public StringProperty typeMapperProperty() {
return stringPropertyOf(TYPE_MAPPER, () -> Column.super.getTypeMapper().orElse(null));
}

@Override
public Optional<String> getTypeMapper() {
return Optional.ofNullable(typeMapperProperty().get());
}


public StringProperty enumConstantsProperty() { public StringProperty enumConstantsProperty() {
return stringPropertyOf(ENUM_CONSTANTS, () -> Column.super.getEnumConstants().orElse(null)); return stringPropertyOf(ENUM_CONSTANTS, () -> Column.super.getEnumConstants().orElse(null));
Expand All @@ -80,23 +70,6 @@ public StringProperty enumConstantsProperty() {
public Optional<String> getEnumConstants() { public Optional<String> getEnumConstants() {
return Optional.ofNullable(enumConstantsProperty().get()); return Optional.ofNullable(enumConstantsProperty().get());
} }
@Override
public String getDatabaseType() {
return databaseTypeProperty().get();
}

public StringProperty databaseTypeProperty() {
return stringPropertyOf(DATABASE_TYPE, Column.super::getDatabaseType);
}

public ObjectBinding<Class<?>> databaseTypeObjectProperty() {
return createObjectBinding(Column.super::findDatabaseType, databaseTypeProperty());
}

@Override
public Class<?> findDatabaseType() {
return databaseTypeObjectProperty().get();
}


@Override @Override
public ColumnPropertyMutator mutator() { public ColumnPropertyMutator mutator() {
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/ */
package com.speedment.tool.config.mutator; package com.speedment.tool.config.mutator;



import com.speedment.runtime.config.mutator.ColumnMutator; import com.speedment.runtime.config.mutator.ColumnMutator;
import com.speedment.tool.config.ColumnProperty; import com.speedment.tool.config.ColumnProperty;
import com.speedment.tool.config.mutator.trait.HasAliasPropertyMutator; import com.speedment.tool.config.mutator.trait.HasAliasPropertyMutator;
Expand All @@ -29,7 +28,6 @@
* @author Emil Forslund * @author Emil Forslund
* @since 2.3.0 * @since 2.3.0
*/ */

public final class ColumnPropertyMutator extends ColumnMutator<ColumnProperty> implements public final class ColumnPropertyMutator extends ColumnMutator<ColumnProperty> implements
HasEnabledPropertyMutator<ColumnProperty>, HasEnabledPropertyMutator<ColumnProperty>,
HasNamePropertyMutator<ColumnProperty>, HasNamePropertyMutator<ColumnProperty>,
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/ */
package com.speedment.tool.config.mutator.trait; package com.speedment.tool.config.mutator.trait;



import com.speedment.runtime.config.mutator.trait.HasOrderTypeMutator; import com.speedment.runtime.config.mutator.trait.HasOrderTypeMutator;
import com.speedment.runtime.config.parameter.OrderType; import com.speedment.runtime.config.parameter.OrderType;
import com.speedment.tool.config.trait.HasOrderTypeProperty; import com.speedment.tool.config.trait.HasOrderTypeProperty;
Expand All @@ -28,8 +27,8 @@
* @author Emil Forslund * @author Emil Forslund
* @since 2.3.0 * @since 2.3.0
*/ */

public interface HasOrderTypePropertyMutator<DOC extends HasOrderTypeProperty>
public interface HasOrderTypePropertyMutator<DOC extends HasOrderTypeProperty> extends HasOrderTypeMutator<DOC> { extends HasOrderTypeMutator<DOC> {


@Override @Override
default void setOrderType(OrderType orderType) { default void setOrderType(OrderType orderType) {
Expand Down
Expand Up @@ -16,14 +16,11 @@
*/ */
package com.speedment.tool.config.trait; package com.speedment.tool.config.trait;




/** /**
* *
* @author Emil Forslund * @author Emil Forslund
* @since 2.3.0 * @since 2.3.0
*/ */

public interface HasIconPath { public interface HasIconPath {
String getIconPath(); String getIconPath();
} }
Expand Up @@ -33,7 +33,6 @@
* @author Emil Forslund * @author Emil Forslund
* @since 2.3.0 * @since 2.3.0
*/ */

public interface HasNullableProperty extends DocumentProperty, HasNullable { public interface HasNullableProperty extends DocumentProperty, HasNullable {


/** /**
Expand Down
@@ -0,0 +1,56 @@
package com.speedment.tool.config.trait;

import com.speedment.runtime.config.trait.HasTypeMapper;
import static com.speedment.runtime.config.trait.HasTypeMapper.DATABASE_TYPE;
import static com.speedment.runtime.config.trait.HasTypeMapper.TYPE_MAPPER;
import com.speedment.tool.config.DocumentProperty;
import java.util.Optional;
import static javafx.beans.binding.Bindings.createObjectBinding;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.StringProperty;

/**
* A trait for documents that have a {@code TypeMapper} specified. This
* corresponds to the {@link HasTypeMapper} trait but for observable documents.
*
* @author Emil Forslund
* @since 3.0.2
*/
public interface HasTypeMapperProperty extends DocumentProperty, HasTypeMapper {

default StringProperty typeMapperProperty() {
return stringPropertyOf(TYPE_MAPPER,
() -> HasTypeMapper.super.getTypeMapper().orElse(null)
);
}

@Override
default Optional<String> getTypeMapper() {
return Optional.ofNullable(typeMapperProperty().get());
}

@Override
default String getDatabaseType() {
return databaseTypeProperty().get();
}

@Override
default Class<?> findDatabaseType() {
return databaseTypeObjectProperty().get();
}

default StringProperty databaseTypeProperty() {
return stringPropertyOf(
DATABASE_TYPE,
HasTypeMapper.super::getDatabaseType
);
}

default ObjectBinding<Class<?>> databaseTypeObjectProperty() {
return createObjectBinding(
HasTypeMapper.super::findDatabaseType,
databaseTypeProperty()
);
}

}

0 comments on commit 298188a

Please sign in to comment.