本文整理汇总了Java中org.mybatis.generator.internal.rules.Rules.generatePrimaryKeyClass方法的典型用法代码示例。如果您正苦于以下问题:Java Rules.generatePrimaryKeyClass方法的具体用法?Java Rules.generatePrimaryKeyClass怎么用?Java Rules.generatePrimaryKeyClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.internal.rules.Rules
的用法示例。
在下文中一共展示了Rules.generatePrimaryKeyClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTopmostModelClass
import org.mybatis.generator.internal.rules.Rules; //导入方法依赖的package包/类
public static boolean isTopmostModelClass(Plugin.ModelClassType type, IntrospectedTable table) {
Rules rules = table.getRules();
if (type == Plugin.ModelClassType.PRIMARY_KEY)
return rules.generatePrimaryKeyClass();
if (type == Plugin.ModelClassType.BASE_RECORD)
return !rules.generatePrimaryKeyClass() && rules.generateBaseRecordClass();
if (type == Plugin.ModelClassType.RECORD_WITH_BLOBS)
return !rules.generatePrimaryKeyClass() && !rules.generateBaseRecordClass() && rules.generateRecordWithBLOBsClass();
return false;
}
示例2: isUndermostModelClass
import org.mybatis.generator.internal.rules.Rules; //导入方法依赖的package包/类
public static boolean isUndermostModelClass(Plugin.ModelClassType type, IntrospectedTable table) {
Rules rules = table.getRules();
if (type == Plugin.ModelClassType.PRIMARY_KEY)
return rules.generatePrimaryKeyClass() && !rules.generateBaseRecordClass() && !rules.generateRecordWithBLOBsClass();
if (type == Plugin.ModelClassType.BASE_RECORD)
return rules.generateBaseRecordClass() && !rules.generateRecordWithBLOBsClass();
if (type == Plugin.ModelClassType.RECORD_WITH_BLOBS)
return rules.generateRecordWithBLOBsClass();
return false;
}
示例3: genClassName
import org.mybatis.generator.internal.rules.Rules; //导入方法依赖的package包/类
public Pair<String, Set<FullyQualifiedJavaType>> genClassName() {
String s = name;
Set<FullyQualifiedJavaType> imports = new HashSet<FullyQualifiedJavaType>();
if (table != null) {
Rules rules = table.getRules();
boolean genPK = rules.generatePrimaryKeyClass(), genBase = rules.generateBaseRecordClass(), genBLOB = rules.generateRecordWithBLOBsClass();
boolean hasPK = table.hasPrimaryKeyColumns(), hasBase = table.hasBaseColumns(), hasBLOB = table.hasBLOBColumns();
FullyQualifiedJavaType pk = genPK && hasPK ? new FullyQualifiedJavaType(table.getPrimaryKeyType()) : null;
FullyQualifiedJavaType base = genBase && (hasBase || !genPK && hasPK || !genBLOB && hasBLOB) ? new FullyQualifiedJavaType(table.getBaseRecordType()) : null;
FullyQualifiedJavaType blob = genBLOB && hasBLOB ? new FullyQualifiedJavaType(table.getRecordWithBLOBsType()) : null;
if (!genPK && hasPK)
pk = base;
if (!genBLOB && hasBLOB)
blob = base;
FullyQualifiedJavaType model = Objects.nvl(blob, base, pk);
s = replaceAndImport(s, "(?i)\\*(example|criteria)", new FullyQualifiedJavaType(table.getExampleType()), imports);
s = replaceAndImport(s, "(?i)\\*mapper", new FullyQualifiedJavaType(table.getMyBatis3JavaMapperType()), imports);
s = replaceAndImport(s, "(?i)\\*model", model, imports);
s = replaceAndImport(s, "(?i)\\*pk", pk, imports);
s = replaceAndImport(s, "(?i)\\*base", base, imports);
s = replaceAndImport(s, "(?i)\\*blob", blob, imports);
if (hasPK) {
FullyQualifiedJavaType javaPK = table.getPrimaryKeyColumns().get(0).getFullyQualifiedJavaType();
s = replaceAndImport(s, "(?i)\\*(java\\.?pk(\\.?class|\\.?type)?|pk\\.?(class|type))", javaPK, imports);
}
}
s = replaceAndImport(s, "\\*", type, imports);
return Pair.of(s, imports);
}
示例4: MyBatisClasses
import org.mybatis.generator.internal.rules.Rules; //导入方法依赖的package包/类
private MyBatisClasses(IntrospectedTable introspectedTable, FullyQualifiedJavaType klazz, FullyQualifiedJavaType pk, FullyQualifiedJavaType base, FullyQualifiedJavaType blob, FullyQualifiedJavaType example, FullyQualifiedJavaType mapper) {
Rules rules = introspectedTable.getRules();
FullyQualifiedJavaType[] types = {pk, base, blob, example, mapper};
String fqklazz = klazz.getFullyQualifiedName().intern();
String[] fq = {pk.getFullyQualifiedName().intern(), base.getFullyQualifiedName().intern(), blob.getFullyQualifiedName().intern(), example.getFullyQualifiedName().intern(), mapper.getFullyQualifiedName().intern()};
String[] s = {pk.getShortName().intern(), base.getShortName().intern(), blob.getShortName().intern(), example.getShortName().intern(), mapper.getShortName().intern()};
boolean[][] efq = compare(fq);
boolean[][] es = compare(s);
boolean[][] ep = compare(pk.getPackageName().intern(), base.getPackageName().intern(), blob.getPackageName().intern(), example.getPackageName().intern(), mapper.getPackageName().intern());
int idx = -1;
for (int i = 0; i < fq.length && idx < 0; i++) if (fqklazz == fq[i]) idx = i;
String[] names = new String[fq.length];
boolean[] imports = new boolean[fq.length];
if (idx >= 0) {
for (int i = 0; i < es.length; i++) {
if (i == idx) {
names[i] = s[idx];
imports[i] = false;
} else if (es[idx][i]) {
/* equal class names */
names[i] = ep[idx][i] ? /* same class */ s[i] : fq[i];
imports[i] = !ep[idx][i];
} else {
names[i] = s[i];
imports[i] = !ep[idx][i];
for (int j = 0; j < i; j++) if (es[i][j]) names[i] = fq[i];
}
}
} else {
names = fq;
Arrays.fill(imports, true);
}
this.names = new Types<String>(names[0], names[1], names[2], names[3], names[4]);
this.imports = new Types<FullyQualifiedJavaType>(imports[0] ? types[0] : null, imports[1] ? types[1] : null, imports[2] ? types[2] : null, imports[3] ? types[3] : null, imports[4] ? types[4] : null);
this.types = new Types<FullyQualifiedJavaType>(pk, base, blob, example, mapper);
this.exists = new Types<Boolean>(introspectedTable.hasPrimaryKeyColumns() && rules.generatePrimaryKeyClass(), rules.generateBaseRecordClass(), introspectedTable.hasBLOBColumns() && rules.generateRecordWithBLOBsClass(), rules.generateExampleClass(), true);
}