Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tool-config: Separate tool config HasTypeMapper into trait as well
- Loading branch information
Showing
7 changed files
with
59 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...rent/tool-config/src/main/java/com/speedment/tool/config/trait/HasTypeMapperProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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() | |||
); | |||
} | |||
|
|||
} |