org.nuxeo.ecm.core.schema.types.Field.getConstraints()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(88)

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

Field.getConstraints介绍

暂无

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

/**
 * This method should be the only one to create {@link ConstraintViolation}.
 *
 * @since 7.1
 */
private List<ConstraintViolation> validateSimpleTypeField(Schema schema, List<PathNode> path, Field field,
    Object value) {
  Type type = field.getType();
  assert type.isSimpleType() || type.isListType(); // list type to manage ArrayProperty
  List<ConstraintViolation> violations = new ArrayList<>();
  Set<Constraint> constraints;
  if (type.isListType()) { // ArrayProperty
    constraints = ((ListType) type).getFieldType().getConstraints();
  } else {
    constraints = field.getConstraints();
  }
  for (Constraint constraint : constraints) {
    if (!constraint.validate(value)) {
      ConstraintViolation violation = new ConstraintViolation(schema, path, constraint, value);
      violations.add(violation);
    }
  }
  return violations;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema

LengthConstraint lc = ConstraintUtils.getConstraint(field.getConstraints(), LengthConstraint.class);
if (lc != null && lc.getMax() != null) {
  field.setMaxLength(lc.getMax().intValue());

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

OutputStream out = new OutputStreamWithJsonWriter(jg);
jg.writeArrayFieldStart("constraints");
for (Constraint c : field.getConstraints()) {
  constraintWriter.write(c, Constraint.class, Constraint.class, APPLICATION_JSON_TYPE, out);

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema

/**
 * Create a schema from a ComplexType
 *
 * @since 5.7
 * @param complexType
 * @param name
 * @param ns
 */
public SchemaImpl(ComplexType complexType, String name, Namespace ns, boolean isVersionWritabe) {
  super(null, SchemaNames.SCHEMAS, name, ns);
  this.isVersionWritabe = isVersionWritabe;
  if (complexType != null) {
    for (Field field : complexType.getFields()) {
      QName fieldname = QName.valueOf(field.getName().getLocalName(), ns.prefix);
      Type type = field.getType();
      String defaultValue = type.encode(field.getDefaultValue());
      Set<Constraint> constraint = field.getConstraints();
      FieldImpl newField = new FieldImpl(fieldname, this, type, defaultValue, 0, constraint);
      newField.setConstant(field.isConstant());
      addField(newField);
    }
  }
}

相关文章

微信公众号

最新文章

更多