private GrantorSpecification getGrantorSpecification(SqlBaseParser.GrantorContext context) { if (context instanceof SqlBaseParser.SpecifiedPrincipalContext) { return new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(getPrincipalSpecification(((SqlBaseParser.SpecifiedPrincipalContext) context).principal()))); } else if (context instanceof SqlBaseParser.CurrentUserGrantorContext) { return new GrantorSpecification(GrantorSpecification.Type.CURRENT_USER, Optional.empty()); } else if (context instanceof SqlBaseParser.CurrentRoleGrantorContext) { return new GrantorSpecification(GrantorSpecification.Type.CURRENT_ROLE, Optional.empty()); } else { throw new IllegalArgumentException("Unsupported grantor: " + context); } }
private GrantorSpecification getGrantorSpecification(SqlBaseParser.GrantorContext context) { if (context instanceof SqlBaseParser.SpecifiedPrincipalContext) { return new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(getPrincipalSpecification(((SqlBaseParser.SpecifiedPrincipalContext) context).principal()))); } else if (context instanceof SqlBaseParser.CurrentUserGrantorContext) { return new GrantorSpecification(GrantorSpecification.Type.CURRENT_USER, Optional.empty()); } else if (context instanceof SqlBaseParser.CurrentRoleGrantorContext) { return new GrantorSpecification(GrantorSpecification.Type.CURRENT_ROLE, Optional.empty()); } else { throw new IllegalArgumentException("Unsupported grantor: " + context); } }
@Override public Node visitGrant(SqlBaseParser.GrantContext context) { Optional<List<String>> privileges; if (context.ALL() != null) { privileges = Optional.empty(); } else { privileges = Optional.of(context.privilege().stream() .map(SqlBaseParser.PrivilegeContext::getText) .collect(toList())); } return new Grant( getLocation(context), privileges, context.TABLE() != null, getQualifiedName(context.qualifiedName()), getPrincipalSpecification(context.grantee), context.OPTION() != null); }
@Override public Node visitRevoke(SqlBaseParser.RevokeContext context) { Optional<List<String>> privileges; if (context.ALL() != null) { privileges = Optional.empty(); } else { privileges = Optional.of(context.privilege().stream() .map(SqlBaseParser.PrivilegeContext::getText) .collect(toList())); } return new Revoke( getLocation(context), context.OPTION() != null, privileges, context.TABLE() != null, getQualifiedName(context.qualifiedName()), getPrincipalSpecification(context.grantee)); }
@Override public Node visitGrant(SqlBaseParser.GrantContext context) { Optional<List<String>> privileges; if (context.ALL() != null) { privileges = Optional.empty(); } else { privileges = Optional.of(context.privilege().stream() .map(SqlBaseParser.PrivilegeContext::getText) .collect(toList())); } return new Grant( getLocation(context), privileges, context.TABLE() != null, getQualifiedName(context.qualifiedName()), getPrincipalSpecification(context.grantee), context.OPTION() != null); }
@Override public Node visitRevoke(SqlBaseParser.RevokeContext context) { Optional<List<String>> privileges; if (context.ALL() != null) { privileges = Optional.empty(); } else { privileges = Optional.of(context.privilege().stream() .map(SqlBaseParser.PrivilegeContext::getText) .collect(toList())); } return new Revoke( getLocation(context), context.OPTION() != null, privileges, context.TABLE() != null, getQualifiedName(context.qualifiedName()), getPrincipalSpecification(context.grantee)); }