// Generated by delombok at Sun Feb 26 12:31:38 KST 2017 package scouter.bytebuddy.implementation.bytecode.assign; import scouter.bytebuddy.description.type.TypeDefinition; import scouter.bytebuddy.description.type.TypeDescription; import scouter.bytebuddy.implementation.Implementation; import scouter.bytebuddy.implementation.bytecode.StackManipulation; import scouter.bytebuddy.implementation.bytecode.StackSize; import scouter.bytebuddy.jar.asm.MethodVisitor; import scouter.bytebuddy.jar.asm.Opcodes; /** * A stack manipulation for a type down casting. Such castings are not implicit but must be performed explicitly. */ public class TypeCasting implements StackManipulation { /** * The type description to which a value should be casted. */ private final TypeDescription typeDescription; /** * Creates a new type casting. * * @param typeDescription The type description to which a value should be casted. */ protected TypeCasting(TypeDescription typeDescription) { this.typeDescription = typeDescription; } /** * Creates a casting to the given, non-primitive type. * * @param typeDefinition The type to which a value should be casted. * @return A stack manipulation that represents the casting. */ public static StackManipulation to(TypeDefinition typeDefinition) { if (typeDefinition.isPrimitive()) { throw new IllegalArgumentException("Cannot cast to primitive type: " + typeDefinition); } return new TypeCasting(typeDefinition.asErasure()); } @Override public boolean isValid() { return true; } @Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, typeDescription.getInternalName()); return StackSize.ZERO.toIncreasingSize(); } @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") public boolean equals(final java.lang.Object o) { if (o == this) return true; if (!(o instanceof TypeCasting)) return false; final TypeCasting other = (TypeCasting) o; if (!other.canEqual((java.lang.Object) this)) return false; final java.lang.Object this$typeDescription = this.typeDescription; final java.lang.Object other$typeDescription = other.typeDescription; if (this$typeDescription == null ? other$typeDescription != null : !this$typeDescription.equals(other$typeDescription)) return false; return true; } @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") protected boolean canEqual(final java.lang.Object other) { return other instanceof TypeCasting; } @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") public int hashCode() { final int PRIME = 59; int result = 1; final java.lang.Object $typeDescription = this.typeDescription; result = result * PRIME + ($typeDescription == null ? 43 : $typeDescription.hashCode()); return result; } }