com.maxifier.mxcache.transform.ScalarTransformGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxcache-runtime Show documentation
Show all versions of mxcache-runtime Show documentation
Constains all classes necessary for launching a MxCache-instrumentated application
/*
* Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
*/
package com.maxifier.mxcache.transform;
import com.maxifier.mxcache.provider.Signature;
/**
* @author Alexander Kochurov ([email protected])
*/
public abstract class ScalarTransformGenerator implements TransformGenerator {
public abstract Class getTransformedType(Class in);
@Override
public Signature transformKey(Signature in) {
if (in.getContainer() == null) {
throw new IllegalArgumentException("Cannot transform signature without key!");
}
int keyCount = in.getKeyCount();
if (keyCount != 1) {
throw new UnsupportedOperationException("Scalar transform cannot be applied to tuple");
}
return in.overrideKey(getTransformedType(in.getKey(0)));
}
@Override
public Signature transformValue(Signature in) {
return in.overrideValue(getTransformedType(in.getValue()));
}
}