Package kiss

Examples of kiss.Table


     *
     * @param clazz A target class.
     * @return A table of method and annnotations.
     */
    public static Table<Method, Annotation> getAnnotations(Class clazz) {
        Table<Method, Annotation> table = new Table();

        for (Class type : ClassUtil.getTypes(clazz)) {
            for (Method method : type.getDeclaredMethods()) {
                // exclude the method which is created by compiler
                // exclude the private method which is not declared in the specified class
                if (!method.isBridge() && !method.isSynthetic() && (((method.getModifiers() & Modifier.PRIVATE) == 0) || method.getDeclaringClass() == clazz)) {
                    Annotation[] annotations = method.getAnnotations();

                    if (annotations.length != 0) {
                        List<Annotation> list = new ArrayList();

                        // disclose container annotation
                        for (Annotation annotation : annotations) {
                            try {
                                Class annotationType = annotation.annotationType();
                                Method value = annotationType.getMethod("value");
                                Class returnType = value.getReturnType();

                                if (returnType.isArray()) {
                                    Class<?> componentType = returnType.getComponentType();
                                    Repeatable repeatable = componentType.getAnnotation(Repeatable.class);

                                    if (repeatable != null && repeatable.value() == annotationType) {
                                        value.setAccessible(true);

                                        Annotation[] items = (Annotation[]) value.invoke(annotation);

                                        for (Annotation item : items) {
                                            list.add(item);
                                        }
                                        continue;
                                    }
                                }
                            } catch (Exception e) {
                                // do nothing
                            }
                            list.add(annotation);
                        }

                        // check method overriding
                        for (Method candidate : table.keySet()) {
                            if (candidate.getName().equals(method.getName()) && Arrays.deepEquals(candidate.getParameterTypes(), method.getParameterTypes())) {
                                method = candidate; // detect overriding
                                break;
                            }
                        }

                        add: for (Annotation annotation : list) {
                            Class annotationType = annotation.annotationType();

                            if (!annotationType.isAnnotationPresent(Repeatable.class)) {
                                for (Annotation item : table.get(method)) {
                                    if (item.annotationType() == annotationType) {
                                        continue add;
                                    }
                                }
                            }

                            table.push(method, annotation);
                        }
                    }
                }
            }
        }
View Full Code Here


     */
    private <V> Events<V> add(Object type) {
        return new Events<V>(observer -> {
            // create event listener holder if it is not initialized
            if (holder == null) {
                holder = new Table();
                startListening(Object.class);
            }

            // register this event listener
            if (holder.push(type, observer)) {
View Full Code Here

                    if (model.properties.size() != 0) {
                        // register as model state listener
                        Table<String, AlternateJSBinds> binds = contexts.get(param);

                        if (binds == null) {
                            binds = new Table();
                            contexts.put(param, binds);
                        }

                        // collect bindable properties
                        for (Property property : model.properties) {
View Full Code Here

                    if (model.properties.size() != 0) {
                        // register as model state listener
                        Table<String, Binds> binds = contexts.get(param);

                        if (binds == null) {
                            binds = new Table();
                            contexts.put(param, binds);
                        }

                        // collect bindable properties
                        for (Property property : model.properties) {
View Full Code Here

TOP

Related Classes of kiss.Table

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.