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


Java BeanUtil类代码示例

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


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

示例1: get

import jodd.bean.BeanUtil; //导入依赖的package包/类
@Override
public Object get(Object bean) {
    PropertyNode currentNode = this;
    Object currentBean = bean;

    while (!currentNode.isLeafNode() && currentNode.next() != null) {
        currentBean = BeanUtil.getProperty(currentBean, currentNode.name());
        currentNode = currentNode.next();
    }

    if (currentNode.isLeafNode() && currentBean != null) {
        return BeanUtil.getProperty(currentBean, currentNode.name());
    } else {
        return null;
    }
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:17,代码来源:DefaultPropertyNode.java

示例2: validate

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
 * Performs validation of provided validation context and appends violations.
 */
public List<Violation> validate(ValidationContext ctx, Object target, String targetName) {
	for (Map.Entry<String, List<Check>> entry : ctx.map.entrySet()) {
		String name = entry.getKey();
		Object value = BeanUtil.declaredSilent.getProperty(target, name);
		String valueName = targetName != null ? (targetName + '.' + name) : name;		// move up
		ValidationConstraintContext vcc = new ValidationConstraintContext(this, target, valueName);
		
		for (Check check : entry.getValue()) {
			String[] checkProfiles = check.getProfiles();
			if (!matchProfiles(checkProfiles)) {
				continue;
			}
			if (check.getSeverity() < severity) {
				continue;
			}
			ValidationConstraint constraint = check.getConstraint();
			if (!constraint.isValid(vcc, value)) {
				addViolation(new Violation(valueName, target, value, check));
			}
		}
	}

	return getViolations();
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:28,代码来源:Vtor.java

示例3: instanceFirstInit

import jodd.bean.BeanUtil; //导入依赖的package包/类
public static <T extends Object> T instanceFirstInit(final Class<T> klass) {
  try {
    T _xblockexpression = null;
    {
      final T instance = klass.newInstance();
      Field[] _declaredFields = klass.getDeclaredFields();
      final Consumer<Field> _function = (Field field) -> {
        String _name = field.getName();
        String _name_1 = field.getName();
        Object _firstInitFrom = MockHelper.firstInitFrom(_name_1);
        BeanUtil.setDeclaredProperty(instance, _name, _firstInitFrom);
      };
      ((List<Field>)Conversions.doWrapArray(_declaredFields)).forEach(_function);
      _xblockexpression = instance;
    }
    return _xblockexpression;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:East196,项目名称:maker,代码行数:21,代码来源:MockHelper.java

示例4: instanceSecondInit

import jodd.bean.BeanUtil; //导入依赖的package包/类
public static <T extends Object> T instanceSecondInit(final T instance) {
  T _xblockexpression = null;
  {
    Class<?> _class = instance.getClass();
    Field[] _declaredFields = _class.getDeclaredFields();
    final Consumer<Field> _function = (Field field) -> {
      String _name = field.getName();
      String _name_1 = field.getName();
      Object _secondInitFrom = MockHelper.secondInitFrom(_name_1, instance);
      BeanUtil.setDeclaredProperty(instance, _name, _secondInitFrom);
    };
    ((List<Field>)Conversions.doWrapArray(_declaredFields)).forEach(_function);
    _xblockexpression = instance;
  }
  return _xblockexpression;
}
 
开发者ID:East196,项目名称:maker,代码行数:17,代码来源:MockHelper.java

示例5: testKeyword

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
  This method tests, if the test-value for keyword is copied into the xml document.
 */
@Test
public void testKeyword() {

	BeanUtil.setProperty(smlKeyword, "keyword","testkeyword");
	multiSmlKeyword.getItems().add(smlKeyword);
	Document doc = beanTransformerService.mergeToISO(multiSmlKeyword,mRefDatasetDocument);
	multiSmlKeyword.getItems().remove(smlKeyword);
	Source beanSource = new DOMSource(doc);
	try {
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:keywords/sml:KeywordList/sml:keyword[text()='testkeyword']",
						usingNamespaces));
	} catch (NoSuchMethodError e) {
		LOG.error("Possibly XPath is invalid with compared source", e);
		throw e;
	}

}
 
开发者ID:52North,项目名称:smartSensorEditor,代码行数:24,代码来源:SmlXsltTest.java

示例6: testIdentifer

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
  This method tests, if the test-value for uniqueId is copied into the xml document.
 */
@Test
public void testIdentifer() {
	BeanUtil.setProperty(smlIdentifier, "id", "testIdentifier");

	Document doc = beanTransformerService.mergeToISO(smlIdentifier,
			mRefDatasetDocument);
	Source beanSource = new DOMSource(doc);
	try {
		assertThat(
				beanSource,
				hasXPath(
						"/sml:PhysicalSystem/gml:identifier[text()='testIdentifier']",
						usingNamespaces));
	} catch (NoSuchMethodError e) {
		LOG.error("Possibly XPath is invalid with compared source", e);
		throw e;
	}

}
 
开发者ID:52North,项目名称:smartSensorEditor,代码行数:23,代码来源:SmlXsltTest.java

示例7: set

import jodd.bean.BeanUtil; //导入依赖的package包/类
@Override
public void set(Object bean, Object value) {
    if (!isLeaf) {
        Object nodeBean = BeanUtil.getProperty(bean, name);

        if (nodeBean == null) {
            nodeBean = injector.getInstance(type);
            BeanUtil.setProperty(bean, name, nodeBean);
        }

        next.set(nodeBean, value);
    } else {
        BeanUtil.setProperty(bean, name, validValue(value, type));
    }
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:DefaultPropertyNode.java

示例8: getClassPK

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
 * If 'entry' is null it should return default parent value.
 * 
 * @param entry
 * @return
 */
protected Object getClassPK(Object entry) {
	if (Validator.isNull(entry)) {
		return 0L;
	}

	return BeanUtil.getDeclaredProperty(entry, getClassPKName());
}
 
开发者ID:sorin-pop,项目名称:data-manipulator,代码行数:14,代码来源:BaseHandler.java

示例9: getClassPK

import jodd.bean.BeanUtil; //导入依赖的package包/类
@Override
protected Object getClassPK(Object entry) {
	if (Validator.isNull(entry)) {
		return StringPool.BLANK;
	}

	return BeanUtil.getDeclaredProperty(entry, getClassPKName());
}
 
开发者ID:sorin-pop,项目名称:data-manipulator,代码行数:9,代码来源:JournalArticleHandler.java

示例10: getHystrixThreadPoolPropertiesSetter

import jodd.bean.BeanUtil; //导入依赖的package包/类
private HystrixThreadPoolProperties.Setter getHystrixThreadPoolPropertiesSetter(
		com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand hystrixCommand) {
	HystrixThreadPoolProperties.Setter commandPropertiesDefaults = HystrixThreadPoolProperties.defaultSetter();

	if (hystrixCommand.threadPoolProperties() == null || hystrixCommand.threadPoolProperties().length == 0) {
		return commandPropertiesDefaults;
	}
	Map<String, Object> commandProperties = new HashMap<String, Object>();
	for (HystrixProperty commandProperty : hystrixCommand.threadPoolProperties()) {
		commandProperties.put(commandProperty.name(), commandProperty.value());
			BeanUtil.setDeclaredProperty(commandPropertiesDefaults, commandProperty.name(),
					commandProperty.value());
	}
	return commandPropertiesDefaults;
}
 
开发者ID:xiaomin0322,项目名称:spring-integration-hystrix,代码行数:16,代码来源:HystrixCommandAspect.java

示例11: validate

import jodd.bean.BeanUtil; //导入依赖的package包/类
public static boolean validate(Object target, Object value, String fieldName) {
	if (value == null) {
		return true;
	}
	Object valueToCompare;
	try {
		valueToCompare = BeanUtil.declared.getProperty(target, fieldName);
	} catch (BeanException bex) {
		throw new VtorException("Invalid value: " + fieldName, bex);
	}
	if (valueToCompare == null) {
		return false;
	}
	return value.equals(valueToCompare);
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:16,代码来源:EqualToDeclaredFieldConstraint.java

示例12: validate

import jodd.bean.BeanUtil; //导入依赖的package包/类
public static boolean validate(Object target, Object value, String fieldName) {
	if (value == null) {
		return true;
	}
	Object valueToCompare;
	try {
		valueToCompare = BeanUtil.pojo.getProperty(target, fieldName);
	} catch (BeanException bex) {
		throw new VtorException("Invalid value: " + fieldName, bex);
	}
	if (valueToCompare == null) {
		return false;
	}
	return value.equals(valueToCompare);
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:16,代码来源:EqualToFieldConstraint.java

示例13: secondInitFrom

import jodd.bean.BeanUtil; //导入依赖的package包/类
public static Object secondInitFrom(final String fieldName, final Object instance) {
  Object _switchResult = null;
  String _trim = fieldName.trim();
  switch (_trim) {
    case "email":
      Object _declaredProperty = BeanUtil.getDeclaredProperty(instance, "realname");
      _switchResult = Randoms.email(((String) _declaredProperty));
      break;
    case "username":
      Object _declaredProperty_1 = BeanUtil.getDeclaredProperty(instance, "realname");
      _switchResult = Randoms.username(((String) _declaredProperty_1));
      break;
    case "nickname":
      Object _declaredProperty_2 = BeanUtil.getDeclaredProperty(instance, "realname");
      _switchResult = Randoms.nickname(((String) _declaredProperty_2));
      break;
    case "age":
      Object _declaredProperty_3 = BeanUtil.getDeclaredProperty(instance, "birthday");
      _switchResult = Integer.valueOf(Randoms.age(((DateTime) _declaredProperty_3)));
      break;
    case "endTime":
      Object _declaredProperty_4 = BeanUtil.getDeclaredProperty(instance, "startTime");
      int _nextInt = RandomUtils.nextInt(0, 10000);
      _switchResult = ((DateTime) _declaredProperty_4).plusHours(_nextInt);
      break;
    default:
      _switchResult = BeanUtil.getDeclaredProperty(instance, fieldName);
      break;
  }
  return _switchResult;
}
 
开发者ID:East196,项目名称:maker,代码行数:32,代码来源:MockHelper.java

示例14: testSmlIdentification

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
  This method tests, if the test-value for smlIdentification is copied into the xml document.
 */
@Test
public void testSmlIdentification() {
	BeanUtil.setProperty(smlIdentification, "definition","testdefinition");
	BeanUtil.setProperty(smlIdentification, "label","testname");
	BeanUtil.setProperty(smlIdentification, "codeSpace","http://testIdentifierCodeSpace");
	BeanUtil.setProperty(smlIdentification, "value","testvalue");
	multiSmlIdentification.getItems().add(smlIdentification);
	Document doc = beanTransformerService.mergeToISO(multiSmlIdentification,mRefDatasetDocument);
	multiSmlIdentification.getItems().remove(smlIdentification);
	Source beanSource = new DOMSource(doc);
	try {
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:identification/sml:IdentifierList/sml:identifier/sml:Term[@definition='testdefinition']/sml:value[text()='testvalue']",
						usingNamespaces));
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:identification/sml:IdentifierList/sml:identifier/sml:Term[@definition='testdefinition']/sml:label[text()='testname']",
						usingNamespaces));
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:identification/sml:IdentifierList/sml:identifier/sml:Term[@definition='testdefinition']/sml:codeSpace[@xlink:href='http://testIdentifierCodeSpace']",
						usingNamespaces));
	} catch (NoSuchMethodError e) {
		LOG.error("Possibly XPath is invalid with compared source", e);
		throw e;
	}

}
 
开发者ID:52North,项目名称:smartSensorEditor,代码行数:36,代码来源:SmlXsltTest.java

示例15: testSmlClassification

import jodd.bean.BeanUtil; //导入依赖的package包/类
/**
  This method tests, if the test-value for smlClassification is copied into the xml document.
 */
@Test
public void testSmlClassification() {
	BeanUtil.setProperty(smlClassification, "definition","testdefinition");
	BeanUtil.setProperty(smlClassification, "label","testname");
	BeanUtil.setProperty(smlClassification, "codeSpace","http://testClassifierCodeSpace");
	BeanUtil.setProperty(smlClassification, "value","testvalue");
	multiSmlClassification.getItems().add(smlClassification);
	Document doc = beanTransformerService.mergeToISO(multiSmlClassification,mRefDatasetDocument);
	multiSmlClassification.getItems().remove(smlClassification);
	Source beanSource = new DOMSource(doc);
	try {
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:classification/sml:ClassifierList/sml:classifier/sml:Term[@definition='testdefinition']/sml:value[text()='testvalue']",
						usingNamespaces));
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:classification/sml:ClassifierList/sml:classifier/sml:Term[@definition='testdefinition']/sml:label[text()='testname']",
						usingNamespaces));
		assertThat(
				beanSource,
				hasXPath(
						"/*/sml:classification/sml:ClassifierList/sml:classifier/sml:Term[@definition='testdefinition']/sml:codeSpace[@xlink:href='http://testClassifierCodeSpace']",
						usingNamespaces));

	} catch (NoSuchMethodError e) {
		LOG.error("Possibly XPath is invalid with compared source", e);
		throw e;
	}

}
 
开发者ID:52North,项目名称:smartSensorEditor,代码行数:37,代码来源:SmlXsltTest.java


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