Package com.esotericsoftware.yamlbeans.Beans

Examples of com.esotericsoftware.yamlbeans.Beans.Property


   */
  public void setPropertyElementType (Class type, String propertyName, Class elementType) {
    if (type == null) throw new IllegalArgumentException("type cannot be null.");
    if (propertyName == null) throw new IllegalArgumentException("propertyName cannot be null.");
    if (elementType == null) throw new IllegalArgumentException("propertyType cannot be null.");
    Property property = null;
    Exception cause = null;
    try {
      property = Beans.getProperty(type, propertyName, beanProperties, privateFields, this);
    } catch (IntrospectionException ex) {
      cause = ex;
    }
    if (property == null) {
      throw new IllegalArgumentException("The class " + type.getName() + " does not have a property named: " + propertyName,
        cause);
    }
    if (!Collection.class.isAssignableFrom(property.getType()) && !Map.class.isAssignableFrom(property.getType()))
      throw new IllegalArgumentException("The '" + propertyName + "' property on the " + type.getName()
        + " class must be a Collection or Map: " + property.getType());
    propertyToElementType.put(property, elementType);
  }
View Full Code Here


   */
  public void setPropertyDefaultType (Class type, String propertyName, Class defaultType) {
    if (type == null) throw new IllegalArgumentException("type cannot be null.");
    if (propertyName == null) throw new IllegalArgumentException("propertyName cannot be null.");
    if (defaultType == null) throw new IllegalArgumentException("defaultType cannot be null.");
    Property property = null;
    Exception cause = null;
    try {
      property = Beans.getProperty(type, propertyName, beanProperties, privateFields, this);
    } catch (IntrospectionException ex) {
      cause = ex;
View Full Code Here

          if (!isExplicitKey) value = readValue(elementType, null, null);
          ((Map)object).put(key, value);
        } else {
          // Set field on object.
          try {
            Property property = Beans.getProperty(type, (String)key, config.beanProperties, config.privateFields, config);
            if (property == null)
              throw new YamlReaderException("Unable to find property '" + key + "' on class: " + type.getName());
            Class propertyElementType = config.propertyToElementType.get(property);
            Class propertyDefaultType = config.propertyToDefaultType.get(property);
            if (!isExplicitKey) value = readValue(property.getType(), propertyElementType, propertyDefaultType);
            property.set(object, value);
          } catch (Exception ex) {
            if (ex instanceof YamlReaderException) throw (YamlReaderException)ex;
            throw new YamlReaderException("Error setting property '" + key + "' on class: " + type.getName(), ex);
          }
        }
View Full Code Here

   * type will be used for each element if no tag is found. */
  public void setPropertyElementType (Class type, String propertyName, Class elementType) {
    if (type == null) throw new IllegalArgumentException("type cannot be null.");
    if (propertyName == null) throw new IllegalArgumentException("propertyName cannot be null.");
    if (elementType == null) throw new IllegalArgumentException("propertyType cannot be null.");
    Property property = null;
    Exception cause = null;
    try {
      property = Beans.getProperty(type, propertyName, beanProperties, privateFields, this);
    } catch (IntrospectionException ex) {
      cause = ex;
    }
    if (property == null) {
      throw new IllegalArgumentException("The class " + type.getName() + " does not have a property named: " + propertyName,
        cause);
    }
    if (!Collection.class.isAssignableFrom(property.getType()) && !Map.class.isAssignableFrom(property.getType()))
      throw new IllegalArgumentException("The '" + propertyName + "' property on the " + type.getName()
        + " class must be a Collection or Map: " + property.getType());
    propertyToElementType.put(property, elementType);
  }
View Full Code Here

   * found. */
  public void setPropertyDefaultType (Class type, String propertyName, Class defaultType) {
    if (type == null) throw new IllegalArgumentException("type cannot be null.");
    if (propertyName == null) throw new IllegalArgumentException("propertyName cannot be null.");
    if (defaultType == null) throw new IllegalArgumentException("defaultType cannot be null.");
    Property property = null;
    Exception cause = null;
    try {
      property = Beans.getProperty(type, propertyName, beanProperties, privateFields, this);
    } catch (IntrospectionException ex) {
      cause = ex;
View Full Code Here

          if (!isExplicitKey) value = readValue(elementType, null, null);
          ((Map)object).put(key, value);
        } else {
          // Set field on object.
          try {
            Property property = Beans.getProperty(type, (String)key, config.beanProperties, config.privateFields, config);
            if (property == null)
              throw new YamlReaderException("Unable to find property '" + key + "' on class: " + type.getName());
            Class propertyElementType = config.propertyToElementType.get(property);
            Class propertyDefaultType = config.propertyToDefaultType.get(property);
            if (!isExplicitKey) value = readValue(property.getType(), propertyElementType, propertyDefaultType);
            property.set(object, value);
          } catch (Exception ex) {
            if (ex instanceof YamlReaderException) throw (YamlReaderException)ex;
            throw new YamlReaderException("Error setting property '" + key + "' on class: " + type.getName(), ex);
          }
        }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.yamlbeans.Beans.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.