Conversation
…an not be resolved immediatly
| ASTCDAttribute attribute = ast; | ||
| String templateName = "methods.Set"; | ||
| if (getDecorationHelper().isSupplier(ast.getMCType())) { | ||
| // expose the unwrapped type (Supplier<X> -> X) in the setter parameter; the Supplier stays hidden |
There was a problem hiding this comment.
This may need another method:
one that allows one to set a supplier (for Lazy creation in, e.g., SymbolAdapters).
| }; | ||
|
|
||
|
|
||
| public static boolean shouldBeSupplied(String t) { |
There was a problem hiding this comment.
shouldBeSupplied -> shouldHaveSupplier/shouldBeAccessedViaSupplier/etc.
| import java.util.Arrays; | ||
|
|
||
|
|
||
| public class AccessAsSupplierTyps { |
There was a problem hiding this comment.
| public class AccessAsSupplierTyps { | |
| public class AccessAsSupplierTypes { |
| import java.util.Arrays; | ||
|
|
||
|
|
||
| public class AccessAsSupplierTyps { |
There was a problem hiding this comment.
needs documentation on what this class is for
|
|
||
| public class AccessAsSupplierTyps { | ||
|
|
||
| public static final String SUPPLIER_TYPE = "java.util.function.Supplier"; |
There was a problem hiding this comment.
does this need to be public?
| return; | ||
| } | ||
|
|
||
| String defaultValue; |
There was a problem hiding this comment.
the defaultValue is what comes after the =.
This is more like the defaultInitialization or simmilar?
| return ((ASTMCGenericType) type).getMCTypeArgumentList().get(0); | ||
| } | ||
|
|
||
| public ASTMCTypeArgument getReferenceTypeFromSupply(ASTMCType type) { |
There was a problem hiding this comment.
| public ASTMCTypeArgument getReferenceTypeFromSupply(ASTMCType type) { | |
| public ASTMCTypeArgument getReferenceTypeOfSupplier(ASTMCType type) { |
?
| return ((ASTMCGenericType) type).getMCTypeArgumentList().get(0); | ||
| } | ||
|
|
||
| public ASTMCType createSupplierTypeOf(ASTMCType inner) { |
There was a problem hiding this comment.
Would this fit more in the MCTypeFacade?
| @@ -21,11 +21,11 @@ public void setFunctionList(List<FunctionSymbol> methodList){ | |||
| } | |||
|
|
|||
| public List<SymTypeExpression> getSuperClassesOnly(){ | |||
| return superTypes; | |||
| return superTypes.get(); | |||
There was a problem hiding this comment.
prefer something like getSuperTypesList()
There was a problem hiding this comment.
Why do both methods return the same? Is this correct?
There was a problem hiding this comment.
... yes, kind-of.
It is questionable design wise,
but the idea is that we cannot distinguish between them for TypeSymbols,
so we simply return them all.
| } | ||
|
|
||
| public List<SymTypeExpression> getInterfaceList(){ | ||
| return superTypes; | ||
| return superTypes.get(); |
| public static <T, R> Supplier<R> map(Supplier<T> source, Function<? super T, ? extends R> mapper) { | ||
| return new ClearingMemorizer<>(() -> { | ||
| T value = source.get(); | ||
| return value == null ? null : mapper.apply(value); |
There was a problem hiding this comment.
why can the mapper not accept null?
| * Evaluates the wrapped supplier at most once and caches the result. Afterwards the | ||
| * supplier is released (and with it everything it captured, e.g. the JSON it deserializes from). | ||
| */ | ||
| public class ClearingMemorizer<T> implements Supplier<T> { |
There was a problem hiding this comment.
Why is it called Clearing? that is an internal detail.
| /** | ||
| * Wraps the type of every attribute that {@link #shouldHaveSupplier} selects into the internal supplier type. | ||
| */ | ||
| public void wrapSuppliers(Collection<ASTCDAttribute> attributes) { |
There was a problem hiding this comment.
wrapSuppliers does not say anything about storing the values
| * so the internal wrapper never leaks into the public API. | ||
| */ | ||
| public ASTMCType toPublicSupplierType(ASTMCType type) { | ||
| return createStdSupplierTypeOf(unwrapSupplier(type)); |
There was a problem hiding this comment.
This makes me wonder if the setup is too complex.
I am not sure.
…on because we have multiple return types) made ClearingMemorizer.map more general
| } | ||
|
|
||
|
|
||
| public static TypeSymbol resolveTypeSymbolOrLogError( |
There was a problem hiding this comment.
This should not be part of its public api, it has nothing to do with the Factory directly
| @@ -21,11 +21,11 @@ public void setFunctionList(List<FunctionSymbol> methodList){ | |||
| } | |||
|
|
|||
| public List<SymTypeExpression> getSuperClassesOnly(){ | |||
| return superTypes; | |||
| return superTypes.get(); | |||
There was a problem hiding this comment.
... yes, kind-of.
It is questionable design wise,
but the idea is that we cannot distinguish between them for TypeSymbols,
so we simply return them all.
…and no residuals in the final generated code
…an not be resolved immediatly