net.bytebuddy.modifier.SynchronizationState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of byte-buddy Show documentation
Show all versions of byte-buddy Show documentation
Byte Buddy is a Java library for creating Java classes at run time.
This artifact is a build of Byte Buddy with all ASM dependencies repackaged into its own name space.
package net.bytebuddy.modifier;
import net.bytebuddy.instrumentation.ModifierContributor;
import net.bytebuddy.jar.asm.Opcodes;
/**
* Describes if a method is supposed to be synchronized.
*/
public enum SynchronizationState implements ModifierContributor.ForMethod {
/**
* Modifier for non-synchronized method. (This is the default modifier.)
*/
PLAIN(EMPTY_MASK),
/**
* Modifier for a synchronized method.
*/
SYNCHRONIZED(Opcodes.ACC_SYNCHRONIZED);
/**
* The mask the modifier contributor.
*/
private final int mask;
/**
* Creates a new synchronization state representation.
*
* @param mask The modifier mask of this instance.
*/
private SynchronizationState(int mask) {
this.mask = mask;
}
/**
* Creates a synchronization state from a boolean value indicating if a method is supposed to be synchronized.
*
* @param isSynchronized {@code true} if the state is supposed to be synchronized.
* @return The corresponding synthetic state.
*/
public static SynchronizationState is(boolean isSynchronized) {
return isSynchronized ? SYNCHRONIZED : PLAIN;
}
@Override
public int getMask() {
return mask;
}
/**
* Checks if the current state describes the synchronized state.
*
* @return {@code true} if the current state is synchronized.
*/
public boolean isSynchronized() {
return this == SYNCHRONIZED;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy