Package codechicken.mixin
Class MixinFactoryImpl<B,F>
java.lang.Object
codechicken.mixin.MixinFactoryImpl<B,F>
- All Implemented Interfaces:
MixinFactory<B,F>
- Direct Known Subclasses:
SidedFactory
Created by covers1624 on 2/17/20.
-
Nested Class Summary
Nested classes/interfaces inherited from interface codechicken.mixin.api.MixinFactory
MixinFactory.TraitKey -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>,Class<? extends B>> protected final Stringprotected final AtomicIntegerprotected final Map<com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>,F> protected final FactoryGeneratorprotected final MixinCompilerprotected final Map<String,MixinFactory.TraitKey> protected final Map<Class<?>,com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>> -
Constructor Summary
ConstructorsConstructorDescriptionMixinFactoryImpl(MixinCompiler mixinCompiler, Class<B> baseType, Class<F> factoryClass, String classSuffix) -
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.
-
Field Details
-
counter
-
classCache
protected final Map<com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>,Class<? extends B>> classCache -
factoryCache
-
traitLookup
protected final Map<Class<?>,com.google.common.collect.ImmutableSet<MixinFactory.TraitKey>> traitLookup -
registeredTraits
-
mixinCompiler
-
baseType
-
factoryClass
-
classSuffix
-
factoryGenerator
-
-
Constructor Details
-
MixinFactoryImpl
-
-
Method Details
-
getMixinCompiler
Description copied from interface:MixinFactoryGets the associated MixinCompiler for this MixinFactory.- Specified by:
getMixinCompilerin interfaceMixinFactory<B,F> - Returns:
- The MixinCompiler.
-
registerTrait
Description copied from interface:MixinFactoryRegisters a trait.- Specified by:
registerTraitin interfaceMixinFactory<B,F> - Parameters:
tClass- The trait class.- Returns:
- a TraitKey for using this registered trait.
-
registerTrait
Description copied from interface:MixinFactoryRegisters a binary trait. Used for traits which are generated at runtime.- Specified by:
registerTraitin interfaceMixinFactory<B,F> - Parameters:
cNode- TheClassNodefor the trait.- Returns:
- a TraitKey for using this registered trait.
-
construct
Description copied from interface:MixinFactoryReturns 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.- Specified by:
constructin interfaceMixinFactory<B,F> - Parameters:
traits- The traits to apply.- Returns:
- The Factory.
-
getTraitsForClass
public com.google.common.collect.ImmutableSet<MixinFactory.TraitKey> getTraitsForClass(Class<?> clazz) Description copied from interface:MixinFactoryGets the traits that were used in compiling the given class. If the given class was not compiled by this factory, simply returns null.- Specified by:
getTraitsForClassin interfaceMixinFactory<B,F> - Parameters:
clazz- The Class to get the traits for.- Returns:
- The classes traits, or null if it was not compiled by this factory.
-