org.yaml.snakeyaml.introspector.Property类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.yaml.snakeyaml.introspector.Property类的一些代码示例,展示了Property类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property类的具体详情如下:
包路径:org.yaml.snakeyaml.introspector.Property
类名称:Property

Property介绍

[英]A Property represents a single member variable of a class, possibly including its accessor methods (getX, setX). The name stored in this class is the actual name of the property as given for the class, not an alias.

Objects of this class have a total ordering which defaults to ordering based on the name of the property.
[中]Property表示类的单个成员变量,可能包括其访问器方法(getX、setX)。存储在该类中的名称是为该类指定的属性的实际名称,而不是别名。
此类对象的总排序默认为基于属性名称的排序。

代码示例

代码示例来源:origin: redisson/redisson

@Override
public String toString() {
  return getName() + " of " + getType();
}

代码示例来源:origin: redisson/redisson

@Override
public Object get(Object object) {
  try {
    if (read != null) {
      return read.invoke(object);
    } else if (field != null) {
      return field.get(object);
    }
  } catch (Exception e) {
    throw new YAMLException("Unable to find getter for property '" + getName()
        + "' on object " + object + ":" + e);
  }
  if (delegate != null) {
    return delegate.get(object);
  }
  throw new YAMLException("No getter or delegate for property '" + getName() + "' on object "
      + object);
}

代码示例来源:origin: redisson/redisson

: memberDescription.getProperty(key);
if (!property.isWritable()) {
  throw new YAMLException("No writable property '" + key + "' on class: "
      + beanType.getName());
valueNode.setType(property.getType());
final boolean typeDetected = (memberDescription != null)
    ? memberDescription.setupPropertyType(key, valueNode)
if (!typeDetected && valueNode.getNodeId() != NodeId.scalar) {
  Class<?>[] arguments = property.getActualTypeArguments();
  if (arguments != null && arguments.length > 0) {
if (property.getType() == Float.TYPE || property.getType() == Float.class) {
  if (value instanceof Double) {
    value = ((Double) value).floatValue();
if (property.getType() == String.class && Tag.BINARY.equals(valueNode.getTag())
    && value instanceof byte[]) {
  value = new String((byte[]) value);
  property.set(object, value);

代码示例来源:origin: redisson/redisson

protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) {
  Set<Property> properties = new TreeSet<Property>();
  Collection<Property> props = getPropertiesMap(type, bAccess).values();
  for (Property property : props) {
    if (property.isReadable() && (allowReadOnlyProperties || property.isWritable())) {
      properties.add(property);
    }
  }
  return properties;
}

代码示例来源:origin: redisson/redisson

if (!excludes.contains(property.getName())) {
    dumpProperties.add(property);
if (!excludes.contains(property.getName()) && property.isReadable()) {
  dumpProperties.add(property);
if (!excludes.contains(property.getName())) {
  dumpProperties.add(property);

代码示例来源:origin: redisson/redisson

@Override
public String getName() {
  final String n = super.getName();
  if (n != null) {
    return n;
  }
  return delegate != null ? delegate.getName() : null;
}

代码示例来源:origin: org.sonatype.pmaven/pmaven-yaml

for ( Property property : properties )
  ScalarNode nodeKey = (ScalarNode) representData( property.getName() );
  Object memberValue = property.get( javaBean );
  boolean hasAlias = false;
  if ( representedObjects.containsKey( memberValue ) )
      if ( property.getType() == memberValue.getClass() )

代码示例来源:origin: CodeCrafter47/BungeeTabListPlus

private TypeDescription computeTypeDescription(Class<?> clazz) {
  TypeDescription typeDescription = new TypeDescription(clazz, new Tag(clazz));
  Set<Property> properties = null;
  try {
    properties = getPropertyUtils().getProperties(clazz);
  } catch (IntrospectionException e) {
    e.printStackTrace();
  }
  if (properties != null) {
    for (Property property : properties) {
      if (Collection.class.isAssignableFrom(property.getType()) || property.getClass().isArray()) {
        Class<?>[] typeArguments = property.getActualTypeArguments();
        if (typeArguments != null && typeArguments.length == 1 && typeArguments[0] != null) {
          typeDescription.putListPropertyType(property.getName(), typeArguments[0]);
        }
      }
      if (Map.class.isAssignableFrom(property.getType())) {
        Class<?>[] typeArguments = property.getActualTypeArguments();
        if (typeArguments != null && typeArguments.length == 2 && typeArguments[0] != null && typeArguments[1] != null) {
          typeDescription.putMapPropertyType(property.getName(), typeArguments[0], typeArguments[1]);
        }
      }
    }
  }
  return typeDescription;
}

代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml

try {
  Property property = getProperty(beanType, key);
  valueNode.setType(property.getType());
  TypeDescription memberDescription = typeDefinitions.get(beanType);
  boolean typeDetected = false;
        snode.setListType(memberType);
        typeDetected = true;
      } else if (property.getType().isArray()) {
        snode.setListType(property.getType().getComponentType());
        typeDetected = true;
    Class<?>[] arguments = property.getActualTypeArguments();
    if (arguments != null && arguments.length > 0) {
        mnode.setOnlyKeyType(t);
        mnode.setUseClassConstructor(true);
      } else if (property.getType().isAssignableFrom(Map.class)) {
        Class<?> ketType = arguments[0];
        Class<?> valueType = arguments[1];
  if (property.getType() == Float.TYPE || property.getType() == Float.class) {
    if (value instanceof Double) {
      value = ((Double) value).floatValue();
  if (property.getType() == String.class && Tag.BINARY.equals(valueNode.getTag()) && value instanceof byte[]) {
    value = new String((byte[])value);
  property.set(object, value);

代码示例来源:origin: redisson/redisson

protected void setProperties(Object bean, Map<String, Object> data) throws Exception {
  if (data == null) {
    throw new NullPointerException("Data for Compact Object Notation cannot be null.");
  }
  for (Map.Entry<String, Object> entry : data.entrySet()) {
    String key = entry.getKey();
    Property property = getPropertyUtils().getProperty(bean.getClass(), key);
    try {
      property.set(bean, entry.getValue());
    } catch (IllegalArgumentException e) {
      throw new YAMLException("Cannot set property='" + key + "' with value='"
          + data.get(key) + "' (" + data.get(key).getClass() + ") in " + bean);
    }
  }
}

代码示例来源:origin: redisson/redisson

@Override
public Class<?>[] getActualTypeArguments() {
  if (parameters == null && delegate != null) {
    return delegate.getActualTypeArguments();
  }
  return parameters;
}

代码示例来源:origin: redisson/redisson

@Override
public Class<?> getType() {
  final Class<?> t = super.getType();
  if (t != null) {
    return t;
  }
  return delegate != null ? delegate.getType() : null;
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isWritable() {
  return (write != null) || (field != null) || (delegate != null && delegate.isWritable());
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isReadable() {
  return (read != null) || (field != null) || (delegate != null && delegate.isReadable());
}

代码示例来源:origin: redisson/redisson

public int compareTo(Property o) {
  return getName().compareTo(o.getName());
}

代码示例来源:origin: io.tesla.polyglot/tesla-polyglot-yaml

for ( Property property : properties )
  ScalarNode nodeKey = (ScalarNode) representData( property.getName() );
  Object memberValue = property.get( javaBean );
  boolean hasAlias = false;
  if ( representedObjects.containsKey( memberValue ) )
      if ( property.getType() == memberValue.getClass() )

代码示例来源:origin: harbby/presto-connectors

try {
  Property property = getProperty(beanType, key);
  valueNode.setType(property.getType());
  TypeDescription memberDescription = typeDefinitions.get(beanType);
  boolean typeDetected = false;
        snode.setListType(memberType);
        typeDetected = true;
      } else if (property.getType().isArray()) {
        snode.setListType(property.getType().getComponentType());
        typeDetected = true;
    Class<?>[] arguments = property.getActualTypeArguments();
    if (arguments != null && arguments.length > 0) {
        mnode.setOnlyKeyType(t);
        mnode.setUseClassConstructor(true);
      } else if (property.getType().isAssignableFrom(Map.class)) {
        Class<?> ketType = arguments[0];
        Class<?> valueType = arguments[1];
  if (property.getType() == Float.TYPE || property.getType() == Float.class) {
    if (value instanceof Double) {
      value = ((Double) value).floatValue();
  property.set(object, value);
} catch (Exception e) {
  throw new ConstructorException("Cannot create property=" + key

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

if (!excludes.contains(property.getName())) {
    dumpProperties.add(property);
if (!excludes.contains(property.getName()) && property.isReadable()) {
  dumpProperties.add(property);
if (!excludes.contains(property.getName())) {
  dumpProperties.add(property);

代码示例来源:origin: redisson/redisson

field.set(object, value);
} else if (delegate != null) {
  delegate.set(object, value);
} else {
  log.warning("No setter/delegate for '" + getName() + "' on object " + object);

代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml

protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
    throws IntrospectionException {
  Set<Property> properties = new TreeSet<Property>();
  Collection<Property> props = getPropertiesMap(type, bAccess).values();
  for (Property property : props) {
    if (property.isReadable() && (allowReadOnlyProperties || property.isWritable())) {
      properties.add(property);
    }
  }
  return properties;
}

相关文章