Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbashir committed Jul 7, 2024
1 parent b9b55dc commit 9ad0231
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 5 deletions.
73 changes: 73 additions & 0 deletions example-java/src/main/java/ru/meta/MetaExampleJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.art.core.property.LazyProperty;
import io.art.meta.model.InstanceMetaMethod;
import io.art.meta.model.MetaClass;
import io.art.meta.model.MetaConstructor;
import io.art.meta.model.MetaField;
import io.art.meta.model.MetaLibrary;
import io.art.meta.model.MetaMethod;
Expand Down Expand Up @@ -61,6 +62,8 @@ public MetaModelPackage modelPackage() {
public static final class MetaExampleClass extends MetaClass<ru.Example> {
private static final LazyProperty<MetaExampleClass> self = MetaClass.self(ru.Example.class);

private final MetaConstructorConstructor constructor = registerConstructor(new MetaConstructorConstructor(this));

private final MetaMainMethod mainMethod = registerMethod(new MetaMainMethod(this));

private MetaExampleClass() {
Expand All @@ -71,10 +74,30 @@ public static MetaExampleClass example() {
return self.get();
}

public MetaConstructorConstructor constructor() {
return constructor;
}

public MetaMainMethod mainMethod() {
return mainMethod;
}

public final class MetaConstructorConstructor extends MetaConstructor<MetaExampleClass, ru.Example> {
private MetaConstructorConstructor(MetaExampleClass owner) {
super(metaType(ru.Example.class),owner);
}

@Override
public ru.Example invoke(java.lang.Object[] arguments) throws Throwable {
return new ru.Example();
}

@Override
public ru.Example invoke() throws Throwable {
return new ru.Example();
}
}

public final class MetaMainMethod extends StaticMetaMethod<MetaExampleClass, Void> {
private final MetaParameter<java.lang.String[]> argumentsParameter = register(new MetaParameter<>(0, "arguments",metaArray(java.lang.String[].class, java.lang.String[]::new, metaType(java.lang.String.class))));

Expand Down Expand Up @@ -114,6 +137,8 @@ public MetaMyServiceClass myServiceClass() {
public static final class MetaMyServiceClass extends MetaClass<ru.service.MyService> {
private static final LazyProperty<MetaMyServiceClass> self = MetaClass.self(ru.service.MyService.class);

private final MetaConstructorConstructor constructor = registerConstructor(new MetaConstructorConstructor(this));

private final MetaMyMethodMethod myMethodMethod = registerMethod(new MetaMyMethodMethod(this));

private final MetaGetModelMethod getModelMethod = registerMethod(new MetaGetModelMethod(this));
Expand All @@ -126,6 +151,10 @@ public static MetaMyServiceClass myService() {
return self.get();
}

public MetaConstructorConstructor constructor() {
return constructor;
}

public MetaMyMethodMethod myMethodMethod() {
return myMethodMethod;
}
Expand All @@ -134,6 +163,22 @@ public MetaGetModelMethod getModelMethod() {
return getModelMethod;
}

public final class MetaConstructorConstructor extends MetaConstructor<MetaMyServiceClass, ru.service.MyService> {
private MetaConstructorConstructor(MetaMyServiceClass owner) {
super(metaType(ru.service.MyService.class),owner);
}

@Override
public ru.service.MyService invoke(java.lang.Object[] arguments) throws Throwable {
return new ru.service.MyService();
}

@Override
public ru.service.MyService invoke() throws Throwable {
return new ru.service.MyService();
}
}

public final class MetaMyMethodMethod extends InstanceMetaMethod<MetaMyServiceClass, ru.service.MyService, ru.model.Model> {
private final MetaParameter<ru.model.Model> modelParameter = register(new MetaParameter<>(0, "model",metaType(ru.model.Model.class)));

Expand Down Expand Up @@ -297,6 +342,8 @@ public MetaModelClass modelClass() {
public static final class MetaModelClass extends MetaClass<ru.model.Model> {
private static final LazyProperty<MetaModelClass> self = MetaClass.self(ru.model.Model.class);

private final MetaConstructorConstructor constructor = registerConstructor(new MetaConstructorConstructor(this));

private final MetaField<MetaModelClass, java.lang.String> valueField = registerField(new MetaField<>("value",metaType(java.lang.String.class),false,this));

private final MetaToBuilderMethod toBuilderMethod = registerMethod(new MetaToBuilderMethod(this));
Expand All @@ -313,6 +360,10 @@ public static MetaModelClass model() {
return self.get();
}

public MetaConstructorConstructor constructor() {
return constructor;
}

public MetaField<MetaModelClass, java.lang.String> valueField() {
return valueField;
}
Expand All @@ -329,6 +380,28 @@ public MetaModelBuilderClass modelBuilderClass() {
return modelBuilderClass;
}

public final class MetaConstructorConstructor extends MetaConstructor<MetaModelClass, ru.model.Model> {
private final MetaParameter<java.lang.String> valueParameter = register(new MetaParameter<>(0, "value",metaType(java.lang.String.class)));

private MetaConstructorConstructor(MetaModelClass owner) {
super(metaType(ru.model.Model.class),owner);
}

@Override
public ru.model.Model invoke(java.lang.Object[] arguments) throws Throwable {
return new ru.model.Model((java.lang.String)(arguments[0]));
}

@Override
public ru.model.Model invoke(java.lang.Object argument) throws Throwable {
return new ru.model.Model((java.lang.String)(argument));
}

public MetaParameter<java.lang.String> valueParameter() {
return valueParameter;
}
}

public final class MetaToBuilderMethod extends InstanceMetaMethod<MetaModelClass, ru.model.Model, ru.model.Model.ModelBuilder> {
private MetaToBuilderMethod(MetaModelClass owner) {
super("toBuilder",metaType(ru.model.Model.ModelBuilder.class),owner);
Expand Down
2 changes: 2 additions & 0 deletions example-java/src/main/java/ru/service/MyService.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ru.service;

import lombok.NoArgsConstructor;
import ru.communicator.*;
import ru.model.*;
import static io.art.logging.Logging.*;
import static io.art.transport.extensions.TransportExtensions.*;

@NoArgsConstructor
public class MyService implements MyCommunicator {
@Override
public Model myMethod(Model model) {
Expand Down
3 changes: 2 additions & 1 deletion example-kotlin/src/main/kotlin/ru/Example.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import io.art.rsocket.kotlin.rsocket
import io.art.transport.kotlin.transport
import io.art.yaml.kotlin.yaml
import ru.communicator.MyCommunicator
import ru.meta.MetaExampleKotlin
import ru.service.MyService

data class Request(val success: String)

fun main() = activator {
//meta(::MetaExampleKotlin)
meta(::MetaExampleKotlin)
configurator()
logging()
json()
Expand Down
59 changes: 55 additions & 4 deletions example-kotlin/src/main/kotlin/ru/meta/MetaExampleKotlin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.art.core.`property`.LazyProperty
import io.art.http.communicator.HttpCommunicationDecorator
import io.art.meta.model.InstanceMetaMethod
import io.art.meta.model.MetaClass
import io.art.meta.model.MetaConstructor
import io.art.meta.model.MetaField
import io.art.meta.model.MetaLibrary
import io.art.meta.model.MetaMethod
Expand Down Expand Up @@ -64,6 +65,9 @@ public class MetaExampleKotlin : MetaLibrary {
public fun modelPackage(): MetaModelPackage = modelPackage

public class MetaRequestClass : MetaClass<Request> {
private val `constructor`: MetaConstructorConstructor =
registerConstructor(MetaConstructorConstructor(this))

private val successField: MetaField<MetaRequestClass, String> =
registerField(MetaField("success",metaType<String>(String::class.java),false,this))

Expand All @@ -72,6 +76,8 @@ public class MetaExampleKotlin : MetaLibrary {

internal constructor() : super(metaType<Request>(Request::class.java))

public fun `constructor`(): MetaConstructorConstructor = constructor

public fun successField(): MetaField<MetaRequestClass, String> = successField

public fun getSuccessMethod(): MetaGetSuccessMethod = getSuccessMethod
Expand All @@ -82,6 +88,26 @@ public class MetaExampleKotlin : MetaLibrary {
public fun request(): MetaRequestClass = self.get()
}

public class MetaConstructorConstructor : MetaConstructor<MetaRequestClass, Request> {
private val successParameter: MetaParameter<String> = register(MetaParameter(0,
"success",metaType<String>(String::class.java)))

internal constructor(owner: MetaRequestClass) :
super(metaType<Request>(Request::class.java),owner)

@Throws(Throwable::class)
override fun invoke(arguments: Array<Any>): Request {
return Request(arguments[0] as String)
}

@Throws(Throwable::class)
override fun invoke(argument: Any): Request {
return Request(argument as String)
}

public fun successParameter(): MetaParameter<String> = successParameter
}

public class MetaGetSuccessMethod : InstanceMetaMethod<MetaRequestClass, Request, String> {
internal constructor(owner: MetaRequestClass) :
super("getSuccess",metaType<String>(String::class.java),owner)
Expand Down Expand Up @@ -607,13 +633,13 @@ public class MetaExampleKotlin : MetaLibrary {
MetaMethod<MetaClass<*>, *>]!!
}

public override fun myMethod(model: Model): Model = myMethodInvocation.apply(model) as
Model
public override fun myMethod(model: Model): Model = single<Model>(myMethodInvocation,
model)

public override fun getModel(): Model = getModelInvocation.apply(null) as Model
public override fun getModel(): Model = get<Model>(getModelInvocation)

public override fun compensation(input: Flux<String>): Mono<String> =
compensationInvocation.apply(input) as Mono<String>
single<Mono<String>>(compensationInvocation, input)
}
}
}
Expand Down Expand Up @@ -1103,6 +1129,9 @@ public class MetaExampleKotlin : MetaLibrary {
public fun modelClass(): MetaModelClass = modelClass

public class MetaModelClass : MetaClass<Model> {
private val `constructor`: MetaConstructorConstructor =
registerConstructor(MetaConstructorConstructor(this))

private val valueField: MetaField<MetaModelClass, Sequence<String>> =
registerField(MetaField("value",metaType<Sequence<String>>(Sequence::class.java,metaType<String>(String::class.java)),false,this))

Expand All @@ -1111,6 +1140,8 @@ public class MetaExampleKotlin : MetaLibrary {

internal constructor() : super(metaType<Model>(Model::class.java))

public fun `constructor`(): MetaConstructorConstructor = constructor

public fun valueField(): MetaField<MetaModelClass, Sequence<String>> = valueField

public fun getValueMethod(): MetaGetValueMethod = getValueMethod
Expand All @@ -1121,6 +1152,26 @@ public class MetaExampleKotlin : MetaLibrary {
public fun model(): MetaModelClass = self.get()
}

public class MetaConstructorConstructor : MetaConstructor<MetaModelClass, Model> {
private val valueParameter: MetaParameter<Sequence<String>> = register(MetaParameter(0,
"value",metaType<Sequence<String>>(Sequence::class.java,metaType<String>(String::class.java))))

internal constructor(owner: MetaModelClass) :
super(metaType<Model>(Model::class.java),owner)

@Throws(Throwable::class)
override fun invoke(arguments: Array<Any>): Model {
return Model(arguments[0] as Sequence<String>)
}

@Throws(Throwable::class)
override fun invoke(argument: Any): Model {
return Model(argument as Sequence<String>)
}

public fun valueParameter(): MetaParameter<Sequence<String>> = valueParameter
}

public class MetaGetValueMethod :
InstanceMetaMethod<MetaModelClass, Model, Sequence<String>> {
internal constructor(owner: MetaModelClass) :
Expand Down

0 comments on commit 9ad0231

Please sign in to comment.