[jOOQ/jOOQ#9325] Add Name.empty() to check if a name consists only of the empty string
This commit is contained in:
parent
b2a90be054
commit
a4e92c30fd
@ -138,6 +138,15 @@ public interface Name extends QueryPart {
|
||||
*/
|
||||
String last();
|
||||
|
||||
/**
|
||||
* Whether this is the empty name.
|
||||
* <p>
|
||||
* An unnamed object will have an <code>""</code> empty string as its name.
|
||||
* If a table has no explicit schema, it will be located in the default
|
||||
* schema whose name is <code>""</code>.
|
||||
*/
|
||||
boolean empty();
|
||||
|
||||
/**
|
||||
* Whether this is a qualified name.
|
||||
* <p>
|
||||
|
||||
@ -59,8 +59,8 @@ abstract class AbstractName extends AbstractQueryPart implements Name {
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 8562325639223483938L;
|
||||
static final Name NO_NAME = DSL.name("");
|
||||
private static final long serialVersionUID = 8562325639223483938L;
|
||||
static final UnqualifiedName NO_NAME = new UnqualifiedName("");
|
||||
|
||||
@Override
|
||||
public final Name append(String name) {
|
||||
|
||||
@ -178,6 +178,15 @@ final class QualifiedName extends AbstractName {
|
||||
return qualifiedName.length > 0 ? qualifiedName[qualifiedName.length - 1].last() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean empty() {
|
||||
for (UnqualifiedName n : qualifiedName)
|
||||
if (!n.empty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean qualified() {
|
||||
return qualifiedName.length > 1;
|
||||
|
||||
@ -45,6 +45,7 @@ import org.jooq.Context;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.conf.RenderQuotedNames;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* The default implementation for an unqualified SQL identifier.
|
||||
@ -95,6 +96,11 @@ final class UnqualifiedName extends AbstractName {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean empty() {
|
||||
return StringUtils.isEmpty(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean qualified() {
|
||||
return false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user