[#6838] Add org.jooq.User
This commit is contained in:
parent
89c8624d07
commit
41d4a78eb1
@ -42,6 +42,12 @@ package org.jooq;
|
||||
*/
|
||||
public enum Clause {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Clauses used in a any type of statement to model access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
USER,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Clauses used in a any type of statement to model constraint references
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -1,3 +1,37 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
@ -5,9 +39,10 @@ package org.jooq;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
public interface User {
|
||||
public interface User extends QueryPart {
|
||||
|
||||
/**
|
||||
* The name of user
|
||||
*/
|
||||
public Name getName();
|
||||
public String getName();
|
||||
}
|
||||
|
||||
@ -7857,10 +7857,18 @@ public class DSL {
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a new user reference.
|
||||
*
|
||||
* @see #user(Name)
|
||||
*/
|
||||
public static User user(String name) {
|
||||
return new UserImpl(name(name));
|
||||
return user(name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user reference.
|
||||
*/
|
||||
public static User user(Name name) {
|
||||
return new UserImpl(name);
|
||||
}
|
||||
|
||||
@ -1,5 +1,43 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.USER;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.User;
|
||||
|
||||
@ -8,15 +46,39 @@ import org.jooq.User;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
public class UserImpl implements User {
|
||||
private Name name;
|
||||
final class UserImpl extends AbstractQueryPart implements User {
|
||||
|
||||
public UserImpl(Name name) {
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1169948119720063466L;
|
||||
private static final Clause[] CLAUSES = { USER };
|
||||
private final Name name;
|
||||
|
||||
UserImpl(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Name getName() {
|
||||
return name;
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: User API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return name.last();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user