[jOOQ/jOOQ#6182] Support renaming Keys with matcher strategy
This commit is contained in:
parent
b5fb969a55
commit
65556fe9b6
@ -59,17 +59,8 @@ import org.jooq.meta.RoutineDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
import org.jooq.meta.SequenceDefinition;
|
||||
import org.jooq.meta.TableDefinition;
|
||||
import org.jooq.meta.jaxb.MatcherRule;
|
||||
import org.jooq.meta.jaxb.MatcherTransformType;
|
||||
import org.jooq.meta.jaxb.Matchers;
|
||||
import org.jooq.meta.jaxb.MatchersCatalogType;
|
||||
import org.jooq.meta.UniqueKeyDefinition;
|
||||
import org.jooq.meta.jaxb.*;
|
||||
import org.jooq.meta.jaxb.MatchersEnumType;
|
||||
import org.jooq.meta.jaxb.MatchersFieldType;
|
||||
import org.jooq.meta.jaxb.MatchersRoutineType;
|
||||
import org.jooq.meta.jaxb.MatchersSchemaType;
|
||||
import org.jooq.meta.jaxb.MatchersSequenceType;
|
||||
import org.jooq.meta.jaxb.MatchersTableType;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
@ -195,6 +186,22 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
private final List<MatchersPrimaryKeyType> primaryKeys(Definition definition) {
|
||||
if (definition instanceof UniqueKeyDefinition u)
|
||||
if (u.isPrimaryKey())
|
||||
return matchers.getPrimaryKeys();
|
||||
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
private final List<MatchersUniqueKeyType> uniqueKeys(Definition definition) {
|
||||
if (definition instanceof UniqueKeyDefinition u)
|
||||
if (!u.isPrimaryKey())
|
||||
return matchers.getUniqueKeys();
|
||||
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
private final List<MatchersForeignKeyType> foreignKeys(Definition definition) {
|
||||
if (definition instanceof ForeignKeyDefinition)
|
||||
return matchers.getForeignKeys();
|
||||
@ -287,6 +294,30 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersPrimaryKeyType primaryKey : primaryKeys(definition)) {
|
||||
String result = match(definition, primaryKey.getExpression(), primaryKey.getKeyIdentifier());
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersUniqueKeyType uniqueKey : uniqueKeys(definition)) {
|
||||
String result = match(definition, uniqueKey.getExpression(), uniqueKey.getKeyIdentifier());
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersForeignKeyType foreignKey : foreignKeys(definition)) {
|
||||
String result = match(definition, foreignKey.getExpression(), foreignKey.getKeyIdentifier());
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersForeignKeyType foreignKey : inverseForeignKeys(definition)) {
|
||||
String result = match(definition, foreignKey.getExpression(), foreignKey.getKeyIdentifier());
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Default to standard behaviour
|
||||
return super.getJavaIdentifier(definition);
|
||||
}
|
||||
@ -325,21 +356,21 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
|
||||
}
|
||||
|
||||
for (MatchersForeignKeyType foreignKeys : foreignKeys(definition)) {
|
||||
String result = match(definition, foreignKeys.getExpression(), foreignKeys.getMethodName());
|
||||
String result = match(definition, foreignKeys.getExpression(), foreignKeys.getPathMethodName());
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersForeignKeyType inverseForeignKeys : inverseForeignKeys(definition)) {
|
||||
String result = match(definition, inverseForeignKeys.getExpression(), inverseForeignKeys.getMethodNameInverse());
|
||||
String result = match(definition, inverseForeignKeys.getExpression(), inverseForeignKeys.getPathMethodNameInverse());
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
|
||||
for (MatchersForeignKeyType manyToManyKeys : manyToManyKeys(definition)) {
|
||||
String result = match(definition, manyToManyKeys.getExpression(), manyToManyKeys.getMethodNameManyToMany());
|
||||
String result = match(definition, manyToManyKeys.getExpression(), manyToManyKeys.getPathMethodNameManyToMany());
|
||||
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
@ -25,6 +25,8 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
"catalogs",
|
||||
"schemas",
|
||||
"tables",
|
||||
"primaryKeys",
|
||||
"uniqueKeys",
|
||||
"foreignKeys",
|
||||
"fields",
|
||||
"routines",
|
||||
@ -48,6 +50,12 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
@XmlElementWrapper(name = "tables")
|
||||
@XmlElement(name = "table")
|
||||
protected List<MatchersTableType> tables;
|
||||
@XmlElementWrapper(name = "primaryKeys")
|
||||
@XmlElement(name = "table")
|
||||
protected List<MatchersPrimaryKeyType> primaryKeys;
|
||||
@XmlElementWrapper(name = "uniqueKeys")
|
||||
@XmlElement(name = "table")
|
||||
protected List<MatchersUniqueKeyType> uniqueKeys;
|
||||
@XmlElementWrapper(name = "foreignKeys")
|
||||
@XmlElement(name = "table")
|
||||
protected List<MatchersForeignKeyType> foreignKeys;
|
||||
@ -100,6 +108,28 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
this.tables = tables;
|
||||
}
|
||||
|
||||
public List<MatchersPrimaryKeyType> getPrimaryKeys() {
|
||||
if (primaryKeys == null) {
|
||||
primaryKeys = new ArrayList<MatchersPrimaryKeyType>();
|
||||
}
|
||||
return primaryKeys;
|
||||
}
|
||||
|
||||
public void setPrimaryKeys(List<MatchersPrimaryKeyType> primaryKeys) {
|
||||
this.primaryKeys = primaryKeys;
|
||||
}
|
||||
|
||||
public List<MatchersUniqueKeyType> getUniqueKeys() {
|
||||
if (uniqueKeys == null) {
|
||||
uniqueKeys = new ArrayList<MatchersUniqueKeyType>();
|
||||
}
|
||||
return uniqueKeys;
|
||||
}
|
||||
|
||||
public void setUniqueKeys(List<MatchersUniqueKeyType> uniqueKeys) {
|
||||
this.uniqueKeys = uniqueKeys;
|
||||
}
|
||||
|
||||
public List<MatchersForeignKeyType> getForeignKeys() {
|
||||
if (foreignKeys == null) {
|
||||
foreignKeys = new ArrayList<MatchersForeignKeyType>();
|
||||
@ -229,6 +259,48 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withPrimaryKeys(MatchersPrimaryKeyType... values) {
|
||||
if (values!= null) {
|
||||
for (MatchersPrimaryKeyType value: values) {
|
||||
getPrimaryKeys().add(value);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withPrimaryKeys(Collection<MatchersPrimaryKeyType> values) {
|
||||
if (values!= null) {
|
||||
getPrimaryKeys().addAll(values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withPrimaryKeys(List<MatchersPrimaryKeyType> primaryKeys) {
|
||||
setPrimaryKeys(primaryKeys);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withUniqueKeys(MatchersUniqueKeyType... values) {
|
||||
if (values!= null) {
|
||||
for (MatchersUniqueKeyType value: values) {
|
||||
getUniqueKeys().add(value);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withUniqueKeys(Collection<MatchersUniqueKeyType> values) {
|
||||
if (values!= null) {
|
||||
getUniqueKeys().addAll(values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withUniqueKeys(List<MatchersUniqueKeyType> uniqueKeys) {
|
||||
setUniqueKeys(uniqueKeys);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Matchers withForeignKeys(MatchersForeignKeyType... values) {
|
||||
if (values!= null) {
|
||||
for (MatchersForeignKeyType value: values) {
|
||||
@ -360,6 +432,8 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
builder.append("catalogs", "catalog", catalogs);
|
||||
builder.append("schemas", "schema", schemas);
|
||||
builder.append("tables", "table", tables);
|
||||
builder.append("primaryKeys", "table", primaryKeys);
|
||||
builder.append("uniqueKeys", "table", uniqueKeys);
|
||||
builder.append("foreignKeys", "table", foreignKeys);
|
||||
builder.append("fields", "field", fields);
|
||||
builder.append("routines", "routine", routines);
|
||||
@ -414,6 +488,24 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (primaryKeys == null) {
|
||||
if (other.primaryKeys!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!primaryKeys.equals(other.primaryKeys)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (uniqueKeys == null) {
|
||||
if (other.uniqueKeys!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!uniqueKeys.equals(other.uniqueKeys)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (foreignKeys == null) {
|
||||
if (other.foreignKeys!= null) {
|
||||
return false;
|
||||
@ -478,6 +570,8 @@ public class Matchers implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((catalogs == null)? 0 :catalogs.hashCode()));
|
||||
result = ((prime*result)+((schemas == null)? 0 :schemas.hashCode()));
|
||||
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
|
||||
result = ((prime*result)+((primaryKeys == null)? 0 :primaryKeys.hashCode()));
|
||||
result = ((prime*result)+((uniqueKeys == null)? 0 :uniqueKeys.hashCode()));
|
||||
result = ((prime*result)+((foreignKeys == null)? 0 :foreignKeys.hashCode()));
|
||||
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
|
||||
result = ((prime*result)+((routines == null)? 0 :routines.hashCode()));
|
||||
|
||||
@ -30,9 +30,10 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
private final static long serialVersionUID = 31900L;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String expression;
|
||||
protected MatcherRule methodName;
|
||||
protected MatcherRule methodNameInverse;
|
||||
protected MatcherRule methodNameManyToMany;
|
||||
protected MatcherRule keyIdentifier;
|
||||
protected MatcherRule pathMethodName;
|
||||
protected MatcherRule pathMethodNameInverse;
|
||||
protected MatcherRule pathMethodNameManyToMany;
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
@ -51,51 +52,67 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-one path join methods.
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatcherRule getMethodName() {
|
||||
return methodName;
|
||||
public MatcherRule getKeyIdentifier() {
|
||||
return keyIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public void setKeyIdentifier(MatcherRule value) {
|
||||
this.keyIdentifier = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-one path join methods.
|
||||
*
|
||||
*/
|
||||
public void setMethodName(MatcherRule value) {
|
||||
this.methodName = value;
|
||||
public MatcherRule getPathMethodName() {
|
||||
return pathMethodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-one path join methods.
|
||||
*
|
||||
*/
|
||||
public void setPathMethodName(MatcherRule value) {
|
||||
this.pathMethodName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public MatcherRule getMethodNameInverse() {
|
||||
return methodNameInverse;
|
||||
public MatcherRule getPathMethodNameInverse() {
|
||||
return pathMethodNameInverse;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public void setMethodNameInverse(MatcherRule value) {
|
||||
this.methodNameInverse = value;
|
||||
public void setPathMethodNameInverse(MatcherRule value) {
|
||||
this.pathMethodNameInverse = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated many-to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public MatcherRule getMethodNameManyToMany() {
|
||||
return methodNameManyToMany;
|
||||
public MatcherRule getPathMethodNameManyToMany() {
|
||||
return pathMethodNameManyToMany;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated many-to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public void setMethodNameManyToMany(MatcherRule value) {
|
||||
this.methodNameManyToMany = value;
|
||||
public void setPathMethodNameManyToMany(MatcherRule value) {
|
||||
this.pathMethodNameManyToMany = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,12 +124,21 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatchersForeignKeyType withKeyIdentifier(MatcherRule value) {
|
||||
setKeyIdentifier(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated to-one path join methods.
|
||||
*
|
||||
*/
|
||||
public MatchersForeignKeyType withMethodName(MatcherRule value) {
|
||||
setMethodName(value);
|
||||
public MatchersForeignKeyType withPathMethodName(MatcherRule value) {
|
||||
setPathMethodName(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -120,8 +146,8 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
* This rule influences the naming of the generated to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public MatchersForeignKeyType withMethodNameInverse(MatcherRule value) {
|
||||
setMethodNameInverse(value);
|
||||
public MatchersForeignKeyType withPathMethodNameInverse(MatcherRule value) {
|
||||
setPathMethodNameInverse(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -129,17 +155,18 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
* This rule influences the naming of the generated many-to-many path join methods.
|
||||
*
|
||||
*/
|
||||
public MatchersForeignKeyType withMethodNameManyToMany(MatcherRule value) {
|
||||
setMethodNameManyToMany(value);
|
||||
public MatchersForeignKeyType withPathMethodNameManyToMany(MatcherRule value) {
|
||||
setPathMethodNameManyToMany(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void appendTo(XMLBuilder builder) {
|
||||
builder.append("expression", expression);
|
||||
builder.append("methodName", methodName);
|
||||
builder.append("methodNameInverse", methodNameInverse);
|
||||
builder.append("methodNameManyToMany", methodNameManyToMany);
|
||||
builder.append("keyIdentifier", keyIdentifier);
|
||||
builder.append("pathMethodName", pathMethodName);
|
||||
builder.append("pathMethodNameInverse", pathMethodNameInverse);
|
||||
builder.append("pathMethodNameManyToMany", pathMethodNameManyToMany);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -170,30 +197,39 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (methodName == null) {
|
||||
if (other.methodName!= null) {
|
||||
if (keyIdentifier == null) {
|
||||
if (other.keyIdentifier!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!methodName.equals(other.methodName)) {
|
||||
if (!keyIdentifier.equals(other.keyIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (methodNameInverse == null) {
|
||||
if (other.methodNameInverse!= null) {
|
||||
if (pathMethodName == null) {
|
||||
if (other.pathMethodName!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!methodNameInverse.equals(other.methodNameInverse)) {
|
||||
if (!pathMethodName.equals(other.pathMethodName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (methodNameManyToMany == null) {
|
||||
if (other.methodNameManyToMany!= null) {
|
||||
if (pathMethodNameInverse == null) {
|
||||
if (other.pathMethodNameInverse!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!methodNameManyToMany.equals(other.methodNameManyToMany)) {
|
||||
if (!pathMethodNameInverse.equals(other.pathMethodNameInverse)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pathMethodNameManyToMany == null) {
|
||||
if (other.pathMethodNameManyToMany!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!pathMethodNameManyToMany.equals(other.pathMethodNameManyToMany)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -205,9 +241,10 @@ public class MatchersForeignKeyType implements Serializable, XMLAppendable
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = ((prime*result)+((expression == null)? 0 :expression.hashCode()));
|
||||
result = ((prime*result)+((methodName == null)? 0 :methodName.hashCode()));
|
||||
result = ((prime*result)+((methodNameInverse == null)? 0 :methodNameInverse.hashCode()));
|
||||
result = ((prime*result)+((methodNameManyToMany == null)? 0 :methodNameManyToMany.hashCode()));
|
||||
result = ((prime*result)+((keyIdentifier == null)? 0 :keyIdentifier.hashCode()));
|
||||
result = ((prime*result)+((pathMethodName == null)? 0 :pathMethodName.hashCode()));
|
||||
result = ((prime*result)+((pathMethodNameInverse == null)? 0 :pathMethodNameInverse.hashCode()));
|
||||
result = ((prime*result)+((pathMethodNameManyToMany == null)? 0 :pathMethodNameManyToMany.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,140 @@
|
||||
|
||||
package org.jooq.meta.jaxb;
|
||||
|
||||
import java.io.Serializable;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.jooq.util.jaxb.tools.StringAdapter;
|
||||
import org.jooq.util.jaxb.tools.XMLAppendable;
|
||||
import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Declarative naming strategy configuration for primary key names.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "MatchersPrimaryKeyType", propOrder = {
|
||||
|
||||
})
|
||||
@SuppressWarnings({
|
||||
"all"
|
||||
})
|
||||
public class MatchersPrimaryKeyType implements Serializable, XMLAppendable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = 31900L;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String expression;
|
||||
protected MatcherRule keyIdentifier;
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public void setExpression(String value) {
|
||||
this.expression = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatcherRule getKeyIdentifier() {
|
||||
return keyIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public void setKeyIdentifier(MatcherRule value) {
|
||||
this.keyIdentifier = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public MatchersPrimaryKeyType withExpression(String value) {
|
||||
setExpression(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatchersPrimaryKeyType withKeyIdentifier(MatcherRule value) {
|
||||
setKeyIdentifier(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void appendTo(XMLBuilder builder) {
|
||||
builder.append("expression", expression);
|
||||
builder.append("keyIdentifier", keyIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
XMLBuilder builder = XMLBuilder.nonFormatting();
|
||||
appendTo(builder);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass()!= that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MatchersPrimaryKeyType other = ((MatchersPrimaryKeyType) that);
|
||||
if (expression == null) {
|
||||
if (other.expression!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!expression.equals(other.expression)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (keyIdentifier == null) {
|
||||
if (other.keyIdentifier!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!keyIdentifier.equals(other.keyIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = ((prime*result)+((expression == null)? 0 :expression.hashCode()));
|
||||
result = ((prime*result)+((keyIdentifier == null)? 0 :keyIdentifier.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
|
||||
package org.jooq.meta.jaxb;
|
||||
|
||||
import java.io.Serializable;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlType;
|
||||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.jooq.util.jaxb.tools.StringAdapter;
|
||||
import org.jooq.util.jaxb.tools.XMLAppendable;
|
||||
import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Declarative naming strategy configuration for foreign key names.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "MatchersUniqueKeyType", propOrder = {
|
||||
|
||||
})
|
||||
@SuppressWarnings({
|
||||
"all"
|
||||
})
|
||||
public class MatchersUniqueKeyType implements Serializable, XMLAppendable
|
||||
{
|
||||
|
||||
private final static long serialVersionUID = 31900L;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String expression;
|
||||
protected MatcherRule keyIdentifier;
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public void setExpression(String value) {
|
||||
this.expression = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatcherRule getKeyIdentifier() {
|
||||
return keyIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public void setKeyIdentifier(MatcherRule value) {
|
||||
this.keyIdentifier = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.
|
||||
*
|
||||
*/
|
||||
public MatchersUniqueKeyType withExpression(String value) {
|
||||
setExpression(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This rule influences the naming of the generated key literal in the Keys class.
|
||||
*
|
||||
*/
|
||||
public MatchersUniqueKeyType withKeyIdentifier(MatcherRule value) {
|
||||
setKeyIdentifier(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void appendTo(XMLBuilder builder) {
|
||||
builder.append("expression", expression);
|
||||
builder.append("keyIdentifier", keyIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
XMLBuilder builder = XMLBuilder.nonFormatting();
|
||||
appendTo(builder);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass()!= that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MatchersUniqueKeyType other = ((MatchersUniqueKeyType) that);
|
||||
if (expression == null) {
|
||||
if (other.expression!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!expression.equals(other.expression)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (keyIdentifier == null) {
|
||||
if (other.keyIdentifier!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!keyIdentifier.equals(other.keyIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = ((prime*result)+((expression == null)? 0 :expression.hashCode()));
|
||||
result = ((prime*result)+((keyIdentifier == null)? 0 :keyIdentifier.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -101,6 +101,22 @@ public class ObjectFactory {
|
||||
return new MatchersTableType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link MatchersPrimaryKeyType }
|
||||
*
|
||||
*/
|
||||
public MatchersPrimaryKeyType createMatchersPrimaryKeyType() {
|
||||
return new MatchersPrimaryKeyType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link MatchersUniqueKeyType }
|
||||
*
|
||||
*/
|
||||
public MatchersUniqueKeyType createMatchersUniqueKeyType() {
|
||||
return new MatchersUniqueKeyType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link MatchersForeignKeyType }
|
||||
*
|
||||
|
||||
@ -183,6 +183,14 @@
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Declarative naming strategy configuration for table names.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="primaryKeys" type="tns:MatchersPrimaryKeysType" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Declarative naming strategy configuration for primary key names.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="uniqueKeys" type="tns:MatchersUniqueKeysType" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Declarative naming strategy configuration for unique key names.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="foreignKeys" type="tns:MatchersForeignKeysType" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Declarative naming strategy configuration for foreign key names.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
@ -378,28 +386,70 @@ and follow its (undocumented!) assumptions (e.g. constructors, etc.). Use this a
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersPrimaryKeysType">
|
||||
<sequence>
|
||||
<element name="table" type="tns:MatchersPrimaryKeyType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersUniqueKeysType">
|
||||
<sequence>
|
||||
<element name="table" type="tns:MatchersUniqueKeyType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersForeignKeysType">
|
||||
<sequence>
|
||||
<element name="table" type="tns:MatchersForeignKeyType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersPrimaryKeyType">
|
||||
<annotation><appinfo><jxb:class><jxb:javadoc><![CDATA[Declarative naming strategy configuration for primary key names.]]></jxb:javadoc></jxb:class></appinfo></annotation>
|
||||
<all>
|
||||
<element name="expression" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="keyIdentifier" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated key literal in the Keys class.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersUniqueKeyType">
|
||||
<annotation><appinfo><jxb:class><jxb:javadoc><![CDATA[Declarative naming strategy configuration for foreign key names.]]></jxb:javadoc></jxb:class></appinfo></annotation>
|
||||
<all>
|
||||
<element name="expression" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="keyIdentifier" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated key literal in the Keys class.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MatchersForeignKeyType">
|
||||
<annotation><appinfo><jxb:class><jxb:javadoc><![CDATA[Declarative naming strategy configuration for foreign key names.]]></jxb:javadoc></jxb:class></appinfo></annotation>
|
||||
<all>
|
||||
<element name="expression" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This table matcher applies to all unqualified or qualified table names matched by this expression. If left empty, this matcher applies to all tables.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="keyIdentifier" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated key literal in the Keys class.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="methodName" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<element name="pathMethodName" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated to-one path join methods.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="methodNameInverse" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<element name="pathMethodNameInverse" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated to-many path join methods.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="methodNameManyToMany" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<element name="pathMethodNameManyToMany" type="tns:MatcherRule" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This rule influences the naming of the generated many-to-many path join methods.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
</all>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user