Package codechicken.mixin.api
Interface MixinFactory<B,F>
- All Known Implementing Classes:
MixinFactoryImpl,SidedFactory
public interface MixinFactory<B,F>
Represents a 'user' facing interface for interacting and caching the
MixinCompiler.
Created by covers1624 on 2/17/20.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordUnique key representing a registered trait. -
Method Summary
Modifier and TypeMethodDescriptionconstruct(com.google.common.collect.ImmutableSet<MixinFactory.TraitKey> traits) Returns a factory (MixinFactory) capable of constructing a newMixinFactorywith the given set of traits applied.Gets the associated MixinCompiler for this MixinFactory.com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>getTraitsForClass(Class<?> clazz) Gets the traits that were used in compiling the given class.registerTrait(Class<?> tClass) Registers a trait.registerTrait(org.objectweb.asm.tree.ClassNode cNode) Registers a binary trait.
-
Method Details
-
getMixinCompiler
MixinCompiler getMixinCompiler()Gets the associated MixinCompiler for this MixinFactory.- Returns:
- The MixinCompiler.
-
registerTrait
Registers a trait.- Parameters:
tClass- The trait class.- Returns:
- a TraitKey for using this registered trait.
-
registerTrait
Registers a binary trait. Used for traits which are generated at runtime.- Parameters:
cNode- TheClassNodefor the trait.- Returns:
- a TraitKey for using this registered trait.
-
construct
Returns a factory (MixinFactory) capable of constructing a newMixinFactorywith the given set of traits applied.The MixinFactory will cache constructed classes with the given set of traits, subsequent calls with the same traits will not cause a new class to be generated.
It should be noted that,
ImmutableSetis explicitly used here, as their hashCode is statically computed, making it favourable for use as a key in a Map.- Parameters:
traits- The traits to apply.- Returns:
- The Factory.
-
getTraitsForClass
Gets the traits that were used in compiling the given class. If the given class was not compiled by this factory, simply returns null.- Parameters:
clazz- The Class to get the traits for.- Returns:
- The classes traits, or null if it was not compiled by this factory.
-