Search in sources :

Example 1 with AlternativeKeySchema

use of com.linkedin.restli.restspec.AlternativeKeySchema in project rest.li by linkedin.

the class ResourceModelEncoder method appendAlternativeKeys.

public void appendAlternativeKeys(CollectionSchema rootNode, ResourceModel resourceModel) {
    Map<String, AlternativeKey<?, ?>> alternativeKeys = resourceModel.getAlternativeKeys();
    if (!alternativeKeys.isEmpty()) {
        AlternativeKeySchemaArray altKeyArray = new AlternativeKeySchemaArray();
        for (Map.Entry<String, AlternativeKey<?, ?>> entry : alternativeKeys.entrySet()) {
            AlternativeKeySchema altKeySchema = new AlternativeKeySchema();
            altKeySchema.setName(entry.getKey());
            altKeySchema.setType(buildDataSchemaType(entry.getValue().getType()));
            altKeySchema.setKeyCoercer(entry.getValue().getKeyCoercer().getClass().getCanonicalName());
            altKeyArray.add(altKeySchema);
        }
        rootNode.setAlternativeKeys(altKeyArray);
    }
}
Also used : AlternativeKeySchemaArray(com.linkedin.restli.restspec.AlternativeKeySchemaArray) AlternativeKeySchema(com.linkedin.restli.restspec.AlternativeKeySchema) Map(java.util.Map) CustomAnnotationContentSchemaMap(com.linkedin.restli.restspec.CustomAnnotationContentSchemaMap) DataMap(com.linkedin.data.DataMap) AlternativeKey(com.linkedin.restli.server.AlternativeKey)

Aggregations

DataMap (com.linkedin.data.DataMap)1 AlternativeKeySchema (com.linkedin.restli.restspec.AlternativeKeySchema)1 AlternativeKeySchemaArray (com.linkedin.restli.restspec.AlternativeKeySchemaArray)1 CustomAnnotationContentSchemaMap (com.linkedin.restli.restspec.CustomAnnotationContentSchemaMap)1 AlternativeKey (com.linkedin.restli.server.AlternativeKey)1 Map (java.util.Map)1