/** * format a type constraint to a JSON representation. * @param constraint the constraint to format. * @return The JSONification. */ protected String typeConstraintToJson(final PathConstraint constraint) { String path = constraint.getPath(); String type = PathConstraint.getType(constraint); return String.format("{\"path\":\"%s\",\"type\":\"%s\"}", path, type); }
/** * format a type constraint to a JSON representation. * @param constraint the constraint to format. * @return The JSONification. */ protected String typeConstraintToJson(final PathConstraint constraint) { String path = constraint.getPath(); String type = PathConstraint.getType(constraint); return String.format("{\"path\":\"%s\",\"type\":\"%s\"}", path, type); }
/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }
/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }