/** * Impose immutability constraints. * * @param <T> representation type * @param strict array of strictly immutable field names * @param incoming incoming representation * @param existing existing representation * @return error Response if appropriate */ public static <T extends BaseResource> Response imposeConstraints(String[] strict, T incoming, T existing) { return imposeConstraints(strict, incoming, existing, BROKEN_CONSTRAINT_REASON, BROKEN_CONSTRAINT_DETAIL); }
/** * Validate update from an immutability point of view. * * @param <T> representation type * @param strict array of strictly immutable field names * @param incoming the incoming representation * @param existing the existing representation * @throws WebApplicationException wrapping an appropriate response * iff an immutability constraint has been broken */ public static <T extends BaseResource> void validateUpdate(String[] strict, T incoming, T existing) { Response error = imposeConstraints(strict, incoming, existing); if (error != null) { throw new WebApplicationException(error); } }