All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.babyfish.jimmer.Input Maven / Gradle / Ivy

There is a newer version: 0.9.17
Show newest version
package org.babyfish.jimmer;

import org.babyfish.jimmer.client.ApiIgnore;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.jetbrains.annotations.NotNull;

/**
 * Interface for generated input DTO class of entity type
 */
@ApiIgnore
public interface Input extends View {

    E toEntity();

    /**
     * For complex form contains UI tab.
     */
    @SuppressWarnings("unchecked")
    @NotNull
    static  E toMergedEntity(Input ... inputs) {
        E[] entities = (E[])new Object[inputs.length];
        for (int i = inputs.length - 1; i >= 0; --i) {
            entities[i] = inputs[i] != null ? inputs[i].toEntity() : null;
        }
        return ImmutableObjects.merge(entities);
    }

    static RuntimeException unknownNonNullProperty(Class type, String prop) {
        return new IllegalStateException(
                "An object whose type is \"" +
                        type.getName() +
                        "\" cannot be deserialized by Jackson. " +
                        "the property \"" +
                        prop +
                        "\" must be specified it is non-null property"
        );
    }

    static RuntimeException unknownNullableProperty(Class type, String prop) {
        return new IllegalStateException(
                "An object whose type is \"" +
                        type.getName() +
                        "\" cannot be deserialized by Jackson. " +
                        "The current type is fixed input DTO so that all JSON properties " +
                        "must be specified explicitly, however, the property \"" +
                        prop +
                        "\" is not specified by JSON explicitly. " +
                        "Please either explicitly specify the property as null in the JSON, " +
                        "or specify the current input property as static, dynamic or fuzzy in the DTO language"
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy