Package com.insightfullogic.slab

Examples of com.insightfullogic.slab.InvalidInterfaceException


    final Map<String, Method> setters;
   
    public TypeInspector(Class<?> klass) {
        this.klass = klass;
        if(!klass.isInterface() && !ConcreteCursor.class.isAssignableFrom(klass))
          throw new InvalidInterfaceException("concrete classes must sublass ConcreteCursor");
       
        getters = findGetters();
        setters = findSetters();
        checkRemainingMethods(klass);
    }
View Full Code Here


    List<Method> methods = new ArrayList<Method>(asList(klass.getDeclaredMethods()));
    methods.removeAll(getters);
    methods.removeAll(setters.values());
        for (Method method : methods)
      if (isAbstract(method.getModifiers()))
        throw new InvalidInterfaceException(klass.getName() + " has abstract methods that are neither getters nor setters");
  }
View Full Code Here

        return methods;
    }
 
    private void ensureAbstract(Method method) {
    if (!isAbstract(method.getModifiers()))
      throw new InvalidInterfaceException(method + " must be abstract, since its a getter or setter");
  }
View Full Code Here

      throw new InvalidInterfaceException(method + " must be abstract, since its a getter or setter");
  }

  private void doesntUseIndex(String name) {
    if ("getIndex".equals(name))
      throw new InvalidInterfaceException("You can't declare an index field, since that name is used by Slab");
  }
View Full Code Here

      throw new InvalidInterfaceException("You can't declare an index field, since that name is used by Slab");
  }

  private void hasNoParameters(Method method) {
        if (method.getParameterTypes().length != 0)
            throw new InvalidInterfaceException(method.getName() + " is a getter with one or more parameters");
    }
View Full Code Here

            throw new InvalidInterfaceException(method.getName() + " is a getter with one or more parameters");
    }

    private void returnsPrimitive(Method method) {
        if (!method.getReturnType().isPrimitive())
          throw new InvalidInterfaceException(method.getName() + " is a getter that doesn't return a primitive");
    }
View Full Code Here

  }

    private void hasOnePrimitiveParameter(Method method) {
    Class<?>[] parameters = method.getParameterTypes();
    if (parameters.length != 1)
      throw new InvalidInterfaceException(method.getName() + " is a setter with more than one parameter");
   
    if (!parameters[0].isPrimitive())
      throw new InvalidInterfaceException(method.getName() + " is a setter with a non-primitive parameter");
  }
View Full Code Here

      throw new InvalidInterfaceException(method.getName() + " is a setter with a non-primitive parameter");
  }

  private void returnsVoid(Method method) {
    if (method.getReturnType() != Void.TYPE)
      throw new InvalidInterfaceException(method.getName() + " is a setter that doesn't return void");
  }
View Full Code Here

  public Method setterFor(Method getter) {
    String name = getter.getName().replaceFirst("get", "set");
    Method method = setters.get(name);
    if (method == null)
      throw new InvalidInterfaceException("Unable to find setter with name: " + name);
    return method;
  }
View Full Code Here

TOP

Related Classes of com.insightfullogic.slab.InvalidInterfaceException

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.