mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge pull request #3078 from ebean-orm/feature/refactor-renameDtoMethodUsingAccessors
Refactor internal dto methods to use accessors
This commit is contained in:
@@ -882,13 +882,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> DtoQuery<T> findDto(Class<T> dtoType, String sql) {
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.getDescriptor(dtoType);
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.descriptor(dtoType);
|
||||
return new DefaultDtoQuery<>(this, descriptor, sql.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> DtoQuery<T> createNamedDtoQuery(Class<T> dtoType, String namedQuery) {
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.getDescriptor(dtoType);
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.descriptor(dtoType);
|
||||
String sql = descriptor.getNamedRawSql(namedQuery);
|
||||
if (sql == null) {
|
||||
throw new PersistenceException("No named query called " + namedQuery + " for bean:" + dtoType.getName());
|
||||
@@ -898,7 +898,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> DtoQuery<T> findDto(Class<T> dtoType, SpiQuery<?> ormQuery) {
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.getDescriptor(dtoType);
|
||||
DtoBeanDescriptor<T> descriptor = dtoBeanManager.descriptor(dtoType);
|
||||
return new DefaultDtoQuery<>(this, descriptor, ormQuery);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ public final class DtoBeanDescriptor<T> {
|
||||
this.namedQueries = namedQueries;
|
||||
}
|
||||
|
||||
public Class<T> getType() {
|
||||
public Class<T> type() {
|
||||
return dtoType;
|
||||
}
|
||||
|
||||
public DtoQueryPlan getQueryPlan(Object planKey) {
|
||||
public DtoQueryPlan queryPlan(Object planKey) {
|
||||
return plans.get(planKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,11 @@ public final class DtoBeanManager {
|
||||
* Return the descriptor for the given DTO bean class.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> DtoBeanDescriptor<T> getDescriptor(Class<T> dtoType) {
|
||||
|
||||
public <T> DtoBeanDescriptor<T> descriptor(Class<T> dtoType) {
|
||||
return descriptorMap.computeIfAbsent(dtoType, this::createDescriptor);
|
||||
}
|
||||
|
||||
private <T> DtoBeanDescriptor createDescriptor(Class<T> dtoType) {
|
||||
|
||||
try {
|
||||
DtoMeta meta = new DtoMetaBuilder(dtoType, typeManager).build();
|
||||
return new DtoBeanDescriptor<>(dtoType, meta, namedQueries(dtoType));
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class DtoColumn {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ public final class DtoMappingRequest {
|
||||
this.columnMeta = columnMeta;
|
||||
}
|
||||
|
||||
public DtoColumn[] getColumnMeta() {
|
||||
public DtoColumn[] columnMeta() {
|
||||
return columnMeta;
|
||||
}
|
||||
|
||||
public boolean isRelaxedMode() {
|
||||
public boolean relaxedMode() {
|
||||
return relaxedMode;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
public String sql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ public final class DtoMappingRequest {
|
||||
}
|
||||
|
||||
private DtoReadSet mapColumn(int pos, DtoMeta meta) {
|
||||
String label = columnMeta[pos].getLabel();
|
||||
String label = columnMeta[pos].label();
|
||||
DtoReadSet property = meta.findProperty(label);
|
||||
if (property == null || property.isReadOnly()) {
|
||||
if (isRelaxedMode()) {
|
||||
if (relaxedMode()) {
|
||||
property = DtoReadSetColumnSkip.INSTANCE;
|
||||
} else {
|
||||
throw new IllegalStateException(unableToMapColumnMessage(columnMeta[pos], meta));
|
||||
|
||||
@@ -18,7 +18,7 @@ final class DtoMeta {
|
||||
DtoMeta(Class<?> dtoType, Collection<DtoMetaConstructor> constructors, List<DtoMetaProperty> properties) {
|
||||
this.dtoType = dtoType;
|
||||
for (DtoMetaProperty property : properties) {
|
||||
propMap.put(property.getName().toUpperCase(), property);
|
||||
propMap.put(property.name().toUpperCase(), property);
|
||||
}
|
||||
int maxArg = 0;
|
||||
DtoMetaConstructor defaultConstructor = null;
|
||||
@@ -38,7 +38,7 @@ final class DtoMeta {
|
||||
}
|
||||
|
||||
public DtoQueryPlan match(DtoMappingRequest request) {
|
||||
DtoColumn[] cols = request.getColumnMeta();
|
||||
DtoColumn[] cols = request.columnMeta();
|
||||
int colLen = cols.length;
|
||||
DtoMetaConstructor constructor = constructorMap.get(colLen);
|
||||
if (constructor != null) {
|
||||
|
||||
@@ -44,7 +44,7 @@ final class DtoMetaProperty implements DtoReadSet {
|
||||
return method.getParameterTypes()[0];
|
||||
}
|
||||
|
||||
String getName() {
|
||||
String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class DefaultDtoQuery<T> extends AbstractQuery implements SpiDtoQue
|
||||
|
||||
@Override
|
||||
public DtoQueryPlan getQueryPlan(Object planKey) {
|
||||
return descriptor.getQueryPlan(planKey);
|
||||
return descriptor.queryPlan(planKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,7 +206,7 @@ public final class DefaultDtoQuery<T> extends AbstractQuery implements SpiDtoQue
|
||||
|
||||
@Override
|
||||
public Class<T> getType() {
|
||||
return descriptor.getType();
|
||||
return descriptor.type();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user