All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.springlets.data.domain.jaxb.OrderAdapter Maven / Gradle / Ivy

There is a newer version: 1.2.0.RELEASE
Show newest version
package io.springlets.data.domain.jaxb;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import org.springframework.data.domain.Sort.Order;

import io.springlets.data.domain.jaxb.SpringletsDataJaxb.OrderDto;

/**
 * JAXB {@link XmlAdapter} to convert Spring Data `Order` instance  
 * into a {@link OrderDto} and vice versa. Useful to be used in JAX-WS
 * SEI interfaces.
 * 
 * Based on the Spring Data's `data.domain.jaxb` classes.
 * 
 * @author Enrique Ruiz at http://www.disid.com[DISID Corporation S.L.]
 */
public class OrderAdapter extends XmlAdapter {

  public static final OrderAdapter INSTANCE = new OrderAdapter();

  @Override
  public OrderDto marshal(Order order) {

    if (order == null) {
      return null;
    }

    OrderDto dto = new OrderDto();
    dto.direction = order.getDirection();
    dto.property = order.getProperty();
    return dto;
  }

  @Override
  public Order unmarshal(OrderDto source) {
    return source == null ? null : new Order(source.direction, source.property);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy