generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.12.x' into 2.13.x
- Loading branch information
Showing
7 changed files
with
323 additions
and
13 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
55 changes: 55 additions & 0 deletions
55
serde-processor/src/main/java/io/micronaut/serde/processor/serde/DeserializableMapper.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2017-2025 original authors | ||
* | ||
* 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 | ||
* | ||
* https://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 io.micronaut.serde.processor.serde; | ||
|
||
import io.micronaut.core.annotation.AnnotationValue; | ||
import io.micronaut.core.annotation.AnnotationValueBuilder; | ||
import io.micronaut.inject.annotation.TypedAnnotationMapper; | ||
import io.micronaut.inject.visitor.VisitorContext; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
import io.micronaut.serde.config.annotation.SerdeConfig; | ||
import java.util.List; | ||
|
||
public final class DeserializableMapper | ||
implements TypedAnnotationMapper<Serdeable.Deserializable> { | ||
@Override | ||
public Class<Serdeable.Deserializable> annotationType() { | ||
return Serdeable.Deserializable.class; | ||
} | ||
|
||
@Override | ||
public List<AnnotationValue<?>> map(AnnotationValue<Serdeable.Deserializable> annotation, VisitorContext visitorContext) { | ||
AnnotationValueBuilder<SerdeConfig> builder = AnnotationValue.builder(SerdeConfig.class); | ||
annotation.annotationClassValue("as").ifPresent(as -> | ||
builder | ||
.member(SerdeConfig.DESERIALIZE_AS, as) | ||
); | ||
annotation.annotationClassValue("using").ifPresent(using -> | ||
builder | ||
.member(SerdeConfig.DESERIALIZER_CLASS, using) | ||
); | ||
annotation.booleanValue("validate").ifPresent(validation -> | ||
builder | ||
.member(SerdeConfig.VALIDATE, validation) | ||
); | ||
annotation.annotationClassValue("naming").ifPresent(naming -> | ||
builder | ||
.member(SerdeConfig.NAMING, naming) | ||
); | ||
|
||
return List.of(builder.build()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
serde-processor/src/main/java/io/micronaut/serde/processor/serde/SerdeableMapper.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2017-2025 original authors | ||
* | ||
* 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 | ||
* | ||
* https://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 io.micronaut.serde.processor.serde; | ||
|
||
import io.micronaut.core.annotation.AnnotationValue; | ||
import io.micronaut.core.annotation.AnnotationValueBuilder; | ||
import io.micronaut.inject.annotation.TypedAnnotationMapper; | ||
import io.micronaut.inject.visitor.VisitorContext; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
import io.micronaut.serde.config.annotation.SerdeConfig; | ||
import java.util.List; | ||
|
||
public final class SerdeableMapper | ||
implements TypedAnnotationMapper<Serdeable> { | ||
@Override | ||
public Class<Serdeable> annotationType() { | ||
return Serdeable.class; | ||
} | ||
|
||
@Override | ||
public List<AnnotationValue<?>> map(AnnotationValue<Serdeable> annotation, VisitorContext visitorContext) { | ||
|
||
AnnotationValueBuilder<SerdeConfig> builder = AnnotationValue.builder(SerdeConfig.class); | ||
annotation.booleanValue("validate").ifPresent(validation -> | ||
builder | ||
.member(SerdeConfig.VALIDATE, validation) | ||
); | ||
annotation.annotationClassValue("naming").ifPresent(naming -> | ||
builder | ||
.member(SerdeConfig.NAMING, naming) | ||
); | ||
|
||
AnnotationValue<SerdeConfig> result = builder.build(); | ||
if (!result.getValues().isEmpty()) { | ||
return List.of(result); | ||
} else { | ||
return List.of(); | ||
} | ||
} | ||
} |
Oops, something went wrong.