Examples of ConstructorArgs


Examples of com.github.jmkgreen.morphia.annotations.ConstructorArgs

        if (c == null)
            c = mf.isSingleValue ? mf.getConcreteType() : mf.getSubClass();
        try {
            return createInstance(c, dbObj);
        } catch (RuntimeException e) {
            ConstructorArgs argAnn = mf.getAnnotation(ConstructorArgs.class);
            if (argAnn == null)
                throw e;
            //TODO: now that we have a mapr, get the arg types that way by getting the fields by name. + Validate names
            Object[] args = new Object[argAnn.value().length];
            Class[] argTypes = new Class[argAnn.value().length];
            for (int i = 0; i < argAnn.value().length; i++) {
                //TODO: run converters and stuff against these. Kinda like the List of List stuff, using a fake MappedField to hold the value
                Object val = dbObj.get(argAnn.value()[i]);
                args[i] = val;
                argTypes[i] = val.getClass();
            }
            try {
                Constructor ctor = c.getDeclaredConstructor(argTypes);
View Full Code Here

Examples of org.apache.ibatis.annotations.ConstructorArgs

  }

  private void parseResultsAndConstructorArgs(Method method) {
    Class<?> returnType = getReturnType(method);
    if (returnType != null) {
      ConstructorArgs args = method.getAnnotation(ConstructorArgs.class);
      Results results = method.getAnnotation(Results.class);
      TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class);
      String resultMapId = generateResultMapName(method);
      applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator);
    }
View Full Code Here

Examples of org.apache.ibatis.annotations.ConstructorArgs

  }

  private void parseResultsAndConstructorArgs(Method method) {
    Class<?> returnType = getReturnType(method);
    if (returnType != null) {
      ConstructorArgs args = method.getAnnotation(ConstructorArgs.class);
      Results results = method.getAnnotation(Results.class);
      TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class);
      String resultMapId = generateResultMapName(method);
      applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator);
    }
View Full Code Here

Examples of org.apache.ibatis.annotations.ConstructorArgs

    }
  }

  private String parseResultMap(Method method) {
    Class<?> returnType = getReturnType(method);
    ConstructorArgs args = method.getAnnotation(ConstructorArgs.class);
    Results results = method.getAnnotation(Results.class);
    TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class);
    String resultMapId = generateResultMapName(method);
    applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator);
    return resultMapId;
View Full Code Here

Examples of org.easymock.ConstructorArgs

        Enhancer.registerCallbacks(mockClass, new Callback[] { interceptor });

        if (ClassExtensionHelper.getCurrentConstructorArgs() != null) {
            // Really instantiate the class
            final ConstructorArgs args = ClassExtensionHelper.getCurrentConstructorArgs();
            Constructor cstr;
            try {
                // Get the constructor with the same params
                cstr = mockClass.getDeclaredConstructor(args.getConstructor().getParameterTypes());
            } catch (final NoSuchMethodException e) {
                // Shouldn't happen, constructor is checked when ConstructorArgs is instantiated
                // ///CLOVER:OFF
                throw new RuntimeException("Fail to find constructor for param types", e);
                // ///CLOVER:ON
            }
            T mock;
            try {
                cstr.setAccessible(true); // So we can call a protected
                // constructor
                mock = (T) cstr.newInstance(args.getInitArgs());
            } catch (final InstantiationException e) {
                // ///CLOVER:OFF
                throw new RuntimeException("Failed to instantiate mock calling constructor", e);
                // ///CLOVER:ON
            } catch (final IllegalAccessException e) {
View Full Code Here

Examples of org.easymock.ConstructorArgs

        }
    }

    @Test
    public void testConstructorArgs() {
        final ConstructorArgs args = new ConstructorArgs(A.class.getConstructors()[0], "a", 4);
        checkArgs(args);
    }
View Full Code Here

Examples of org.easymock.ConstructorArgs

        assertEquals(A.class.getConstructors()[0], args.getConstructor());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testConstructorArgs_WrongArgument() {
        new ConstructorArgs(A.class.getConstructors()[0], "a", "b");
    }
View Full Code Here

Examples of org.easymock.ConstructorArgs

        new ConstructorArgs(A.class.getConstructors()[0], "a", "b");
    }

    @Test(expected = IllegalArgumentException.class)
    public void testConstructorArgs_NullPrimitive() {
        new ConstructorArgs(A.class.getConstructors()[0], "a", null);
    }
View Full Code Here

Examples of org.easymock.ConstructorArgs

        new ConstructorArgs(A.class.getConstructors()[0], "a", null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testConstructorArgs_PrimitiveForObject() {
        new ConstructorArgs(A.class.getConstructors()[0], 1, 2);
    }
View Full Code Here

Examples of org.easymock.ConstructorArgs

        new ConstructorArgs(A.class.getConstructors()[0], 1, 2);
    }

    @Test
    public void testConstructorArgs_NullObject() {
        new ConstructorArgs(A.class.getConstructors()[0], null, 2);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.