lojix/state/src/main/com/thesett/aima/state/impl/JavaType.java
public T getRandomInstance() throws RandomInstanceNotSupportedException
    {
        Object result = null;

        // For basic Java types return the standard default value. For others, try the default constructor.
        switch (type)
        {
        case BOOLEAN:
            result = RANDOM.nextBoolean();
            break;

        case CHARACTER:
            result = (char) RANDOM.nextInt();
            break;

        case BYTE:
            result = (byte) RANDOM.nextInt();
            break;

        case SHORT:
            result = (short) RANDOM.nextInt();
            break;

        case INTEGER:
            result = RANDOM.nextInt();
            break;

        case LONG:
            result = RANDOM.nextLong();
            break;

        case FLOAT:
            result = RANDOM.nextFloat();
            break;

        case DOUBLE:
            result = RANDOM.nextDouble();
            break;

        case OTHER:
        default:

            if (String.class.equals(underlyingClass))
            {
                byte[] bytes = new byte[6];
                RANDOM.nextBytes(bytes);

                result = new String(bytes);
            }

            break;
        }

        if (result != null)
        {
            return (T) result;
        }
        else
        {
            throw new RandomInstanceNotSupportedException("Type does not support random instance creation.", null);
        }
    }
public T getRandomInstance() throws RandomInstanceNotSupportedException
    {
        Object result = null;

        // For basic Java types return the standard default value. For others, try the default constructor.
        switch (type)
        {
        case BOOLEAN:
            result = RANDOM.nextBoolean();
            break;

        case CHARACTER:
            result = (char) RANDOM.nextInt();
            break;

        case BYTE:
            result = (byte) RANDOM.nextInt();
            break;

        case SHORT:
            result = (short) RANDOM.nextInt();
            break;

        case INTEGER:
            result = RANDOM.nextInt();
            break;

        case LONG:
            result = RANDOM.nextLong();
            break;

        case FLOAT:
            result = RANDOM.nextFloat();
            break;

        case DOUBLE:
            result = RANDOM.nextDouble();
            break;

        case OTHER:
        default:

            if (String.class.equals(underlyingClass))
            {
                byte[] bytes = new byte[6];
                RANDOM.nextBytes(bytes);

                result = new String(bytes);
            }

            break;
        }

        if (result != null)
        {
            return (T) result;
        }
        else
        {
            throw new RandomInstanceNotSupportedException("Type does not support random instance creation.", null);
        }
    }
public T getRandomInstance ( ) throws RandomInstanceNotSupportedException { Object result = null ; // For basic Java types return the standard default value. For others, try the default constructor. switch ( type ) { case BOOLEAN : result = RANDOM . nextBoolean ( ) ; break ; case CHARACTER : result = ( char ) RANDOM . nextInt ( ) ; break ; case BYTE : result = ( byte ) RANDOM . nextInt ( ) ; break ; case SHORT : result = ( short ) RANDOM . nextInt ( ) ; break ; case INTEGER : result = RANDOM . nextInt ( ) ; break ; case LONG : result = RANDOM . nextLong ( ) ; break ; case FLOAT : result = RANDOM . nextFloat ( ) ; break ; case DOUBLE : result = RANDOM . nextDouble ( ) ; break ; case OTHER : default : if ( String . class . equals ( underlyingClass ) ) { byte [ ] bytes = new byte [ 6 ] ; RANDOM . nextBytes ( bytes ) ; result = new String ( bytes ) ; } break ; } if ( result != null ) { return ( T ) result ; } else { throw new RandomInstanceNotSupportedException ( "Type does not support random instance creation." , null ) ; } }
{@inheritDoc}
{