Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant -> Timestamp not converted. #289

Open
wirekang opened this issue Feb 20, 2023 · 1 comment
Open

Instant -> Timestamp not converted. #289

wirekang opened this issue Feb 20, 2023 · 1 comment

Comments

@wirekang
Copy link

wirekang commented Feb 20, 2023

Is there are additional steps to do?

message Foo {
    // ...
    google.protobuf.Timestamp modified_at = 4;
}
data class FooDto(
    // ...
    val modifiedAt: Instant,
)
@Mapper(
    config = GrpcDtoMapperConfig::class,
)
interface AdminDbDtoMapper {
    fun map(src: FooDto): Foo
}
@MapperConfig(
    nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
    nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
    collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED,
    unmappedSourcePolicy = ReportingPolicy.ERROR,
    unmappedTargetPolicy = ReportingPolicy.ERROR,
)
interface GrpcDtoMapperConfig
plugins {
    id("org.springframework.boot") version "3.0.2"
    id("io.spring.dependency-management") version "1.1.0"
    kotlin("jvm") version "1.8.10"
    kotlin("plugin.spring") version "1.8.10"
    kotlin("plugin.jpa") version "1.8.10"
    kotlin("plugin.allopen") version "1.8.10"
    kotlin("kapt") version "1.8.10"
}


// ...

kapt {
    arguments {
        arg("mapstruct.defaultComponentModel", "spring")
    }
}


dependencies {
    implementation("org.mapstruct:mapstruct:1.5.3.Final")
    kapt("org.mapstruct:mapstruct-processor:1.5.3.Final")
    kapt("no.entur.mapstruct.spi:protobuf-spi-impl:1.42")

    // ...

Error

foo.java:22: error: Can't map property "Instant ..modifiedAt" to "Timestamp ..modifiedAt". Consider to declare/implement a mapping method: "Timestamp map(Instant value)"..                                                                     
@zankich
Copy link

zankich commented Sep 27, 2023

You need to add implementation 'no.entur.mapstruct.spi:protobuf-support-standard:1.44' to your build.gradle and extend your mapper with ProtobufStandardMappings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants