本文整理汇总了Java中org.databene.commons.BeanUtil.isIntegralNumberType方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtil.isIntegralNumberType方法的具体用法?Java BeanUtil.isIntegralNumberType怎么用?Java BeanUtil.isIntegralNumberType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.databene.commons.BeanUtil
的用法示例。
在下文中一共展示了BeanUtil.isIntegralNumberType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(Class<T> numberType, T min, T max, T granularity, boolean unique) {
NonNullGenerator<? extends Number> base;
if (unique) {
return SequenceManager.EXPAND_SEQUENCE.createNumberGenerator(numberType, min, max, granularity, unique);
} else if (BeanUtil.isIntegralNumberType(numberType)) {
long lMax = (max != null ? max.longValue() :
Math.min(RandomLongGenerator.DEFAULT_MAX, NumberUtil.maxValue(numberType).longValue()));
if (Integer.class.equals(numberType.getClass()))
base = new RandomIntegerGenerator(toInteger(min), toInteger(lMax), toInteger(granularity));
else if (BigInteger.class.equals(numberType.getClass()))
base = new RandomBigIntegerGenerator(toBigInteger(min), toBigInteger(lMax), toBigInteger(granularity));
else if (BigDecimal.class.equals(numberType.getClass()))
base = new RandomBigDecimalGenerator(toBigDecimal(min), toBigDecimal(lMax), toBigDecimal(granularity));
else
base = new RandomLongGenerator(toLong(min), lMax, toLong(granularity));
} else {
double dMax = (max != null ? max.doubleValue() : Long.MAX_VALUE);
base = new RandomDoubleGenerator(toDouble(min), dMax, toDouble(granularity));
}
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
示例2: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(
Class<T> numberType, T min, T max, T granularity, boolean unique) {
Number deltaToUse = deltaToUse(granularity);
if (unique && deltaToUse.doubleValue() == 0)
throw new InvalidGeneratorSetupException("Can't generate unique numbers with an increment of 0.");
NonNullGenerator<? extends Number> base;
if (BeanUtil.isIntegralNumberType(numberType)) {
if (max == null)
max = NumberUtil.maxValue(numberType);
base = new StepLongGenerator(
toLong(min), toLong(max), toLong(deltaToUse), toLong(initial));
} else
base = new StepDoubleGenerator(
toDouble(min), toDouble(max), toDouble(deltaToUse), toDouble(initial));
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
示例3: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(
Class<T> numberType, T min, T max, T granularity, boolean unique) {
if (increment == null)
increment = BigDecimal.valueOf(2);
if (max == null)
max = NumberUtil.maxValue(numberType);
NonNullGenerator<? extends Number> base;
if (BeanUtil.isIntegralNumberType(numberType))
base = new ShuffleLongGenerator(
toLong(min), toLong(max), toLong(granularity), toLong(increment));
else
base = new ShuffleDoubleGenerator(
toDouble(min), toDouble(max), toDouble(granularity), toDouble(increment));
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
示例4: writeHeaderRow
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private void writeHeaderRow(Entity entity, HSSFSheet sheet) {
HSSFRow headerRow = sheet.createRow(0);
int colnum = 0;
for (Map.Entry<String, Object> component : getComponents(entity)) {
String componentName = component.getKey();
headerRow.createCell(colnum).setCellValue(new HSSFRichTextString(componentName));
ComponentDescriptor cd = entity.descriptor().getComponent(componentName);
PrimitiveType primitiveType;
if (cd.getTypeDescriptor() instanceof SimpleTypeDescriptor)
primitiveType = ((SimpleTypeDescriptor) cd.getTypeDescriptor()).getPrimitiveType();
else
throw new UnsupportedOperationException("Can only export simple type attributes, " +
"failed to export " + entity.type() + '.' + cd.getName());
Class<?> javaType = (primitiveType != null ? primitiveType.getJavaType() : String.class);
String formatString = null;
if (BeanUtil.isIntegralNumberType(javaType))
formatString = getIntegralPattern();
else if (BeanUtil.isDecimalNumberType(javaType))
formatString = getDecimalPattern();
else if (Time.class.isAssignableFrom(javaType))
formatString = getTimePattern();
else if (Timestamp.class.isAssignableFrom(javaType))
formatString = getTimestampPattern();
else if (Date.class.isAssignableFrom(javaType))
formatString = getDatePattern();
if (formatString != null) {
HSSFDataFormat dataFormat = workbook.createDataFormat();
CellStyle columnStyle = workbook.createCellStyle();
columnStyle.setDataFormat(dataFormat.getFormat(formatString));
sheet.setDefaultColumnStyle(colnum, columnStyle);
}
colnum++;
}
}
示例5: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T extends Number> NonNullGenerator<T> createNumberGenerator(
Class<T> numberType, T min, T max, T granularity, boolean unique) {
if (Long.class.equals(numberType))
return (NonNullGenerator<T>) createLongGenerator(min, max, granularity);
else if (Double.class.equals(numberType))
return (NonNullGenerator<T>) createDoubleGenerator(min, max, granularity);
else if (BeanUtil.isIntegralNumberType(numberType))
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, createLongGenerator(min, max, granularity), min, granularity);
else
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, createDoubleGenerator(min, max, granularity), min, granularity);
}
示例6: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(Class<T> numberType, T min, T max, T granularity, boolean unique) {
if (unique)
throw new ConfigurationError(getClass().getSimpleName() + " does not support uniqueness");
NonNullGenerator<? extends Number> base;
if (BeanUtil.isIntegralNumberType(numberType)) {
long lMax = (max != null ? max.longValue() :
(numberType != Long.class && numberType != BigInteger.class ? NumberUtil.maxValue(numberType).longValue() : CumulatedLongGenerator.DEFAULT_MAX));
base = new CumulatedLongGenerator(toLong(min), lMax, toLong(granularity));
} else {
double dMax = (max != null ? max.doubleValue() : Long.MAX_VALUE);
base = new CumulatedDoubleGenerator(toDouble(min), dMax, toDouble(granularity));
}
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
示例7: createNumberGenerator
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(Class<T> numberType, T min, T max, T granularity, boolean unique) {
if (max == null)
max = NumberUtil.maxValue(numberType);
NonNullGenerator<? extends Number> base;
if (BeanUtil.isIntegralNumberType(numberType))
base = createLongGenerator(toLong(min), toLong(max), toLong(granularity), unique);
else
base = createDoubleGenerator(toDouble(min), toDouble(max), toDouble(granularity), unique);
return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}