示例#1
0
 /**
  * Returns a new ModelCodec.
  *
  * @param <ModelType> a model type
  * @param modelClass a model class
  * @return a new ModelCodec
  */
 public static <ModelType> ModelCodec<ModelType> to(Class<ModelType> modelClass) {
   ModelCodec<ModelType> result = new ModelCodec();
   result.entityClass = modelClass;
   return result;
 }
示例#2
0
 /**
  * Returns a new ModelCodec.
  *
  * @param <ModelType> a model type
  * @param model a model instance to serialize
  * @return a new ModelCodec
  */
 public static <ModelType> ModelCodec<ModelType> from(ModelType model) {
   ModelCodec<ModelType> result = new ModelCodec();
   result.entity = model;
   result.entityClass = (Class<ModelType>) model.getClass();
   return result;
 }