@Override public <T> T next(InstanceType<T> instanceType, FixtureContract fixture) { try { if (instanceType.isCompatibleWith(Integer.class)) { return (T) Integer.valueOf(this.getNextRandom().intValue()); } else if (instanceType.isCompatibleWith(Short.class)) { return (T) Short.valueOf(getNextRandom().shortValue()); } else if (instanceType.isCompatibleWith(Long.class)) { return (T) getNextRandom(); } else if (instanceType.isCompatibleWith(Byte.class)) { return (T) Byte.valueOf(getNextRandom().byteValue()); } else if (instanceType.isCompatibleWith(Character.class)) { return (T) Character.valueOf(new String(new byte[] {getNextRandom().byteValue()}).charAt(0)); } return (T) this.getNextRandom(); } catch (Exception e) { throw new ObjectCreationException(instanceType, e); } }
@Override public <T> boolean appliesTo(InstanceType<T> instanceType) { return instanceType.isCompatibleWithAnyOf( Byte.class, Character.class, Integer.class, Long.class, Short.class); }