当前位置: 首页>>代码示例>>Java>>正文


Java BeanUtil.isIntegralNumberType方法代码示例

本文整理汇总了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);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:23,代码来源:RandomSequence.java

示例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);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:18,代码来源:StepSequence.java

示例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);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:17,代码来源:ShuffleSequence.java

示例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++;
  }
 }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:35,代码来源:XLSEntityExporter.java

示例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);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:14,代码来源:AbstractWeightFunction.java

示例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);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:16,代码来源:CumulatedSequence.java

示例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);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:12,代码来源:RandomWalkSequence.java


注:本文中的org.databene.commons.BeanUtil.isIntegralNumberType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。