Skip to content

Commit

Permalink
use constants for rune property names (#926)
Browse files Browse the repository at this point in the history
* use constants for rune property names

* rename constants
  • Loading branch information
davidalk authored Feb 18, 2025
1 parent cdbd17d commit a27a430
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.regnosys.rosetta.generator.java.types;

import static com.rosetta.model.lib.RuneNameConstants.*;

import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -60,8 +62,8 @@ public List<JavaClass<?>> getInterfaces() {
@Override
public Collection<JavaPojoProperty> getOwnProperties() {
return List.of(
new JavaPojoProperty("value", "@data", "value", valueType, null, null, false),
new JavaPojoProperty("meta", "meta", "meta", typeUtil.META_FIELDS, null, null, false)
new JavaPojoProperty("value", DATA, "value", valueType, null, null, false),
new JavaPojoProperty("meta", META, "meta", typeUtil.META_FIELDS, null, null, false)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.regnosys.rosetta.generator.java.types;

import static com.rosetta.model.lib.RuneNameConstants.*;

import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -62,9 +64,9 @@ public List<JavaClass<?>> getInterfaces() {
@Override
public Collection<JavaPojoProperty> getOwnProperties() {
return List.of(
new JavaPojoProperty("value", "@data", "value", valueType, null, null, false),
new JavaPojoProperty("globalReference", "@ref", "globalReference", javaTypeUtil.STRING, null, AttributeMeta.META, false),
new JavaPojoProperty("externalReference", "@ref:external", "externalReference", javaTypeUtil.STRING, null, AttributeMeta.META, false),
new JavaPojoProperty("value", DATA, "value", valueType, null, null, false),
new JavaPojoProperty("globalReference", REFERENCE, "globalReference", javaTypeUtil.STRING, null, AttributeMeta.META, false),
new JavaPojoProperty("externalReference", EXTERNAL_REFERENCE, "externalReference", javaTypeUtil.STRING, null, AttributeMeta.META, false),
new JavaPojoProperty("reference", null, "reference", javaTypeUtil.REFERENCE, null, null, false)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.rosetta.model.lib;

public class RuneNameConstants {
private RuneNameConstants() {}

public static final String DATA = "@data";
public static final String REFERENCE = "@ref";
public static final String EXTERNAL_REFERENCE = "@ref:external";
public static final String SCOPED_REFERENCE = "@ref:scoped";
public static final String META = "meta";
public static final String SCHEME = "@scheme";
public static final String KEY = "@key";
public static final String EXTERNAL_KEY = "@key:external";
public static final String SCOPED_KEY = "@key:scoped";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Objects;
import java.util.stream.Collectors;

import static com.rosetta.model.lib.RuneNameConstants.*;
import static java.util.Optional.ofNullable;

/**
Expand Down Expand Up @@ -140,7 +141,7 @@ protected MetaAndTemplateFieldsImpl(MetaAndTemplateFields.MetaAndTemplateFieldsB

@Override
@RosettaAttribute("scheme")
@RuneAttribute("scheme")
@RuneAttribute(SCHEME)
public String getScheme() {
return scheme;
}
Expand All @@ -159,7 +160,7 @@ public String getLocation() {

@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public String getAddress() {
return address;
}
Expand All @@ -172,14 +173,14 @@ public String getTemplateGlobalReference() {

@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public String getGlobalKey() {
return globalKey;
}

@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public String getExternalKey() {
return externalKey;
}
Expand All @@ -191,7 +192,7 @@ public List<? extends Key> getKey() {
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public String getKeyScoped() {
if (key == null || key.isEmpty()) {
return null;
Expand Down Expand Up @@ -286,7 +287,7 @@ public MetaAndTemplateFieldsBuilderImpl() {

@Override
@RosettaAttribute("scheme")
@RuneAttribute("scheme")
@RuneAttribute(SCHEME)
public String getScheme() {
return scheme;
}
Expand All @@ -305,7 +306,7 @@ public String getLocation() {

@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public String getAddress() {
return address;
}
Expand All @@ -318,14 +319,14 @@ public String getTemplateGlobalReference() {

@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public String getGlobalKey() {
return globalKey;
}

@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public String getExternalKey() {
return externalKey;
}
Expand All @@ -349,7 +350,7 @@ public Key.KeyBuilder getOrCreateKey(int _index) {
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public String getKeyScoped() {
if (key == null || key.isEmpty()) {
return null;
Expand All @@ -359,7 +360,7 @@ public String getKeyScoped() {

@Override
@RosettaAttribute("scheme")
@RuneAttribute("scheme")
@RuneAttribute(SCHEME)
public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setScheme(String scheme) {
this.scheme = scheme==null?null:scheme;
return this;
Expand All @@ -378,7 +379,7 @@ public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setLocation(String loc
}
@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setAddress(String address) {
this.address = address==null?null:address;
return this;
Expand All @@ -391,14 +392,14 @@ public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setTemplateGlobalRefer
}
@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setGlobalKey(String globalKey) {
this.globalKey = globalKey==null?null:globalKey;
return this;
}
@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setExternalKey(String externalKey) {
this.externalKey = externalKey==null?null:externalKey;
return this;
Expand Down Expand Up @@ -439,7 +440,7 @@ public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setKey(List<? extends
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public MetaAndTemplateFields.MetaAndTemplateFieldsBuilder setKeyScoped(String keyScoped) {
this.key = new ArrayList<>();
if (keyScoped!=null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.rosetta.model.metafields;

import static java.util.Optional.ofNullable;
import static com.rosetta.model.lib.RuneNameConstants.*;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -135,7 +136,7 @@ protected MetaFieldsImpl(MetaFields.MetaFieldsBuilder builder) {

@Override
@RosettaAttribute("scheme")
@RuneAttribute("@scheme")
@RuneAttribute(SCHEME)
public String getScheme() {
return scheme;
}
Expand All @@ -154,21 +155,21 @@ public String getLocation() {

@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public String getAddress() {
return address;
}

@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public String getGlobalKey() {
return globalKey;
}

@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public String getExternalKey() {
return externalKey;
}
Expand All @@ -181,7 +182,7 @@ public List<? extends Key> getKey() {
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public String getScopedKey() {
if (key == null || key.isEmpty()) {
return null;
Expand Down Expand Up @@ -271,7 +272,7 @@ public MetaFieldsBuilderImpl() {

@Override
@RosettaAttribute("scheme")
@RuneAttribute("@scheme")
@RuneAttribute(SCHEME)
public String getScheme() {
return scheme;
}
Expand All @@ -290,21 +291,21 @@ public String getLocation() {

@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public String getAddress() {
return address;
}

@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public String getGlobalKey() {
return globalKey;
}

@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public String getExternalKey() {
return externalKey;
}
Expand All @@ -317,7 +318,7 @@ public List<? extends Key.KeyBuilder> getKey() {
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public String getScopedKey() {
if (key == null || key.isEmpty()) {
return null;
Expand All @@ -339,7 +340,7 @@ public Key.KeyBuilder getOrCreateKey(int _index) {

@Override
@RosettaAttribute("scheme")
@RuneAttribute("@scheme")
@RuneAttribute(SCHEME)
public MetaFields.MetaFieldsBuilder setScheme(String scheme) {
this.scheme = scheme==null?null:scheme;
return this;
Expand All @@ -358,21 +359,21 @@ public MetaFields.MetaFieldsBuilder setLocation(String location) {
}
@Override
@RosettaAttribute("address")
@RuneAttribute("@ref:scoped")
@RuneAttribute(SCOPED_REFERENCE)
public MetaFields.MetaFieldsBuilder setAddress(String address) {
this.address = address==null?null:address;
return this;
}
@Override
@RosettaAttribute("globalKey")
@RuneAttribute("@key")
@RuneAttribute(KEY)
public MetaFields.MetaFieldsBuilder setGlobalKey(String globalKey) {
this.globalKey = globalKey==null?null:globalKey;
return this;
}
@Override
@RosettaAttribute("externalKey")
@RuneAttribute("@key:external")
@RuneAttribute(EXTERNAL_KEY)
public MetaFields.MetaFieldsBuilder setExternalKey(String externalKey) {
this.externalKey = externalKey==null?null:externalKey;
return this;
Expand Down Expand Up @@ -414,7 +415,7 @@ public MetaFields.MetaFieldsBuilder setKey(List<? extends Key> keys) {
}

@Override
@RuneAttribute("@key:scoped")
@RuneAttribute(SCOPED_KEY)
public MetaFields.MetaFieldsBuilder setScopedKey(String scopedKey) {
this.key = new ArrayList<>();
if (scopedKey!=null) {
Expand Down

0 comments on commit a27a430

Please sign in to comment.