Java 类javax.annotation.Syntax 实例源码

项目:jactiverecord    文件:SimpleCondition.java   
@Nonnull
@Syntax("SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName)
{
    if(isValue)
    {
        if(data != null && data.getClass().isArray())
        {
            if(((Object[])data).length == 0)
            {
                //Matching item to empty list is not supported by SQL
                return "(NULL)";
            }
            //see: https://stackoverflow.com/questions/178479/preparedstatement-in-clause-alternatives
            return "("+Arrays.stream( (Object[])data).map( (final Object o) -> "?").collect( Collectors.joining( ", "))+")";
        }
        return "?";
    }
    if(data instanceof SQLFunction)
    {
        return ((SQLFunction)data).toSQL( driver, tableName );
    }
    return (String)(tableName != null ? tableName + "." + data : data);
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * NOTE: If the specified {@link IndexType} is not supported by the driver,
 * fallback to the {@link IndexType#DEFAULT default} index-type is allowed
 *
 * @param indexType the index-type to translate to driver-specific keyword
 * @return the keyword for the given index-type
 * @since 0.6
 */
@Nonnull
@Syntax(value = "SQL")
public String getIndexKeyword(@Nonnull final IndexType indexType)
{
    switch(indexType)
    {
        case DEFAULT:
            return "";
        case UNIQUE:
            return "UNIQUE";
        case CLUSTERED:
            return "CLUSTERED";
        default:
            throw new AssertionError( indexType.name() );
    }
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * @param offset the offset to start at
 * @param limit the maximum number of results
 * @return the SQL-clause to limit the amount of retrieved results
 */
@Nonnull
@Syntax(value = "SQL")
public String getLimitClause(@Nonnegative final int offset, @Signed final int limit)
{
    return (offset > 0 ? "OFFSET " + offset + " " : "") + (limit > 0 ? "FETCH FIRST " + limit + " ROWS ONLY" : "");
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * @param sqlFunction the SQL-function to apply
 * @param column the column to aggregate
 * @return the SQL function for the given column
 */
@Nonnull
@Syntax(value = "SQL")
public String getSQLFunction(@Nonnull final String sqlFunction, @Nonnull final String column)
{
    return sqlFunction.replaceAll( "%column%", column);
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * For the default-implementation, see: https://en.wikibooks.org/wiki/SQL_Dialects_Reference/Data_structure_definition/Auto-increment_column
 *
 * @param primaryKeyKeywords the previously set keywords
 * @return the keywords for an auto-incremental primary-key column
 */
@Nonnull
@Syntax(value = "SQL")
public String getPrimaryKeyKeywords(@Nonnull final String primaryKeyKeywords)
{
    return primaryKeyKeywords + " GENERATED ALWAYS AS IDENTITY PRIMARY KEY";
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * The default implementation provides a 4kB string-column
 *
 * @return the default data-type for strings
 */
@Nonnull
@Syntax(value = "SQL")
public String getStringDataType()
{
    return "VARCHAR("+JDBCDriver.STRING_TYPE_LENGTH+")";
}
项目:jactiverecord    文件:JDBCDriver.java   
/**
 * The default implementation inserts a <code>NULL</code>-value for the <code>primaryColumn</code>
 *
 * @param primaryColumn the primaryColumn
 * @return the columns-and-values string for an empty row
 */
@Nonnull
@Syntax(value = "SQL")
public String getInsertDataForEmptyRow(@Nonnull final String primaryColumn)
{
    return "(" + primaryColumn + ") VALUES (NULL)";
}
项目:codec    文件:CodecJackson.java   
/**
 * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
 * {@link #decodeObject(String, Config)} with the resultant config and the passed in category. Pretty much just
 * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
 */
public <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") String configText)
        throws JsonProcessingException, IOException {
    PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                     "could not find anything about the category %s", category);
    Config config = ConfigFactory.parseString(configText).resolve();
    return (T) decodeObject(pluginMap.baseClass(), config);
}
项目:codec    文件:CodecJackson.java   
/**
 * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
 * {@link #decodeObject(Class, Config)} with the resultant config and the passed in type. Pretty much just
 * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
 */
public <T> T decodeObject(@Nonnull Class<T> type, @Syntax("HOCON") String configText)
        throws JsonProcessingException, IOException {
    Config config = ConfigFactory.parseString(configText).resolve();
    return decodeObject(type, config);
}
项目:codec    文件:CodecJackson.java   
public <T> T decodeObject(@Nonnull TypeReference<T> type, @Syntax("HOCON") String configText)
        throws JsonProcessingException, IOException {
    Config config = ConfigFactory.parseString(configText).resolve();
    return decodeObject(type, config);
}
项目:bundle    文件:ValueFactory.java   
public static ValueMap decodeMap(@Syntax("HOCON") String config) throws IOException {
    return Configs.decodeObject(ValueMap.class, config);
}
项目:bundle    文件:MapBundle.java   
public static MapBundle decode(@Syntax("HOCON") String config) throws IOException {
    return Configs.decodeObject(MapBundle.class, config);
}
项目:bundle    文件:Bundles.java   
@Scaling(SETUP)
public static Bundle decode(@Syntax("HOCON") String config) throws IOException {
    return Configs.decodeObject(Bundle.class, config);
}
项目:jactiverecord    文件:Order.java   
/**
 * @param driver the driver for the underlying RDBMS
 * @param tableName the name to use to uniquely identify the table
 * @return a SQL representation of this Order
 */
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
项目:jactiverecord    文件:SQLFunction.java   
/**
 * @param driver the driver to be used for vendor-specific commands
 * @param tableName the name of the table to apply this function to
 * @return the SQL representation of this function
 */
@Nonnull
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
项目:jactiverecord    文件:Condition.java   
/**
 * @param driver the vendor-specific driver
 * @param tableName the name to use to uniquely identify the table
 * @return the SQL representation of this condition
 */
@Nonnull
@Syntax(value = "SQL")
public String toSQL(@Nonnull final JDBCDriver driver, @Nullable final String tableName);
项目:jactiverecord    文件:SimpleOrder.java   
/**
 * @return the SQL-representation of this order
 */
@Syntax(value = "SQL")
public abstract String toSQL();
项目:codec    文件:Configs.java   
/**
 * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
 * {@link #decodeObject(Class, Config)} with the resultant config and the passed in type. Pretty much just
 * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
 */
public static <T> T decodeObject(@Nonnull Class<T> type, @Syntax("HOCON") @Nonnull String configText)
        throws IOException {
    return Jackson.defaultCodec().decodeObject(type, configText);
}
项目:codec    文件:Configs.java   
/**
 * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
 * {@link #decodeObject(TypeReference, Config)} with the resultant config and the passed in type. Pretty much just
 * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
 */
public static <T> T decodeObject(@Nonnull TypeReference<T> type, @Syntax("HOCON") @Nonnull String configText)
        throws IOException {
    return Jackson.defaultCodec().decodeObject(type, configText);
}
项目:codec    文件:Configs.java   
/**
 * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
 * {@link #decodeObject(String, Config)} with the resultant config and the passed in category. Pretty much just
 * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
 */
public static <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") @Nonnull String configText)
        throws IOException {
    return Jackson.defaultCodec().decodeObject(category, configText);
}
项目:codec    文件:Configs.java   
/**
 * Instantiate an object without a compile time expected type. This expects a config of the
 * form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
 * key should be a valid, loaded, plug-in category.
 */
public static <T> T decodeObject(@Syntax("HOCON") String configText) throws IOException {
    return Jackson.defaultCodec().decodeObject(configText);
}
项目:codec    文件:CodecJackson.java   
/**
 * Instantiate an object without a compile time expected type. This expects a config of the
 * form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
 * key should be a valid, loaded, plug-in category.
 */
public <T> T decodeObject(@Syntax("HOCON") String configText) throws JsonProcessingException, IOException {
    Config config = ConfigFactory.parseString(configText).resolve();
    return decodeObject(config);
}