Returns the {@link Query} annotation's attribute casted to the given type or default value if no annotation
available.

@param attribute
@param type
@return
767046
private <T> T getAnnotationValue(String attribute, Class<T> type) {

		Query annotation = method.getAnnotation(Query.class);
		Object value = annotation == null ? AnnotationUtils.getDefaultValue(Query.class, attribute) : AnnotationUtils
				.getValue(annotation, attribute);

		return type.cast(value);
	}
1037016
@DefinedBy(Api.LANGUAGE_MODEL)
    public <A extends Annotation> A getAnnotation(Class<A> annoType) {

        if (!annoType.isAnnotation())
            throw new IllegalArgumentException("Not an annotation type: " + annoType);

        Attribute.Compound c = getAttribute(annoType);
        return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType);
    }
1220941
static Jsii tryGetJsiiAnnotation(final Class<?> type, final boolean inherited) {
        Jsii[] ann;

        if (inherited) {
            ann = (Jsii[]) type.getAnnotationsByType(Jsii.class);
        } else {
            ann = (Jsii[]) type.getDeclaredAnnotationsByType(Jsii.class);
        }

        if (ann.length == 0) {
            return null;
        }

        return ann[0];
    }
725256
public static Object getAnnotationAttribute(final Annotation annotation, final String attributeName) {
        Object object = null;
        try {
            // Get the annotation method for the given name
            final Method attributeMethod = annotation.annotationType().getDeclaredMethod(attributeName);

            // Call the method to gets the value
            object = attributeMethod.invoke(annotation);

        } catch (NoSuchMethodException | SecurityException e) {
            LOGGER.log(NO_ANNOTATION_PROPERTY, e, attributeName);
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            LOGGER.log(NO_ANNOTATION_PROPERTY_VALUE, e, attributeName);
        }
        return object;
    }
266434
public static boolean isNullValue(Entity entity, Attribute attribute) {
    boolean isNullValue;
    String attributeName = attribute.getName();
    AttributeType attributeType = attribute.getDataType();
    switch (attributeType) {
      case BOOL:
        isNullValue = entity.getBoolean(attributeName) == null;
        break;
      case CATEGORICAL:
      case FILE:
      case XREF:
        isNullValue = entity.getEntity(attributeName) == null;
        break;
      case CATEGORICAL_MREF:
      case MREF:
      case ONE_TO_MANY:
        Iterable<Entity> refEntities = entity.getEntities(attributeName);
        isNullValue = Iterables.isEmpty(refEntities);
        break;
      case COMPOUND:
        throw new RuntimeException(format("Invalid data type [%s]", attribute.getDataType()));
      case DATE:
        isNullValue = entity.getLocalDate(attributeName) == null;
        break;
      case DATE_TIME:
        isNullValue = entity.getInstant(attributeName) == null;
        break;
      case DECIMAL:
        isNullValue = entity.getDouble(attributeName) == null;
        break;
      case EMAIL:
      case ENUM:
      case HTML:
      case HYPERLINK:
      case SCRIPT:
      case STRING:
      case TEXT:
        isNullValue = entity.getString(attributeName) == null;
        break;
      case INT:
        isNullValue = entity.getInt(attributeName) == null;
        break;
      case LONG:
        isNullValue = entity.getLong(attributeName) == null;
        break;
      default:
        throw new UnexpectedEnumException(attributeType);
    }
    return isNullValue;
  }
530806
public static Boolean getAnnotationAttributeAsBoolean(ModelWithAnnotation model, Class<? extends Annotation> annotation, AnnotationAttributeType attribute, Boolean defaultValue) {
		return getAnnotationAttribute(model, annotation, attribute, defaultValue, new OnAnnotationAttributeListener<Boolean>() {

			@Override
			public Boolean onFound(String value) {
				return Boolean.valueOf(value);
			}
		});
	}
253893
@Pure
	protected Attribute getStoredAttribute(String name, AttributeType expectedType) {
		Object val = this.heap.get(name);
		if (val != null) {
			final AttributeType currentType = AttributeType.fromValue(val);
			val = unprotectNull(val);
			final Attribute attr = new AttributeImpl(name);
			if (expectedType == null) {
				attr.castAndSet(currentType, val);
			} else {
				attr.castAndSet(expectedType, val);
			}
			return attr;
		}
		return null;
	}
542012
public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type, final JavacNode node) {
		return createAnnotation(type, (JCAnnotation) node.get(), node);
	}
60622
@SuppressWarnings("unchecked")
    public <T> T getAttribute( String attrName, Class<T> adaptee ) {
        if (attrName == null) {
            return null;
        }
        if (adaptee == null) {
            adaptee = (Class<T>) String.class;
        }

        Object attribute = feature.getAttribute(attrName);
        if (attribute == null) {
            return null;
        }
        if (attribute instanceof Number) {
            Number num = (Number) attribute;
            if (adaptee.isAssignableFrom(Double.class)) {
                return adaptee.cast(num.doubleValue());
            } else if (adaptee.isAssignableFrom(Float.class)) {
                return adaptee.cast(num.floatValue());
            } else if (adaptee.isAssignableFrom(Integer.class)) {
                return adaptee.cast(num.intValue());
            } else if (adaptee.isAssignableFrom(Long.class)) {
                return adaptee.cast(num.longValue());
            } else if (adaptee.isAssignableFrom(String.class)) {
                return adaptee.cast(num.toString());
            } else {
                throw new IllegalArgumentException();
            }
        } else if (attribute instanceof String) {
            if (adaptee.isAssignableFrom(Double.class)) {
                try {
                    Double parsed = Double.parseDouble((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(Float.class)) {
                try {
                    Float parsed = Float.parseFloat((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(Integer.class)) {
                try {
                    Integer parsed = Integer.parseInt((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(String.class)) {
                return adaptee.cast(attribute);
            } else {
                throw new IllegalArgumentException();
            }
        } else if (attribute instanceof Geometry) {
            return null;
        } else {
            throw new IllegalArgumentException("Can't adapt attribute of type: " + attribute.getClass().getCanonicalName());
        }
    }
1278838
public static AnnotationAttributes getAnnotationAttributes(Annotation annotation, boolean classValuesAsString,
			boolean nestedAnnotationsAsMap) {

		AnnotationAttributes attrs = new AnnotationAttributes();
		Method[] methods = annotation.annotationType().getDeclaredMethods();
		for (Method method : methods) {
			if (method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
				try {
					Object value = method.invoke(annotation);
					attrs.put(method.getName(), adaptValue(value, classValuesAsString, nestedAnnotationsAsMap));
				}
				catch (Exception ex) {
					throw new IllegalStateException("Could not obtain annotation attribute values", ex);
				}
			}
		}
		return attrs;
	}
871967
public static <A extends Annotation> A getAnnotation(Field field, Class<A> annotationType) {
        if (field == null || annotationType == null) {
            return null;
        }

        return field.getAnnotation(annotationType);
    }
383401
protected byte[] getThriftColumnValue(Object e, Attribute attribute)
    {
        byte[] value = null;
        Field field = (Field) ((Attribute) attribute).getJavaMember();
        try
        {
            if (attribute != null && field.get(e) != null)
            {

                if (CassandraDataTranslator.isCassandraDataTypeClass(((AbstractAttribute) attribute)
                        .getBindableJavaType()))
                {
                    value = CassandraDataTranslator.compose(((AbstractAttribute) attribute).getBindableJavaType(),
                            field.get(e), false);
                }
                else
                {
                    value = PropertyAccessorHelper.get(e, field);
                }
            }
        }
        catch (IllegalArgumentException iae)
        {
            log.error("Error while persisting data, Caused by: .", iae);
            throw new IllegalArgumentException(iae);
        }
        catch (IllegalAccessException iace)
        {
            log.error("Error while persisting data, Caused by: .", iace);
        }
        return value;
    }
387110
public static TypeDefinition searchAttributeType(TypeDefinition containerType, String attributeName) {
		try {
			Field f = containerType.getBase().getField(attributeName);
			if ((f.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) != 0)
				return new TypeDefinition(containerType, f.getGenericType());
		} catch (Throwable t) { /* ignore */ }
		try {
			Method m = containerType.getBase()
				.getMethod("get" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1));
			Class<?> returnType = m.getReturnType();
			if (returnType != null && !Void.class.equals(returnType) && !void.class.equals(returnType))
				return new TypeDefinition(containerType, m.getGenericReturnType());
		} catch (Throwable t) { /* ignore */ }
		try {
			Method m = containerType.getBase()
				.getMethod("is" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1));
			Class<?> returnType = m.getReturnType();
			if (boolean.class.equals(returnType) || Boolean.class.equals(returnType))
				return new TypeDefinition(containerType, m.getGenericReturnType());
		} catch (Throwable t) { /* ignore */ }
		return null;
	}
1097442
protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) {
        String name = annoType.getName();

        for (Attribute.Compound anno : getAnnotationMirrors()) {
            if (name.equals(anno.type.tsym.flatName().toString()))
                return anno;
        }

        return null;
    }
1247409
public void assignType(XAttribute attribute, String type) {
		if (type != null && type.trim().length() > 0) {
			XAttributeLiteral attr = (XAttributeLiteral) ATTR_TYPE.clone();
			attr.setValue(type);
			attribute.getAttributes().put(KEY_TYPE, attr);
		}
	}
31849
public String queryAttribute(String property) {
        try {
            Object oldValue = null;
            if (property.charAt(0) == RpcConstants.HIDE_KEY_PREFIX) {
                // 方法级配置 例如.echoStr.timeout
                String methodAndP = property.substring(1);
                int index = methodAndP.indexOf(RpcConstants.HIDE_KEY_PREFIX);
                if (index <= 0) {
                    throw ExceptionUtils.buildRuntime(property, "", "Unknown query attribute key!");
                }
                String methodName = methodAndP.substring(0, index);
                String methodProperty = methodAndP.substring(index + 1);
                MethodConfig methodConfig = getMethodConfig(methodName);
                if (methodConfig != null) {
                    Method getMethod = ReflectUtils.getPropertyGetterMethod(MethodConfig.class, methodProperty);
                    Class propertyClazz = getMethod.getReturnType(); // 旧值的类型
                    oldValue = BeanUtils.getProperty(methodConfig, methodProperty, propertyClazz);
                }
            } else { // 接口级配置 例如timeout
                // 先通过get方法找到类型
                Method getMethod = ReflectUtils.getPropertyGetterMethod(getClass(), property);
                Class propertyClazz = getMethod.getReturnType(); // 旧值的类型
                // 拿到旧的值
                oldValue = BeanUtils.getProperty(this, property, propertyClazz);
            }
            return oldValue == null ? null : oldValue.toString();
        } catch (Exception e) {
            throw new SofaRpcRuntimeException("Exception when query attribute, The key is " + property, e);
        }
    }
854451
public static String getDefaultJdbcTypeFor(String javaType)
    {
        return _jdbcMappings.containsKey(javaType) ? (String)_jdbcMappings.get(javaType) : JDBC_DEFAULT_TYPE;
    }