/** * 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 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 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 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); } }