Package kiss.model

Examples of kiss.model.Model


        // check null
        if (input == null) {
            return null;
        }

        Model inputModel = Model.load(input.getClass());
        Model outputModel = Model.load(output);

        // no conversion
        if (inputModel == outputModel) {
            return (M) input;
        }

        Codec inputCodec = inputModel.getCodec();
        Codec<M> outputCodec = outputModel.getCodec();

        // check whether each model are attribute model or not
        if (inputCodec == null && outputCodec == null) {
            // we should copy property values
View Full Code Here


    public static void write(Object input, Appendable output, boolean json) {
        if (output == null) {
            throw new NullPointerException();
        }

        Model model = Model.load(input.getClass());
        Property property = new Property(model, model.name);

        // traverse configuration as json
        new JSON(output).walk(model, property, input);
    }
View Full Code Here

            // store parameters to recall
            this.params = params;
            // collect model
            for (Object param : params) {
                if (param != null) {
                    Model model = Model.load(param.getClass());

                    // exclude GUI Widget
                    if (model.properties.size() != 0) {
                        // register as model state listener
                        Table<String, AlternateJSBinds> binds = contexts.get(param);
View Full Code Here

            this.params = params;

            // collect model
            for (Object param : params) {
                if (param != null) {
                    Model model = Model.load(param.getClass());

                    // exclude GUI Widget
                    if (model.properties.size() != 0) {
                        // register as model state listener
                        Table<String, Binds> binds = contexts.get(param);
View Full Code Here

    @Bind
    protected void bind(M instance, String path) {
        Objects.requireNonNull(instance);
        Objects.requireNonNull(path);

        Model model = Model.load(instance.getClass());
        Property property = model.getProperty(path);

        if (property == null) {
            throw new IllegalArgumentException("'" + path + "' is not property for [" + model.type + "].");
        }
        form.val(model.get(instance, property));
    }
View Full Code Here

        }

        protected <T> T cast(Object object, Class<T> type) {
            NativeObject base = (NativeObject) object;
            T instance = I.make(type);
            Model model = Model.load(type);

            for (Property property : model.properties) {
                Object value = base.get(property.name);

                if (value == null || value instanceof Undefined) {
                    // do nothing
                } else if (property.isAttribute()) {
                    model.set(instance, property, value);
                } else {
                    model.set(instance, property, cast(value, property.model.type));
                }
            }
            return instance;
        }
View Full Code Here

TOP

Related Classes of kiss.model.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.