Skip to content

Commit

Permalink
update naming of the annotaions to be more user friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
skudikala committed Jun 11, 2024
1 parent d8a67cd commit 8908e28
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
@Retention(RetentionPolicy.RUNTIME)
@RosettaAnnotation
public @interface RosettaSetter {
public @interface RosettaDeserializationProperty {
String USE_DEFAULT_NAME = "";

String value() default USE_DEFAULT_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
@Retention(RetentionPolicy.RUNTIME)
@RosettaAnnotation
public @interface RosettaGetter {
public @interface RosettaSerializationProperty {
String USE_DEFAULT_NAME = "";

String value() default USE_DEFAULT_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.hubspot.rosetta.annotations.RosettaCreator;
import com.hubspot.rosetta.annotations.RosettaDeserializationProperty;
import com.hubspot.rosetta.annotations.RosettaDeserialize;
import com.hubspot.rosetta.annotations.RosettaGetter;
import com.hubspot.rosetta.annotations.RosettaIgnore;
import com.hubspot.rosetta.annotations.RosettaNaming;
import com.hubspot.rosetta.annotations.RosettaProperty;
import com.hubspot.rosetta.annotations.RosettaSerializationProperty;
import com.hubspot.rosetta.annotations.RosettaSerialize;
import com.hubspot.rosetta.annotations.RosettaSetter;
import com.hubspot.rosetta.annotations.RosettaValue;
import com.hubspot.rosetta.annotations.StoredAsJson;
import java.util.Optional;
Expand Down Expand Up @@ -182,7 +182,7 @@ private Optional<PropertyName> findRosettaPropertyName(Annotated a) {

private Optional<PropertyName> findRosettaGetterName(Annotated a) {
return Optional
.ofNullable(a.getAnnotation(RosettaGetter.class))
.ofNullable(a.getAnnotation(RosettaSerializationProperty.class))
.map(annotation ->
annotation.value().isEmpty()
? PropertyName.USE_DEFAULT
Expand All @@ -192,7 +192,7 @@ private Optional<PropertyName> findRosettaGetterName(Annotated a) {

private Optional<PropertyName> findRosettaSetterName(Annotated a) {
return Optional
.ofNullable(a.getAnnotation(RosettaSetter.class))
.ofNullable(a.getAnnotation(RosettaDeserializationProperty.class))
.map(annotation ->
annotation.value().isEmpty()
? PropertyName.USE_DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hubspot.rosetta.annotations.RosettaGetter;
import com.hubspot.rosetta.annotations.RosettaSerializationProperty;

public class RosettaGetterBean {

@RosettaGetter("mccartney_song_title")
@RosettaSerializationProperty("mccartney_song_title")
private String mcCartneySongTitle;

@RosettaGetter
@RosettaSerializationProperty
@JsonIgnore
private String jsonIgnoreRosettaUse;

@JsonProperty("otherValue")
@RosettaGetter("other_value")
@RosettaSerializationProperty("other_value")
private String someOtherValue;

public String getMcCartneySongTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hubspot.rosetta.annotations.RosettaSetter;
import com.hubspot.rosetta.annotations.RosettaDeserializationProperty;

public class RosettaSetterBean {

@RosettaSetter("mccartney_song_title")
@RosettaDeserializationProperty("mccartney_song_title")
private String mcCartneySongTitle;

@RosettaSetter
@RosettaDeserializationProperty
@JsonIgnore
private String jsonIgnoreRosettaUse;

@JsonProperty("otherValue")
@RosettaSetter("other_value")
@RosettaDeserializationProperty("other_value")
private String someOtherValue;

public String getMcCartneySongTitle() {
Expand Down

0 comments on commit 8908e28

Please sign in to comment.