1 package com.google.code.beanmatchers;
2
3 import java.nio.ByteBuffer;
4 import java.util.Random;
5
6 class ShortGenerator implements ValueGenerator<Short> {
7
8 private final Random random;
9
10 public ShortGenerator(Random random) {
11 this.random = random;
12 }
13
14 public Short generate() {
15 byte[] bytes = new byte[2];
16 random.nextBytes(bytes);
17 ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
18 return byteBuffer.getShort();
19 }
20 }