/** * Tables are in the <code>tables</code> package. <br /> * Daos are in the <code>dao.internal</code> package. <br /> * Records are in the <code>records</code> package. <br /> */ @Override public String getJavaPackageName(final Definition definition, final Mode mode) { final StringBuilder sb = new StringBuilder(getTargetPackage()); if (mode == Mode.DEFAULT) { sb.append(".tables"); } else if (mode == Mode.DAO) { sb.append(".dao.internal"); } else if (mode == Mode.RECORD) { sb.append(".records"); } return sb.toString(); }
@Override public String getJavaClassName(Definition definition, Mode mode) { StringBuilder result = new StringBuilder(); if (mode == Mode.RECORD) { result.append('R'); } else if (mode == Mode.DEFAULT) { result.append('T'); } else if (mode == Mode.INTERFACE) { result.append('I'); } result.append(StringUtils.toCamelCase(definition.getOutputName())); if (mode == Mode.RECORD) { result.append("Record"); } else if (mode == Mode.DAO) { result.append("Dao"); } return result.toString(); }
/** * Daos start with "Internal". e.g. NewsDao -> InternalNewsDao * Tables end with "Table". e.g. News -> NewsTable */ @Override public String getJavaClassName(final Definition definition, final Mode mode) { String className = super.getJavaClassName(definition, mode); if(mode == Mode.DAO) { className = "Internal" + className; } else if (mode == Mode.DEFAULT) { className += "Table"; } return className; }
@Override public List<String> getJavaClassImplements(Definition definition, Mode mode) { List<String> javaClassImplements = super.getJavaClassImplements(definition, mode); if(mode.equals(Mode.DAO)){ final String tableRecord = getFullJavaClassName(definition, Mode.RECORD); final String pType = getFullJavaClassName(definition, Mode.POJO); javaClassImplements.add(String.format("%s<%s,%s,%s>",daoClassName,tableRecord,pType, VertxJavaWriter.PLACEHOLDER_DAO_TYPE)); }else if(mode.equals(Mode.INTERFACE)){ javaClassImplements.add(VertxPojo.class.getName()); } return javaClassImplements; }
@Override public List<String> getJavaClassImplements(Definition definition, Mode mode) { List<String> javaClassImplements = delegate.getJavaClassImplements(definition, mode); if(mode.equals(Mode.DAO)){ final String tableRecord = getFullJavaClassName(definition, Mode.RECORD); final String pType = getFullJavaClassName(definition, Mode.POJO); javaClassImplements.add(String.format("%s<%s,%s,%s>",daoClassName,tableRecord,pType, VertxJavaWriter.PLACEHOLDER_DAO_TYPE)); } return javaClassImplements; }
@Override public String getJavaMemberName(Definition definition, Mode mode) { if(mode==Mode.POJO){ return definition.getName(); } return super.getJavaMemberName(definition, mode); }
@Override public String getJavaSetterName(Definition definition, Mode mode) { String result = super.getJavaSetterName(definition, mode); switch (result) { case "setEnvironmentId": return "setStackId"; case "setParentEnvironmentId": return "setParentStackId"; case "setFolder": return "setGroup"; } return result; }
@Override public String getJavaGetterName(Definition definition, Mode mode) { String result = super.getJavaGetterName(definition, mode); switch (result) { case "getEnvironmentId": return "getStackId"; case "getParentEnvironmentId": return "getParentStackId"; case "getFolder": return "getGroup"; } return result; }
@Override public String getJavaIdentifier(Definition definition) { String result = super.getJavaIdentifier(definition); switch (result) { case "ENVIRONMENT": return "STACK"; case "ENVIRONMENT_ID": return "STACK_ID"; case "FOLDER": return "GROUP"; } return result; }
@Override public String getJavaClassName(Definition definition, Mode mode) { String result = getJavaClassName0(definition, mode); switch (result) { case "Environment": return "Stack"; case "EnvironmentRecord": return "StackRecord"; case "EnvironmentTable": return "StackTable"; } return result; }
protected String getJavaClassName0(Definition definition, Mode mode) { if (mode == Mode.INTERFACE) { String result = super.getJavaClassName(definition, mode); return StringUtils.removeStart(result, "I"); } else if (mode == Mode.DEFAULT) { return super.getJavaClassName(definition, mode) + "Table"; } return super.getJavaClassName(definition, mode); }
@Override public String getJavaPackageName(Definition definition, Mode mode) { if (mode == Mode.INTERFACE) { String result = super.getJavaPackageName(definition, mode); return StringUtils.replace(result, ".tables.interfaces", ""); } return super.getJavaPackageName(definition, mode); }
@Override public List<String> getJavaClassImplements(Definition definition, Mode mode) { List<String> result = super.getJavaClassImplements(definition, mode); if (mode == Mode.RECORD) { result.add(TableRecordJaxb.class.getName()); } return result; }
@Override public String getJavaClassName(Definition definition, Mode mode) { if ( mode == Mode.INTERFACE ) { String result = super.getJavaClassName(definition, mode); return StringUtils.removeStart(result, "I"); } else if ( mode == Mode.DEFAULT ) { return super.getJavaClassName(definition, mode) + "Table"; } return super.getJavaClassName(definition, mode); }
@Override public String getJavaPackageName(Definition definition, Mode mode) { if ( mode == Mode.INTERFACE ) { String result = super.getJavaPackageName(definition, mode); return StringUtils.replace(result, ".tables.interfaces", ""); } return super.getJavaPackageName(definition, mode); }
@Override public List<String> getJavaClassImplements(Definition definition, Mode mode) { List<String> result = super.getJavaClassImplements(definition, mode); if ( mode == Mode.RECORD ) { result.add(TableRecordJaxb.class.getName()); } return result; }
@Override public String getJavaClassName(final Definition definition, final Mode mode) { return getVersion(definition) + "_" + super.getJavaClassName(definition, mode); }
@Override public String getJavaIdentifier(Definition definition) { return getVersion(definition) + "_" + super.getJavaIdentifier(definition); }
private String getVersion(Definition definition) { return ((AbstractDatabase) definition.getDatabase()).getProperties().getProperty(ModelSynchronizer.VERSION_PROPERTY_KEY); }
@Override public String getJavaPackageName(Definition definition, Mode mode) { return getTargetPackage(); }
@Override public String getFileName(Definition definition) { return delegate.getFileName(definition); }
@Override public String getFileName(Definition definition, Mode mode) { return delegate.getFileName(definition, mode); }
@Override public File getFile(Definition definition) { return delegate.getFile(definition); }
@Override public File getFile(Definition definition, Mode mode) { return delegate.getFile(definition, mode); }
@Override public String getFileHeader(Definition definition) { return delegate.getFileHeader(definition); }
@Override public String getFullJavaIdentifier(Definition definition) { return delegate.getFullJavaIdentifier(definition); }
@Override public String getJavaSetterName(Definition definition) { return delegate.getJavaSetterName(definition); }
@Override public String getJavaGetterName(Definition definition) { return delegate.getJavaGetterName(definition); }
@Override public String getJavaMethodName(Definition definition) { return delegate.getJavaMethodName(definition); }
@Override public String getJavaClassExtends(Definition definition) { return delegate.getJavaClassExtends(definition); }
@Override public List<String> getJavaClassImplements(Definition definition) { return delegate.getJavaClassImplements(definition); }
@Override public String getJavaClassName(Definition definition) { return delegate.getJavaClassName(definition); }
@Override public String getJavaPackageName(Definition definition) { return delegate.getJavaPackageName(definition); }
@Override public String getJavaMemberName(Definition definition) { return delegate.getJavaMemberName(definition); }
@Override public String getFullJavaClassName(Definition definition) { return delegate.getFullJavaClassName(definition); }
@Override public String getFullJavaClassName(Definition definition, Mode mode) { return delegate.getFullJavaClassName(definition, mode); }
@Override public List<String> getJavaIdentifiers(Collection<? extends Definition> definitions) { return delegate.getJavaIdentifiers(definitions); }