Skip to content

Commit

Permalink
Change naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Alekseev authored and Andrey Alekseev committed Jan 16, 2025
1 parent 5fb040c commit 9d7f9fb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@
@ExperimentalApi(issue = "https://github.com/ydb-platform/yoj-project/issues/24")
CustomValueType customValueType() default @CustomValueType(columnClass = Comparable.class, converter = NoConverter.class);

enum NamingStrategy {
enum ColumnNaming {
@Deprecated LEGACY,
ABSOLUTE,
RELATIVE
}

/**
* LEGACY - Use parent name as prefix only if current(child) doesn't specify name explicityly
* LEGACY - Use parent name as prefix only if current(child) doesn't specify name explicitly
* ABSOLUTE - Use only current name, don't add prent name as prefix
* RELATIVE - Use current name and add parent name as prefix
*/
NamingStrategy namingStrategy() default NamingStrategy.LEGACY;
ColumnNaming columnNaming() default ColumnNaming.LEGACY;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ private String getColumnName(Schema.JavaField field) {

var name = (annotation.name().isEmpty()) ? field.getField().getName() : annotation.name();

if (annotation.namingStrategy() == Column.NamingStrategy.ABSOLUTE) {
if (annotation.columnNaming() == Column.ColumnNaming.ABSOLUTE) {
return name;
} else if (annotation.namingStrategy() == Column.NamingStrategy.RELATIVE) {
} else if (annotation.columnNaming() == Column.ColumnNaming.RELATIVE) {
return parentName + NAME_DELIMITER + name;
} else { // annotation.namingStrategy() == Column.NamingStrategy.LEGACY
} else { // annotation.columnNaming() == Column.ColumnNaming.LEGACY
if (!annotation.name().isEmpty()) {
return annotation.name();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static class Id {

@Value
static class SubEntityWithRelative {
@Column(name = "sfe_relative", namingStrategy = Column.NamingStrategy.RELATIVE)
@Column(name = "sfe_relative", columnNaming = Column.ColumnNaming.RELATIVE)
SingleFieldEntity singleFieldEntityRelative;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ private static class Id {
static class SubEntity {
boolean boolValue;

@Column(namingStrategy = Column.NamingStrategy.ABSOLUTE)
@Column(columnNaming = Column.ColumnNaming.ABSOLUTE)
boolean absoluteBoolValue;

@Column(name = "sfe")
SingleFieldEntity singleFieldEntity;

@Column(name = "sfe_absolute", namingStrategy = Column.NamingStrategy.ABSOLUTE)
@Column(name = "sfe_absolute", columnNaming = Column.ColumnNaming.ABSOLUTE)
SingleFieldEntity singleFieldEntityAbsolute;
}
}

0 comments on commit 9d7f9fb

Please sign in to comment.