1 /*
2 ORG Usurper is a random value object generator library
3 Copyright (C) 2007 Pierre-Antoine Grégoire
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 package org.org.usurper.handlers.defaults;
21
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import org.org.usurper.handlers.basic.AbstractPropertyTypeHandler;
26 import org.org.usurper.model.HandledBeanProperty;
27 import org.org.usurper.model.HandledConstructorArg;
28 import org.org.usurper.model.PropertyTypeDefinition;
29 import org.org.usurper.utils.RandomUtils;
30
31 /**
32 * This handler returns a random Byte value.<br>
33 * It handles the Byte type and the primitive byte type.
34 * @author pagregoire
35 */
36 public class BytePropertyTypeHandler extends AbstractPropertyTypeHandler {
37
38 /** The handled types. */
39 private static Set<PropertyTypeDefinition> handledTypes;
40 static {
41 handledTypes = new HashSet<PropertyTypeDefinition>();
42 handledTypes.add(new PropertyTypeDefinition(Byte.class));
43 handledTypes.add(new PropertyTypeDefinition(byte.class));
44 }
45
46
47 /**
48 * Instantiates a new Byte property type handler.
49 */
50 public BytePropertyTypeHandler() {
51 super(handledTypes);
52 }
53
54 /**
55 * @see org.org.usurper.handlers.IHandler#handle(org.org.usurper.model.HandledBeanProperty)
56 */
57 public Object handle(HandledBeanProperty handledBeanProperty) {
58 return RandomUtils.nextByte();
59 }
60
61 /**
62 * @see org.org.usurper.handlers.IHandler#handle(org.org.usurper.model.HandledConstructorArg)
63 */
64 public Object handle(HandledConstructorArg handledConstructorArg) {
65 return RandomUtils.nextByte();
66 }
67 }