Class Resource<T extends Model>


  • public class Resource<T extends Model>
    extends Object
    This class defines CRUD like interface.
    • Method Detail

      • getModel

        public Class<?> getModel()
        Returns the resource class.
      • read

        public Response read​(long id)
      • copy

        public Response copy​(long id)
      • getRecordName

        public Response getRecordName​(Request request)
        Get the name of the record. This method should be used to get the value of name field if it's a function field.
        Parameters:
        request - the request containing the current values of the record
        Returns:
        response with the updated values with record name
      • removePasswordFields

        public static Map<String,​Object> removePasswordFields​(Map<String,​Object> data,
                                                                    Class<?> modelClass)
        Removes password field values from the given record map, including dotted field names and nested record maps of relational fields.

        The given map is not modified, a cleaned copy is returned.

        Parameters:
        data - the record map to clean up
        modelClass - the model class of the record
        Returns:
        a copy of the given map with password fields removed
      • removeNotPermitted

        protected void removeNotPermitted​(Map<String,​Object> map,
                                          String... names)
        Removes not permitted fields in specified map.
        Parameters:
        map - data
        names - field names
      • filterPermitted

        protected String[] filterPermitted​(Object bean,
                                           String... names)
        Filters given field names so that only base fields and readable related fields remains.
        Parameters:
        bean - object
        names - field names
        Returns:
        readable field names