当前位置: 首页>>代码示例>>Java>>正文


Java PropertyAccessor类代码示例

本文整理汇总了Java中org.springframework.beans.PropertyAccessor的典型用法代码示例。如果您正苦于以下问题:Java PropertyAccessor类的具体用法?Java PropertyAccessor怎么用?Java PropertyAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertyAccessor类属于org.springframework.beans包,在下文中一共展示了PropertyAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deepValue

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * This follows a path (like object.childobject.value), to its end value, so it can compare the values of two
 * paths.
 * This method follows the path recursively until it reaches the end value.
 *
 * @param object object to search
 * @param path   path of value
 * @return result
 */
private Object deepValue(final Object object, final String path) {
    final List<String> paths = new LinkedList<>(Arrays.asList(path.split("\\.")));
    final String currentPath = paths.get(0);

    final PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(object);
    Object field = accessor.getPropertyValue(currentPath);

    paths.remove(0);

    if ((field != null) && (!paths.isEmpty())) {
        field = deepValue(field, String.join(".", paths));
    }

    return field;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:25,代码来源:EntitySearch.java

示例2: writeToEntity

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Write the value to the existingEntity field with the name of key
 *
 * @param <T>            Type of the entity
 * @param existingEntity The entity we are changing
 * @param key            The key we are changing
 * @param value          The new value
 */
private <T extends BaseEntity> void writeToEntity(T existingEntity, String key, Object value) {
    final PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(existingEntity);

    if (accessor.getPropertyType(key) != null) {
        try {
            if (value.getClass().equals(JSONObject.class) &&
                    ((JSONObject) value).has("_isMap") &&
                    ((JSONObject) value).get("_isMap").equals(true)) {
                writeArrayMapToEntity(accessor, key, (JSONObject) value);
            } else if (value.getClass().equals(JSONObject.class)) {
                writeObjectToEntity(accessor, key, (JSONObject) value);
            } else if (value.getClass().equals(JSONArray.class)) {
                writeArrayToEntity(accessor, key, (JSONArray) value);
            } else if (isFieldValid(accessor, key, existingEntity.getClass())) {
                writeValueToEntity(accessor, key, value);
            }
        } catch (JSONException e) {
            logger.info("[FormParse] [writeToEntity] Unable To Process JSON", e);
        }
    }
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:30,代码来源:FormParse.java

示例3: hasRestrictionOnField

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
protected boolean hasRestrictionOnField(Query query, String fieldName) {
	for (Restriction<PropertyAccessor> restriction : query.getRestrictions()) {
		if (restriction instanceof FieldCondition) {
			if (fieldName.equals(((FieldCondition) restriction).getFieldName())) {
				return true;
			}
		} else if (restriction instanceof DisjunctionCondition) {
			for (Query subQuery : ((DisjunctionCondition) restriction).getQueries()) {
				if (hasRestrictionOnField(subQuery, fieldName)) {
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:17,代码来源:QueryNarrowerStrategyFieldBased.java

示例4: getLastPropertySeparatorIndex

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Returns the index of the last nested property separator in the given
 * property path, ignoring dots in keys (like "map[my.key]").
 */
protected int getLastPropertySeparatorIndex(String propertyPath) {
	boolean inKey = false;
	for (int i = propertyPath.length() - 1; i >= 0; i--) {
		switch (propertyPath.charAt(i)) {
		case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
			inKey = true;
			break;
		case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
			return i;
		case PropertyAccessor.NESTED_PROPERTY_SEPARATOR_CHAR:
			if (!inKey) {
				return i;
			}
			break;
		}
	}
	return -1;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:23,代码来源:AbstractPropertyAccessStrategy.java

示例5: isReadableProperty

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
public boolean isReadableProperty(String propertyPath) {
	if (PropertyAccessorUtils.isNestedProperty(propertyPath)) {
		String baseProperty = getBasePropertyName(propertyPath);
		String childPropertyPath = getChildPropertyPath(propertyPath);
		if (!super.isReadableProperty(baseProperty)) {
			return false;
		}
		else {
			return ((PropertyAccessor) childPropertyAccessors.get(baseProperty))
					.isReadableProperty(childPropertyPath);
		}
	}
	else {
		return super.isReadableProperty(propertyPath);
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:17,代码来源:AbstractNestedMemberPropertyAccessor.java

示例6: getNestingLevel

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
public static int getNestingLevel(String propertyName) {
    propertyName = getPropertyName(propertyName);
    int nestingLevel = 0;
    boolean inKey = false;
    for (int i = 0; i < propertyName.length(); i++) {
        switch (propertyName.charAt(i)) {
        case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
            if (!inKey) {
                nestingLevel++;
            }
        case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
            inKey = !inKey;
        }
    }
    return nestingLevel;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:17,代码来源:PropertyAccessorUtils.java

示例7: autobind

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
public void autobind(Object view) {
	BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(getModel());
	PropertyAccessor  viewPropertyAccessor = new DirectFieldAccessor(view);
	// iterate on model properties
	for (PropertyDescriptor pd : bw.getPropertyDescriptors()) {
		String propertyName = pd.getName();
		if ( !ignoredProperties.contains(propertyName) && viewPropertyAccessor.isReadableProperty(propertyName)) {
			Object control = viewPropertyAccessor.getPropertyValue(propertyName);
			if (control != null) {
				if (log.isDebugEnabled()) 
					log.debug("Found control: " + control.getClass().getSimpleName() + 
							" for property: " + propertyName);
				bind(control, propertyName);
			}
		}
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:18,代码来源:CompositeBinder.java

示例8: isValid

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
@Override
public boolean isValid(final WithId<?> value, final ConstraintValidatorContext context) {
    if (value == null) {
        return true;
    }

    final PropertyAccessor bean = new BeanWrapperImpl(value);

    final String propertyValue = String.valueOf(bean.getPropertyValue(property));

    @SuppressWarnings({"rawtypes", "unchecked"})
    final Class<WithId> modelClass = (Class) value.getKind().modelClass;

    @SuppressWarnings("unchecked")
    final Set<String> ids = dataManager.fetchIdsByPropertyValue(modelClass, property, propertyValue);

    final boolean isUnique = ids.isEmpty() || value.getId().map(id -> ids.contains(id)).orElse(false);

    if (!isUnique) {
        if (ids.stream().allMatch(id -> consideredValidByException(modelClass, id))) {
            return true;
        }

        context.disableDefaultConstraintViolation();
        context.unwrap(HibernateConstraintValidatorContext.class).addExpressionVariable("nonUnique", propertyValue)
            .buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate())
            .addPropertyNode(property).addConstraintViolation();
    }

    return isUnique;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:32,代码来源:UniquePropertyValidator.java

示例9: writeValueToEntity

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Write normal value to entity.
 *
 * @param accessor The accessor for the existing entity
 * @param key      The fields name we are overwriting
 * @param value    The new value
 */
private void writeValueToEntity(final PropertyAccessor accessor,
                                final String key,
                                final Object value) {
    final ResolvableType type = accessor.getPropertyTypeDescriptor(key).getResolvableType();

    accessor.setPropertyValue(key, parseValue(value, type));
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:15,代码来源:FormParse.java

示例10: isFieldEditable

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Is the field editable according to the SchemaView annotation
 *
 * @param accessor the accessor
 * @param key      the key
 * @return boolean boolean
 */
private Boolean isFieldEditable(final PropertyAccessor accessor, final String key) {
    final SchemaView schemaView = accessor.getPropertyTypeDescriptor(key).getAnnotation(SchemaView.class);

    if (schemaView != null) {
        final boolean isLocked = schemaView.locked() && accessor.getPropertyValue(key) != null;
        final boolean isVisible = schemaView.visible();

        return !isLocked && isVisible;
    }

    return false;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:20,代码来源:FormParse.java

示例11: setPath

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Set the path that this tag should apply.
 * <p>E.g. "customer" to allow bind paths like "address.street"
 * rather than "customer.address.street".
 * @see BindTag#setPath
 */
public void setPath(String path) {
	if (path == null) {
		path = "";
	}
	if (path.length() > 0 && !path.endsWith(PropertyAccessor.NESTED_PROPERTY_SEPARATOR)) {
		path += PropertyAccessor.NESTED_PROPERTY_SEPARATOR;
	}
	this.path = path;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:NestedPathTag.java

示例12: getBindStatus

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
/**
 * Get the {@link BindStatus} for this tag.
 */
protected BindStatus getBindStatus() throws JspException {
	if (this.bindStatus == null) {
		// HTML escaping in tags is performed by the ValueFormatter class.
		String nestedPath = getNestedPath();
		String pathToUse = (nestedPath != null ? nestedPath + getPath() : getPath());
		if (pathToUse.endsWith(PropertyAccessor.NESTED_PROPERTY_SEPARATOR)) {
			pathToUse = pathToUse.substring(0, pathToUse.length() - 1);
		}
		this.bindStatus = new BindStatus(getRequestContext(), pathToUse, false);
	}
	return this.bindStatus;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AbstractDataBoundFormElementTag.java

示例13: getDirectoryService

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
private Directory getDirectoryService() {
  HttpTransport httpTransport = new NetHttpTransport();
  JacksonFactory jacksonFactory = new JacksonFactory();
  GoogleCredential credential = getGoogleCredential();

  PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(credential);
  accessor.setPropertyValue("serviceAccountUser", config.getAdminUsername());
  accessor.setPropertyValue("serviceAccountScopes", SERVICE_ACCOUNT_SCOPES);

  return new Directory.Builder(httpTransport, jacksonFactory, credential)
      .setApplicationName("Spinnaker-Fiat")
      .build();
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:14,代码来源:GoogleDirectoryUserRolesProvider.java

示例14: overrideEnableFallback

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
@Test
public void overrideEnableFallback() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.enableFallback:true");
	assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.TRUE);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例15: overrideNormalPrefix

import org.springframework.beans.PropertyAccessor; //导入依赖的package包/类
@Test
public void overrideNormalPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalPrefix:normal/");
	assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("normal/");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java


注:本文中的org.springframework.beans.PropertyAccessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。