use of org.apache.ignite.internal.configuration.direct.DirectNamedListProxy in project ignite-3 by apache.
the class DirectProxyAsmGenerator method addGetMethod.
/**
* Generates getter based on the field.
*/
private void addGetMethod(Field schemaField) {
Class<?> schemaFieldType = schemaField.getType();
String fieldName = schemaField.getName();
SchemaClassesInfo schemaClassInfo = cgen.schemaInfo(schemaFieldType);
ParameterizedType returnType;
// Return type is determined like in ConfigurationImpl class.
if (isConfigValue(schemaField)) {
returnType = typeFromJavaClassName(schemaClassInfo.cfgClassName);
} else if (isNamedConfigValue(schemaField)) {
returnType = type(NamedConfigurationTree.class);
} else {
assert isValue(schemaField) || isPolymorphicId(schemaField) || isInjectedName(schemaField) || isInternalId(schemaField) : schemaField;
returnType = type(ConfigurationValue.class);
}
MethodDefinition methodDef = classDef.declareMethod(of(PUBLIC), fieldName, returnType);
BytecodeBlock body = methodDef.getBody();
if (isValue(schemaField) || isPolymorphicId(schemaField) || isInjectedName(schemaField) || isInternalId(schemaField)) {
// new DirectValueProxy(appendKey(this.keys, new KeyPathNode("name")), changer);
// or
// new DirectValueProxy(appendKey(this.keys, new KeyPathNode("<internal_id>")), changer);
body.append(newInstance(DirectValueProxy.class, invokeStatic(APPEND_KEY, methodDef.getThis().getField("keys", List.class), newInstance(KeyPathNode.class, constantString(isInjectedName(schemaField) ? InnerNode.INJECTED_NAME : isInternalId(schemaField) ? InnerNode.INTERNAL_ID : fieldName))), methodDef.getThis().getField("changer", DynamicConfigurationChanger.class)));
} else {
SchemaClassesInfo fieldSchemaClassInfo = cgen.schemaInfo(schemaField.getType());
ParameterizedType resultType = typeFromJavaClassName(fieldSchemaClassInfo.directProxyClassName);
if (isConfigValue(schemaField)) {
// new BarDirectProxy(appendKey(this.keys, new KeyPathNode("name")), changer);
body.append(newInstance(resultType, invokeStatic(APPEND_KEY, methodDef.getThis().getField("keys", List.class), newInstance(KeyPathNode.class, constantString(fieldName))), methodDef.getThis().getField("changer", DynamicConfigurationChanger.class)));
} else {
// new DirectNamedListProxy(appendKey(this.keys, new KeyPathNode("name")), changer, BarDirectProxy::new);
body.append(newInstance(DirectNamedListProxy.class, invokeStatic(APPEND_KEY, methodDef.getThis().getField("keys", List.class), newInstance(KeyPathNode.class, constantString(fieldName))), methodDef.getThis().getField("changer", DynamicConfigurationChanger.class), newDirectProxyLambda(fieldSchemaClassInfo)));
}
}
// Return object from the above.
body.retObject();
}
Aggregations