Package br.com.caelum.iogi.parameters

Examples of br.com.caelum.iogi.parameters.Parameter


      return null;
    }

    private Object setPropertiesAfterConversions(Target<?> target, Parameters parameters) {
      List<Parameter> params = parameters.forTarget(target);
      Parameter parameter = findParamFor(params, target);

      Object converted = converterForTarget(target).convert(parameter.getValue(), target.getClassType());

      return new NewObject(this, parameters.focusedOn(target), converted).valueWithPropertiesSet();
    }
View Full Code Here


    }

    @Override
    public Object instantiate(Target<?> target, Parameters parameters) {
      try {
        Parameter parameter = parameters.namedAfter(target);
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType());
      } catch (ConversionException ex) {
        errors.add(ex.getValidationMessage().withCategory(target.getName()));
      } catch (IllegalStateException e) {
        return setPropertiesAfterConversions(target, parameters);
      }
View Full Code Here

      return null;
    }

    private Object setPropertiesAfterConversions(Target<?> target, Parameters parameters) {
      List<Parameter> params = parameters.forTarget(target);
      Parameter parameter = findParamFor(params, target);

      Object converted = converterForTarget(target).convert(parameter.getValue(), target.getClassType());

      return new NewObject(this, parameters.focusedOn(target), converted).valueWithPropertiesSet();
    }
View Full Code Here

      try {
        if(isSupportedCollection(target)) {
          return multiInstantiator.instantiate(target, parameters);
        }
       
        Parameter parameter = parameters.namedAfter(target);
       
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType());
      } catch (ConversionException ex) {
        errors.add(ex.getValidationMessage().withCategory(target.getName()));
      } catch (IllegalStateException e) {
        return setPropertiesAfterConversions(target, parameters);
      }
View Full Code Here

        || Map.class.isAssignableFrom(target.getClassType());
    }

    private Object setPropertiesAfterConversions(Target<?> target, Parameters parameters) {
      List<Parameter> params = parameters.forTarget(target);
      Parameter parameter = findParamFor(params, target);

      Object converted = converterForTarget(target).convert(parameter == null? null : parameter.getValue(), target.getClassType());

      return new NewObject(this, parameters.focusedOn(target), converted).valueWithPropertiesSet();
    }
View Full Code Here

  @Test
  public void canInstantiatingStringsInAListSettingItsInternalValueWithoutInvokingConverters1() throws Exception {
    final Type type = ContainsParameterizedList.class.getField("listOfString").getGenericType();
    final Target<List<String>> target = new Target<>(type, "legLength");
    final List<String> legs = iogi.instantiate(target , new Parameter("legLength[0]", "small"), new Parameter("legLength[1]", "big"));
    assertThat(legs.get(1), is(equalTo("big")));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiatingStringsInAListSettingItsInternalValueWithoutInvokingConverters2() throws Exception {
    final Target<Cat> target = Target.create(Cat.class, "cat");
    final Cat cat = iogi.instantiate(target , new Parameter("cat.legLength[0]", "small"), new Parameter("cat.legLength[1]", "big"));
    assertThat(cat.legLength.get(1), is(equalTo("big")));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiateAndPopulateAnArrayOfWrappers1() {
    final Target<long[]> target = Target.create(long[].class, "ids");
    final long[] ids = iogi.instantiate(target, new Parameter("ids[0]", "3"), new Parameter("ids[1]", "5"));
    assertThat(ids[0], is(equalTo(3L)));
    assertThat(ids[1], is(equalTo(5L)));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiateAndPopulateAnArrayOfWrappers2() {
    final Target<Cat> target = Target.create(Cat.class, "cat");
    final Cat cat = iogi.instantiate(target, new Parameter("cat.ids[0]", "3"), new Parameter("cat.ids[1]", "5"));
    assertThat(cat.ids[0], is(equalTo(3L)));
    assertThat(cat.ids[1], is(equalTo(5L)));
  }
View Full Code Here

  @Test
  public void canInstantiateAndPopulateAListOfWrappers1() throws Exception {
    final Type type = ContainsParameterizedList.class.getField("listOfLong").getGenericType();
    final Target<List<Long>> target = new Target<>(type, "eyeColorCode");
    final List<Long> eyeColorCode = iogi.instantiate(target, new Parameter("eyeColorCode[0]", "3"), new Parameter("eyeColorCode[1]", "5"));
    assertThat(eyeColorCode.get(0), is(equalTo(3L)));
    assertThat(eyeColorCode.get(1), is(equalTo(5L)));
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.iogi.parameters.Parameter

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.