/**
* Adds numeric value to serializer with padding. <br>
* Like setting padding to 3 and saving value of 35 will be saved as '035'
*
* @param key
* key of value.
* @param value
* value to serialize.
* @param padding
* padding to use.
* @param <T>
* type of object.
*
* @throws IllegalArgumentException
* when given number is floating point number.
*/
default <T extends Number> void addNumber(String key, @Nullable T value, @Signed int padding)
{
if (value == null)
{
this.add(key, null);
}
if (padding <= 0)
{
this.add(key, value);
return;
}
if ((value instanceof Float) || (value instanceof Double))
{
throw new IllegalArgumentException("Can't use padding for float or double!");
}
if (this.getSerializationType() == SerializationType.YAML) // yaml reads padded value as octal, so we need escape it
{
this.add(key, String.format("%0" + padding + "d", value), String.class);
return;
}
this.add(key, String.format("%0" + padding + "d", value));
}
java类javax.annotation.Signed的实例源码
SerializationData.java 文件源码
项目:diorite-configs-java8
阅读 22
收藏 0
点赞 0
评论 0
SerializationData.java 文件源码
项目:Diorite
阅读 29
收藏 0
点赞 0
评论 0
/**
* Adds numeric value to serializer with padding. <br>
* Like setting padding to 3 and saving value of 35 will be saved as '035'
*
* @param key
* key of value.
* @param value
* value to serialize.
* @param padding
* padding to use.
* @param <T>
* type of object.
*
* @throws IllegalArgumentException
* when given number is floating point number.
*/
default <T extends Number> void addNumber(String key, @Nullable T value, @Signed int padding)
{
if (value == null)
{
this.add(key, null);
}
if (padding <= 0)
{
this.add(key, value);
return;
}
if ((value instanceof Float) || (value instanceof Double))
{
throw new IllegalArgumentException("Can't use padding for float or double!");
}
if (this.getSerializationType() == SerializationType.YAML) // yaml reads padded value as octal, so we need escape it
{
this.add(key, String.format("%0" + padding + "d", value), String.class);
return;
}
this.add(key, String.format("%0" + padding + "d", value));
}
JDBCDriver.java 文件源码
项目:jactiverecord
阅读 28
收藏 0
点赞 0
评论 0
/**
* @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" : "");
}
SerializationData.java 文件源码
项目:diorite-configs-java8
阅读 27
收藏 0
点赞 0
评论 0
/**
* Adds numeric value to serializer as hex value (like 0xABCDEF), it must be later read back by proper function in {@link DeserializationData}.
* <br>
* You can also set custom padding value, so values like 0xff, will be saved as 0x0000ff (padding = 6)
*
* @param key
* key of value.
* @param value
* value to serialize.
* @param padding
* padding to use.
* @param <T>
* type of object.
*
* @throws IllegalArgumentException
* when given number is floating point number.
*/
default <T extends Number> void addHexNumber(String key, @Nullable T value, @Signed int padding)
{
if (value == null)
{
this.add(key, null);
}
if ((value instanceof Float) || (value instanceof Double))
{
throw new IllegalArgumentException("Can't use hex values for float or double!");
}
this.add(key, String.format("0x%0" + padding + "x", value));
}
SerializationData.java 文件源码
项目:Diorite
阅读 25
收藏 0
点赞 0
评论 0
/**
* Adds numeric value to serializer as hex value (like 0xABCDEF), it must be later read back by proper function in {@link DeserializationData}.
* <br>
* You can also set custom padding value, so values like 0xff, will be saved as 0x0000ff (padding = 6)
*
* @param key
* key of value.
* @param value
* value to serialize.
* @param padding
* padding to use.
* @param <T>
* type of object.
*
* @throws IllegalArgumentException
* when given number is floating point number.
*/
default <T extends Number> void addHexNumber(String key, @Nullable T value, @Signed int padding)
{
if (value == null)
{
this.add(key, null);
}
if ((value instanceof Float) || (value instanceof Double))
{
throw new IllegalArgumentException("Can't use hex values for float or double!");
}
this.add(key, String.format("0x%0" + padding + "x", value));
}
Server.java 文件源码
项目:Basin
阅读 42
收藏 0
点赞 0
评论 0
/**
* Retrieves the maximum amount a server is allowed to wait for a single tick to process
* before assuming the server is hanging.
*
* A value of -1 indicates, that the watchdog shall not shutdown the server regardless of
* how long a tick needs to process.
*/
@Signed
long getMaximumTickTime();
Server.java 文件源码
项目:Basin
阅读 35
收藏 0
点赞 0
评论 0
/**
* Retrieves the threshold at which plugins will be compressed.
*
* @return a threshold in bytes.
*/
@Signed
int getNetworkCompressionThreshold();
Server.java 文件源码
项目:Faucet
阅读 34
收藏 0
点赞 0
评论 0
/**
* Retrieves the maximum amount a server is allowed to wait for a single tick to process
* before assuming the server is hanging.
*
* A value of -1 indicates, that the watchdog shall not shutdown the server regardless of
* how long a tick needs to process.
*/
@Signed
long getMaximumTickTime();
Server.java 文件源码
项目:Faucet
阅读 30
收藏 0
点赞 0
评论 0
/**
* Retrieves the threshold at which plugins will be compressed.
*
* @return a threshold in bytes.
*/
@Signed
int getNetworkCompressionThreshold();
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 58
收藏 0
点赞 0
评论 0
/**
* Calculates the sum of the column-values by casting all single column-values to long
*
* @param <C> the type of the column-value
* @param columnName the name of the column to sum the values
* @param columnFunc the function mapping the record to its column-value
* @return the sum of all the column-values
*/
@Signed
public default <C extends Number> long sum(@Nonnull final String columnName, @Nonnull final Function<T, C> columnFunc)
{
return Objects.requireNonNull( aggregate( new Sum<>(columnName, columnFunc), null)).longValue();
}
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 30
收藏 0
点赞 0
评论 0
/**
* Calculates the sum of the column-values by casting all single column-values to long
*
* @param <C> the type of the column-value
* @param func the SQL-function mapping the record to a value
* @return the sum of all the column-values
* @since 0.8
*/
@Signed
public default <C extends Number> long sum(@Nonnull final SQLFunction<T, C> func)
{
return Objects.requireNonNull( aggregate( new Sum<>(func), null)).longValue();
}
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 33
收藏 0
点赞 0
评论 0
/**
* Calculates the sum of the column-values by casting all single column-values to double
*
* @param <C> the type of the column-value
* @param columnName the name of the column to sum its values
* @param columnFunc the function mapping the record to its column-value
* @return the sum of all the column-values
*/
@Signed
public default <C extends Number> double sumFloating(@Nonnull final String columnName, @Nonnull final Function<T, C> columnFunc)
{
return Objects.requireNonNull( aggregate( new SumDouble<>(columnName, columnFunc), null)).doubleValue();
}
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 25
收藏 0
点赞 0
评论 0
/**
* Calculates the sum of the column-values by casting all single column-values to double
*
* @param <C> the type of the column-value
* @param func the SQL-function mapping the record to a value
* @return the sum of all the column-values
* @since 0.8
*/
@Signed
public default <C extends Number> double sumFloating(@Nonnull final SQLFunction<T, C> func)
{
return Objects.requireNonNull( aggregate( new SumDouble<>(func), null)).doubleValue();
}
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 23
收藏 0
点赞 0
评论 0
/**
* Calculates the average column-value
* @param <C> the type of the column-value
* @param columnName the name of the column to retrieve the average value
* @param columnFunc the function mapping the record to its column-value
* @return the average column-value
*/
@Signed
public default <C extends Number> double average(@Nonnull final String columnName, @Nonnull final Function<T, C> columnFunc)
{
return Objects.requireNonNull( aggregate( new Average<>(columnName, columnFunc), null)).doubleValue();
}
AggregateMethods.java 文件源码
项目:jactiverecord
阅读 32
收藏 0
点赞 0
评论 0
/**
* Calculates the average column-value
* @param <C> the type of the column-value
* @param func the SQL-function mapping the record to a value
* @return the average column-value
* @since 0.8
*/
@Signed
public default <C extends Number> double average(@Nonnull final SQLFunction<T, C> func)
{
return Objects.requireNonNull( aggregate( new Average<>(func), null)).doubleValue();
}