@Override public void serialize(ConstraintType constraintType, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("name", constraintType.getName()); jsonGenerator.writeEndObject(); } }
public void validateConstraint(boolean isRequestContext, String constraint, String name, String value, String constraintValue, StringBuilder errors) { ConstraintType constraintType = constraintMap.get(constraint.toLowerCase(Locale.US)); if (constraintType == null) { if (errors.length() > 0) { errors.append("\n"); } errors.append("Unable to locate constraint type ").append(constraint); if (isRequestContext) { errors.append(" for ThreadContext key "); } else { errors.append(" for key "); } errors.append(name); return; } constraintType.validate(isRequestContext, name, value, constraintValue, errors); }
void appendConstraint(Constraint constraint, StringBuilder buffer) { ConstraintType type = constraint.getConstraintType(); // Add the escapes since they have been removed when converting the original data to a Java Strinng. They need to // be added back for use in the Constraint declaration. buffer.append(String.format(CONSTRAINT, type.getName(), constraint.getValue().replace("\\", "\\\\"))); } }
sb.append(" "); sb.append("name=\"").append(constraint.getConstraintType().getName()).append("\""); sb.append("value=\"").append(constraint.getValue()).append("\"");
private static void validateConstraints(boolean isRequestContext, Collection<Constraint> constraints, String name, String value, StringBuilder errors) { for (Constraint constraint : constraints) { constraintPlugins.validateConstraint(isRequestContext, constraint.getConstraintType().getName(), name, value, constraint.getValue(), errors); } } }
if (constraint.getId() != null) { constraintModel = constraintMap.get(constraint.getId()); constraintModel.setConstraintType(constraint.getConstraintType().getName()); constraintModel.setValue(constraint.getValue()); } else { constraintModel = new ConstraintModel(); constraintModel.setConstraintType(constraint.getConstraintType().getName()); constraintModel.setValue(constraint.getValue()); constraintModels.add(constraintModel);