/** * Creates addition value. * * @return An addition value. */ @SuppressWarnings("rawtypes") protected Object createAdditionValue() { String type = (String) pop(2); Value summand1 = (Value) pop(1); Value summand2 = (Value) pop(); switch (type) { case "byte": return new AdditionValueByte(summand1, summand2); case "short": return new AdditionValueShort(summand1, summand2); case "int": return new AdditionValueInteger(summand1, summand2); case "long": return new AdditionValueLong(summand1, summand2); case "float": return new AdditionValueFloat(summand1, summand2); case "double": return new AdditionValueDouble(summand1, summand2); default: throw new RuntimeException("Unsupported type for addition value. Type: " + type); } }
/** * Creates subtraction value. * * @return An subtraction value. */ @SuppressWarnings("rawtypes") protected Object createSubtractionValue() { String type = (String) pop(2); Value minuend = (Value) pop(1); Value subtrahend = (Value) pop(); switch (type) { case "byte": return new SubtractionValueByte(minuend, subtrahend); case "short": return new SubtractionValueShort(minuend, subtrahend); case "int": return new SubtractionValueInteger(minuend, subtrahend); case "long": return new SubtractionValueLong(minuend, subtrahend); case "float": return new SubtractionValueFloat(minuend, subtrahend); case "double": return new SubtractionValueDouble(minuend, subtrahend); default: throw new RuntimeException("Unsupported type for subtraction value. Type: " + type); } }
/** * Creates multiplication value. * * @return An multiplication value. */ @SuppressWarnings("rawtypes") protected Object createMultiplicationValue() { String type = (String) pop(2); Value factor1 = (Value) pop(1); Value factor2 = (Value) pop(); switch (type) { case "byte": return new MultiplicationValueByte(factor1, factor2); case "short": return new MultiplicationValueShort(factor1, factor2); case "int": return new MultiplicationValueInteger(factor1, factor2); case "long": return new MultiplicationValueLong(factor1, factor2); case "float": return new MultiplicationValueFloat(factor1, factor2); case "double": return new MultiplicationValueDouble(factor1, factor2); default: throw new RuntimeException("Unsupported type for multplication value. Type: " + type); } }
/** * Creates division value. * * @return An division value. */ @SuppressWarnings("rawtypes") protected Object createDivisionValue() { String type = (String) pop(2); Value dividend = (Value) pop(1); Value divisor = (Value) pop(); switch (type) { case "byte": return new DivisionValueByte(dividend, divisor); case "short": return new DivisionValueShort(dividend, divisor); case "int": return new DivisionValueInteger(dividend, divisor); case "long": return new DivisionValueLong(dividend, divisor); case "float": return new DivisionValueFloat(dividend, divisor); case "double": return new DivisionValueDouble(dividend, divisor); default: throw new RuntimeException("Unsupported type for division value. Type: " + type); } }
/** * Creates addition value. * * @return An addition value. */ @SuppressWarnings("rawtypes") protected Object createAdditionValue() { String type = (String) pop(2); Value summand1 = (Value) pop(1); Value summand2 = (Value) pop(); switch (type) { case "byte": return new AdditionValueByte(summand1, summand2); case "short": return new AdditionValueShort(summand1, summand2); case "int": return new AdditionValueInteger(summand1, summand2); case "long": return new AdditionValueLong(summand1, summand2); case "float": return new AdditionValueFloat(summand1, summand2); case "double": return new AdditionValueDouble(summand1, summand2); default: throw new RuntimeException("Unsupported type for addition value. Type: " + type); } }
/** * Creates subtraction value. * * @return An subtraction value. */ @SuppressWarnings("rawtypes") protected Object createSubtractionValue() { String type = (String) pop(2); Value minuend = (Value) pop(1); Value subtrahend = (Value) pop(); switch (type) { case "byte": return new SubtractionValueByte(minuend, subtrahend); case "short": return new SubtractionValueShort(minuend, subtrahend); case "int": return new SubtractionValueInteger(minuend, subtrahend); case "long": return new SubtractionValueLong(minuend, subtrahend); case "float": return new SubtractionValueFloat(minuend, subtrahend); case "double": return new SubtractionValueDouble(minuend, subtrahend); default: throw new RuntimeException("Unsupported type for subtraction value. Type: " + type); } }
/** * Creates multiplication value. * * @return An multiplication value. */ @SuppressWarnings("rawtypes") protected Object createMultiplicationValue() { String type = (String) pop(2); Value factor1 = (Value) pop(1); Value factor2 = (Value) pop(); switch (type) { case "byte": return new MultiplicationValueByte(factor1, factor2); case "short": return new MultiplicationValueShort(factor1, factor2); case "int": return new MultiplicationValueInteger(factor1, factor2); case "long": return new MultiplicationValueLong(factor1, factor2); case "float": return new MultiplicationValueFloat(factor1, factor2); case "double": return new MultiplicationValueDouble(factor1, factor2); default: throw new RuntimeException("Unsupported type for multplication value. Type: " + type); } }
/** * Creates division value. * * @return An division value. */ @SuppressWarnings("rawtypes") protected Object createDivisionValue() { String type = (String) pop(2); Value dividend = (Value) pop(1); Value divisor = (Value) pop(); switch (type) { case "byte": return new DivisionValueByte(dividend, divisor); case "short": return new DivisionValueShort(dividend, divisor); case "int": return new DivisionValueInteger(dividend, divisor); case "long": return new DivisionValueLong(dividend, divisor); case "float": return new DivisionValueFloat(dividend, divisor); case "double": return new DivisionValueDouble(dividend, divisor); default: throw new RuntimeException("Unsupported type for division value. Type: " + type); } }
/** * Creates an instance of {@link ObjectGenerator} which adds up values of given object generators. * * @param type Type object generator will return. * @param summand1 First object generator for addition. * @param summand2 Second object generator for addition. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which adds up values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> add(Class<T> type, ObjectGenerator<T> summand1, ObjectGenerator<T> summand2) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueByte(summand1.value, summand2.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueShort(summand1.value, summand2.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueInteger(summand1.value, summand2.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueLong(summand1.value, summand2.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueFloat(summand1.value, summand2.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueDouble(summand1.value, summand2.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which subtracts values of given object generators. * * @param type Type object generator will return. * @param minuend Object generator which will be used as minuend. * @param subtrahend Object generator which will be used as subtrahend * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which subtracts values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> subtract(Class<T> type, ObjectGenerator<T> minuend, ObjectGenerator<T> subtrahend) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueByte(minuend.value, subtrahend.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueShort(minuend.value, subtrahend.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueInteger(minuend.value, subtrahend.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueLong(minuend.value, subtrahend.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueFloat(minuend.value, subtrahend.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueDouble(minuend.value, subtrahend.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which multiplies values of given object generators. * * @param type Type object generator will return. * @param factor1 First object generator for multiplication. * @param factor2 Second object generator for multiplication. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which multiplies values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> multiply(Class<T> type, ObjectGenerator<T> factor1, ObjectGenerator<T> factor2) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueByte(factor1.value, factor2.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueShort(factor1.value, factor2.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueInteger(factor1.value, factor2.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueLong(factor1.value, factor2.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueFloat(factor1.value, factor2.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueDouble(factor1.value, factor2.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which divides values of given object generators. * * @param type Type object generator will return. * @param dividend Object generator which will be used as dividend. * @param divisor Object generator which will be used as divisor. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which divides values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> divide(Class<T> type, ObjectGenerator<T> dividend, ObjectGenerator<T> divisor) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueByte(dividend.value, divisor.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueShort(dividend.value, divisor.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueInteger(dividend.value, divisor.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueLong(dividend.value, divisor.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueFloat(dividend.value, divisor.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueDouble(dividend.value, divisor.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which adds up values of given object generators. * * @param type Type object generator will return. * @param summand1 First object generator for addition. * @param summand2 Second object generator for addition. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which adds up values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> add(Class<T> type, ObjectGenerator<T> summand1, ObjectGenerator<T> summand2) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueByte(summand1.value, summand2.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueShort(summand1.value, summand2.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueInteger(summand1.value, summand2.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueLong(summand1.value, summand2.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueFloat(summand1.value, summand2.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new AdditionValueDouble(summand1.value, summand2.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which subtracts values of given object generators. * * @param type Type object generator will return. * @param minuend Object generator which will be used as minuend. * @param subtrahend Object generator which will be used as subtrahend * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which subtracts values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> subtract(Class<T> type, ObjectGenerator<T> minuend, ObjectGenerator<T> subtrahend) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueByte(minuend.value, subtrahend.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueShort(minuend.value, subtrahend.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueInteger(minuend.value, subtrahend.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueLong(minuend.value, subtrahend.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueFloat(minuend.value, subtrahend.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new SubtractionValueDouble(minuend.value, subtrahend.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which multiplies values of given object generators. * * @param type Type object generator will return. * @param factor1 First object generator for multiplication. * @param factor2 Second object generator for multiplication. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which multiplies values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> multiply(Class<T> type, ObjectGenerator<T> factor1, ObjectGenerator<T> factor2) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueByte(factor1.value, factor2.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueShort(factor1.value, factor2.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueInteger(factor1.value, factor2.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueLong(factor1.value, factor2.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueFloat(factor1.value, factor2.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new MultiplicationValueDouble(factor1.value, factor2.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }
/** * Creates an instance of {@link ObjectGenerator} which divides values of given object generators. * * @param type Type object generator will return. * @param dividend Object generator which will be used as dividend. * @param divisor Object generator which will be used as divisor. * @param <T> Type object generator will return. * @return An instance of {@link ObjectGenerator} which divides values of given object generators. */ @SuppressWarnings("unchecked") public static <T> ObjectGenerator<T> divide(Class<T> type, ObjectGenerator<T> dividend, ObjectGenerator<T> divisor) { if (type.equals(Byte.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueByte(dividend.value, divisor.value)); } else if (type.equals(Short.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueShort(dividend.value, divisor.value)); } else if (type.equals(Integer.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueInteger(dividend.value, divisor.value)); } else if (type.equals(Long.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueLong(dividend.value, divisor.value)); } else if (type.equals(Float.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueFloat(dividend.value, divisor.value)); } else if (type.equals(Double.class)) { return (ObjectGenerator<T>) wrap(new DivisionValueDouble(dividend.value, divisor.value)); } else { throw new RuntimeException("Type: " + type.getName() + " not supported."); } }