Package org.scf4j

Examples of org.scf4j.Property


    }
    return propertyMapping;
  }

  private void mapProperty(Map<Method, Object> propertyMapping, Properties properties, String path, Method method) throws ConfigurationException {
    Property property = defendMethod(method);

    String separator = path.equals("") ? "" : ".";
    String propertyPath = path + separator + property.id();
    String value = properties.getProperty(propertyPath);

    logger.debug(Messages.getString("try.to.map.and.coerce.property.pstr"), propertyPath);

    Object nested = checkNested(properties, method.getReturnType(), propertyPath);
    if (nested != null) {
      propertyMapping.put(method, nested);
    } else  if (value != null) {
      propertyMapping.put(method, getCoercer().coerce(value, method.getReturnType()));
    } else if (property.optional()) {
      propertyMapping.put(method, getCoercer().coerce(property.value(), method.getReturnType()));
    } else {
      throw new ConfigurationException(Messages.getString("required.property.0.is.missing", propertyPath));
    }
  }
View Full Code Here


  private Property defendMethod(Method method) {
    if (method.getReturnType().equals(void.class)) {
      throw new IllegalArgumentException(Messages.getString("found.void.return.type.in.property.method.0", method.getName()));
    }

    Property property = method.getAnnotation(Property.class);
    if (property == null) {
      throw new IllegalArgumentException(Messages.getString("method.0.is.not.annotated.with.property", method.getName()));
    }
    return property;
  }
View Full Code Here

TOP

Related Classes of org.scf4j.Property

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.