com.maxifier.mxcache.transform.BoxTransformGenerator 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.asm.Type;
import com.maxifier.mxcache.asm.commons.GeneratorAdapter;
import com.maxifier.mxcache.util.ClassGenerator;
import javax.annotation.Nonnull;
/**
* @author Alexander Kochurov ([email protected])
*/
public class BoxTransformGenerator extends ScalarTransformGenerator {
private final Type type;
public BoxTransformGenerator(@Nonnull Type type) {
this.type = type;
}
@Override
public void generateForward(Type thisType, int fieldIndex, GeneratorAdapter method) {
method.box(type);
}
@Override
public void generateBackward(Type thisType, int fieldIndex, GeneratorAdapter method) {
method.unbox(type);
}
@Override
public void generateFields(Type thisType, int fieldIndex, ClassGenerator writer) {
}
@Override
public void generateAcquire(Type thisType, int fieldIndex, GeneratorAdapter ctor, int contextLocal) {
}
@Override
public int getFieldCount() {
return 0;
}
@Override
public Class getTransformedType(Class in) {
return Object.class;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BoxTransformGenerator that = (BoxTransformGenerator) o;
return type.equals(that.type);
}
@Override
public int hashCode() {
return type.hashCode();
}
@Override
public String toString() {
return "box " + type.getClassName();
}
}