protected DefaultCriteria(O options) { Assert.notNull(options, "options argument cannot be null."); Assert.isInstanceOf( Expandable.class, options, "options argument is expected to implement the " + Expandable.class.getName() + " interface."); this.options = options; this.criterionEntries = new ArrayList<Criterion>(); this.orderEntries = new ArrayList<Order>(); }
// since 0.9.2 private Object toMapValue( final AbstractResource resource, final String propName, Object value, boolean partialUpdate) { if (resource instanceof CustomData) { // no sanitization: CustomData resources retain their values as-is: return value; } if (value instanceof CustomData || value instanceof ProviderData || value instanceof Provider) { if (partialUpdate) { Assert.isInstanceOf(AbstractResource.class, value); AbstractResource abstractResource = (AbstractResource) value; Set<String> updatedPropertyNames = abstractResource.getUpdatedPropertyNames(); LinkedHashMap<String, Object> properties = new LinkedHashMap<String, Object>(Collections.size(updatedPropertyNames)); for (String updatedCustomPropertyName : updatedPropertyNames) { Object object = abstractResource.getProperty(updatedCustomPropertyName); properties.put(updatedCustomPropertyName, object); } value = properties; } return value; } if (value instanceof Map) { // Since defaultModel is a map, the DataStore thinks it is a Resource. This causes the code to // crash later one as Resources // do need to have an href property if (resource instanceof ModeledEmailTemplate && propName.equals("defaultModel")) { return value; } else { // if the property is a reference, don't write the entire object - just the href will do: // TODO need to change this to write the entire object because this code defeats the purpose // of entity expansion // when this code gets called (returning the reference instead of the whole object that // is returned from Stormpath) return this.referenceFactory.createReference(propName, (Map) value); } } if (value instanceof Resource) { return this.referenceFactory.createReference(propName, (Resource) value); } return value; }