// Generated by delombok at Sun Feb 26 12:31:38 KST 2017 package scouter.bytebuddy.implementation.bytecode.assign.primitive; import scouter.bytebuddy.description.type.TypeDescription; import scouter.bytebuddy.implementation.bytecode.Removal; import scouter.bytebuddy.implementation.bytecode.StackManipulation; import scouter.bytebuddy.implementation.bytecode.assign.Assigner; import scouter.bytebuddy.implementation.bytecode.constant.DefaultValue; /** * This assigner is able to handle the {@code void} type. This means: * <ol> * <li>If a {@code void} type is assigned to the {@code void} it will consider this a trivial operation.</li> * <li>If a {@code void} type is assigned to a non-{@code void} type, it will pop the top value from the stack.</li> * <li>If a non-{@code void} type is assigned to a {@code void} type, it will load the target type's default value * only if this was configured at the assigner's construction.</li> * <li>If two non-{@code void} types are subject of the assignment, it will delegate the assignment to its chained * assigner.</li> * </ol> */ public class VoidAwareAssigner implements Assigner { /** * An assigner that is capable of handling assignments that do not involve {@code void} types. */ private final Assigner chained; /** * Creates a new assigner that is capable of handling void types. * * @param chained A chained assigner which will be queried by this assigner to handle assignments that * do not involve a {@code void} type. */ public VoidAwareAssigner(Assigner chained) { this.chained = chained; } @Override public StackManipulation assign(TypeDescription.Generic source, TypeDescription.Generic target, Typing typing) { if (source.represents(void.class) && target.represents(void.class)) { return StackManipulation.Trivial.INSTANCE; } else if (source.represents(void.class) /* && target != void.class */) { return typing.isDynamic() ? DefaultValue.of(target) : StackManipulation.Illegal.INSTANCE; } else if (/* source != void.class && */ target.represents(void.class)) { return Removal.of(source); } else /* source != void.class && target != void.class */ { return chained.assign(source, target, typing); } } @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 VoidAwareAssigner)) return false; final VoidAwareAssigner other = (VoidAwareAssigner) o; if (!other.canEqual((java.lang.Object) this)) return false; final java.lang.Object this$chained = this.chained; final java.lang.Object other$chained = other.chained; if (this$chained == null ? other$chained != null : !this$chained.equals(other$chained)) return false; return true; } @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") protected boolean canEqual(final java.lang.Object other) { return other instanceof VoidAwareAssigner; } @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 $chained = this.chained; result = result * PRIME + ($chained == null ? 43 : $chained.hashCode()); return result; } }