Transform an object
in to another object

@param input the record to transform
@return the transformed writable
163034
@Override
    public Object map(Object input) {
        Number n = (Number) input;
        double val = n.doubleValue();
        if (Double.isNaN(val))
            return new DoubleWritable(0);
        return ratio * (val - min) + newMin;
    }
365419
@Override
    public Object map(Object input) {
        List<Long> list = (List<Long>) input;
        switch (mathOp) {
            case Add:
                long sum = 0;
                for (Long w : list)
                    sum += w;
                return new LongWritable(sum);
            case Subtract:
                return list.get(0) - list.get(1);
            case Multiply:
                long product = 1;
                for (Long w : list)
                    product *= w;
                return product;
            case Divide:
                return list.get(0) / list.get(1);
            case Modulus:
                return list.get(0) % list.get(1);
            case ReverseSubtract:
            case ReverseDivide:
            case ScalarMin:
            case ScalarMax:
            default:
                throw new RuntimeException("Invalid mathOp: " + mathOp); //Should never happen
        }
    }
653921
public static GrayS32 transform(GrayU8 input , GrayS32 transformed ) {
		transformed = InputSanityCheck.checkDeclare(input,transformed,GrayS32.class);

		ImplIntegralImageOps.transform(input,transformed);

		return transformed;
	}
413141
private static Serializable jsonObjectToSerializableType(JSONObject input) {
		String type = input.optString(Apptentive.Version.KEY_TYPE, null);
		try {
			if (type != null) {
				if (type.equals(Apptentive.Version.TYPE)) {
					return new Apptentive.Version(input);
				} else if (type.equals(Apptentive.DateTime.TYPE)) {
					return new Apptentive.DateTime(input);
				}
			}
		} catch (JSONException e) {
			ApptentiveLog.e(CONVERSATION, e, "Error migrating JSONObject.");
			logException(e);
		}
		return null;
	}
1045161
public Object transformObject(TransformationDescription description, Object source) throws InstantiationException,
        IllegalAccessException, ClassNotFoundException {
        return transformObject(description, source, null);
    }
618999
public Object transformObject(TransformationDescription description, Object source, Object target)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        checkNeededValues(description);
        Class<?> sourceClass = modelRegistry.loadModel(description.getSourceModel());
        Class<?> targetClass = modelRegistry.loadModel(description.getTargetModel());
        if (!sourceClass.isAssignableFrom(source.getClass())) {
            throw new IllegalArgumentException("The given source object does not match the given description");
        }
        this.source = source;
        if (target == null) {
            this.target = targetClass.newInstance();
        } else {
            this.target = target;
        }
        for (TransformationStep step : description.getTransformingSteps()) {
            performTransformationStep(step);
        }
        return this.target;
    }
27348
public MultiPolygonTo toTransferObject(MultiPolygon input) {
        MultiPolygonTo result = new MultiPolygonTo();
        double[][][][] coordinates = new double[input.getNumGeometries()][][][];
        for (int i = 0; i < input.getNumGeometries(); i++) {
            coordinates[i] = toTransferObject(input.getGeometryN(i)).getCoordinates();
        }
        result.setCoordinates(coordinates);
        result.setCrs(GeoJsonTo.createCrsTo("EPSG:" + input.getSRID()));
        return result;
    }
249022
function denormalizeImmutable(schema, input, unvisit) {
  return Object.keys(schema).reduce(function (object, key) {
    // Immutable maps cast keys to strings on write so we need to ensure
    // we're accessing them using string keys.
    var stringKey = '' + key;

    if (object.has(stringKey)) {
      return object.set(stringKey, unvisit(object.get(stringKey), schema[stringKey]));
    } else {
      return object;
    }
  }, input);
}
1109408
public Feature transform(Source input) throws TransformationException {
        if (input == null) {
            return null;
        } else {
            EntityClassReader reader = EntityClassReader.getClassReaderFor(input.getClass());
            try {
                return reader.asFeature(input);
            } catch (InvalidObjectReaderException e) {
                // Can't happen!
                throw new TransformationException("Transformation failed", e);
            }
        }
    }
1211734
public static <K, V1, V2> Iterable<Map.Entry<K, V2>> transformValues(
      Iterable<Map.Entry<K, V1>> input,
      final Function<? super V1, V2> valueTransformer) {
    return Iterables.transform(input, new Function<Entry<K, V1>, Entry<K, V2>>() {
      @Override
      public Entry<K, V2> apply(final Entry<K, V1> input) {
        return Maps.immutableEntry(input.getKey(), valueTransformer.apply(input.getValue()));
      }
    });
  }
950273
@Override
    public Object map(Object input) {
        String str = input.toString();
        if (exceptions.contains(str)) {
            return str;
        } else {
            return newValue;
        }
    }
543064
private static Object getObjectFromWritable(Writable writable)
            throws IllegalAccessException, InstantiationException, InvocationTargetException {
        Object object = null;

        if (writable instanceof NullWritable) {
            object = NullWritable.get();
        } else if (writable instanceof BooleanWritable) {
            object = ((BooleanWritable) writable).get();
        } else if (writable instanceof Text) {
            object = writable.toString();
        } else if (writable instanceof ByteWritable) {
            object = ((ByteWritable) writable).get();
        } else if (writable instanceof IntWritable) {
            object = ((IntWritable) writable).get();
        } else if (writable instanceof LongWritable) {
            object = ((LongWritable) writable).get();
        } else if (writable instanceof BytesWritable) {
            object = ((BytesWritable) writable).getBytes();
        } else if (writable instanceof DoubleWritable) {
            object = ((DoubleWritable) writable).get();
        } else if (writable instanceof FloatWritable) {
            object = ((FloatWritable) writable).get();
        } else {
            // TODO : do nothing
        }

        return object;
    }
186612
@Override
    public Object map(Object input) {
        Number n = (Number) input;
        double val = n.doubleValue();
        if (Double.isNaN(val))
            return new DoubleWritable(0);
        return normMean(val);
    }
491556
public static void transformSq(final GrayF32 input , final GrayF64 transformed )
	{
		int indexSrc = input.startIndex;
		int indexDst = transformed.startIndex;
		int end = indexSrc + input.width;

		double total = 0;
		for( ; indexSrc < end; indexSrc++ ) {
			float value = input.data[indexSrc];
			transformed.data[indexDst++] = total += value*value;
		}

		for( int y = 1; y < input.height; y++ ) {
			indexSrc = input.startIndex + input.stride*y;
			indexDst = transformed.startIndex + transformed.stride*y;
			int indexPrev = indexDst - transformed.stride;

			end = indexSrc + input.width;

			total = 0;
			for( ; indexSrc < end; indexSrc++ ) {
				float value = input.data[indexSrc];
				total +=  value*value;
				transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
			}
		}
	}
872680
public static Number transformNumber( Number input ) {
      if( input instanceof Float ){
         return new Double( input.toString() );
      }else if( input instanceof Short ){
         return new Integer( input.intValue() );
      }else if( input instanceof Byte ){
         return new Integer( input.intValue() );
      }else if( input instanceof Long ){
         Long max = new Long( Integer.MAX_VALUE );
         if( input.longValue() <= max.longValue() && input.longValue() >= Integer.MIN_VALUE ){
            return new Integer( input.intValue() );
         }
      }

      return input;
   }
908415
public List<Writable> transformRawStringsToInputList(List<String> values) {
        List<Writable> ret = new ArrayList<>();
        if (values.size() != initialSchema.numColumns())
            throw new IllegalArgumentException(
                    String.format("Number of values %d does not match the number of input columns %d for schema",
                            values.size(), initialSchema.numColumns()));
        for (int i = 0; i < values.size(); i++) {
            switch (initialSchema.getType(i)) {
                case String:
                    ret.add(new Text(values.get(i)));
                    break;
                case Integer:
                    ret.add(new IntWritable(Integer.parseInt(values.get(i))));
                    break;
                case Double:
                    ret.add(new DoubleWritable(Double.parseDouble(values.get(i))));
                    break;
                case Float:
                    ret.add(new FloatWritable(Float.parseFloat(values.get(i))));
                    break;
                case Categorical:
                    ret.add(new Text(values.get(i)));
                    break;
                case Boolean:
                    ret.add(new BooleanWritable(Boolean.parseBoolean(values.get(i))));
                    break;
                case Time:

                    break;
                case Long:
                    ret.add(new LongWritable(Long.parseLong(values.get(i))));
            }
        }
        return ret;
    }
985533
@Deprecated
  public static <InType, OutType> Iterable<OutType> applyOneToManyTransform(
      final Iterable<InType> input,
      final Function<? super InType, ? extends Iterable<OutType>> function) {
    return FluentIterable.from(input)
        .transformAndConcat(function);
  }