DATACMNS-431 - Code cleanups.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public OrderDto marshal(Order order) throws Exception {
|
||||
public OrderDto marshal(Order order) {
|
||||
|
||||
if (order == null) {
|
||||
return null;
|
||||
@@ -51,7 +51,7 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Order unmarshal(OrderDto source) throws Exception {
|
||||
public Order unmarshal(OrderDto source) {
|
||||
return source == null ? null : new Order(source.direction, source.property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PageAdapter extends XmlAdapter<PageDto, Page<Object>> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public PageDto marshal(Page<Object> source) throws Exception {
|
||||
public PageDto marshal(Page<Object> source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
@@ -54,7 +54,7 @@ public class PageAdapter extends XmlAdapter<PageDto, Page<Object>> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Page<Object> unmarshal(PageDto v) throws Exception {
|
||||
public Page<Object> unmarshal(PageDto v) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ class PageableAdapter extends XmlAdapter<PageRequestDto, Pageable> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public PageRequestDto marshal(Pageable request) throws Exception {
|
||||
public PageRequestDto marshal(Pageable request) {
|
||||
|
||||
SortDto sortDto = SortAdapter.INSTANCE.marshal(request.getSort());
|
||||
|
||||
@@ -55,7 +55,7 @@ class PageableAdapter extends XmlAdapter<PageRequestDto, Pageable> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Pageable unmarshal(PageRequestDto v) throws Exception {
|
||||
public Pageable unmarshal(PageRequestDto v) {
|
||||
|
||||
if (v.orders.isEmpty()) {
|
||||
return new PageRequest(v.page, v.size);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.domain.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
@@ -19,7 +34,7 @@ public class SortAdapter extends XmlAdapter<SortDto, Sort> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public SortDto marshal(Sort source) throws Exception {
|
||||
public SortDto marshal(Sort source) {
|
||||
|
||||
if (source == null) {
|
||||
return null;
|
||||
@@ -36,7 +51,7 @@ public class SortAdapter extends XmlAdapter<SortDto, Sort> {
|
||||
* @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Sort unmarshal(SortDto source) throws Exception {
|
||||
public Sort unmarshal(SortDto source) {
|
||||
return source == null ? null : new Sort(SpringDataJaxb.unmarshal(source.orders, OrderAdapter.INSTANCE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +57,8 @@ public class SpringDataJaxb {
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class PageRequestDto {
|
||||
|
||||
@XmlAttribute
|
||||
int page, size;
|
||||
@XmlElement(name = "order", namespace = NAMESPACE)
|
||||
List<OrderDto> orders = new ArrayList<OrderDto>();
|
||||
@XmlAttribute int page, size;
|
||||
@XmlElement(name = "order", namespace = NAMESPACE) List<OrderDto> orders = new ArrayList<OrderDto>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,8 +70,7 @@ public class SpringDataJaxb {
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class SortDto {
|
||||
|
||||
@XmlElement(name = "order", namespace = SpringDataJaxb.NAMESPACE)
|
||||
List<OrderDto> orders = new ArrayList<OrderDto>();
|
||||
@XmlElement(name = "order", namespace = SpringDataJaxb.NAMESPACE) List<OrderDto> orders = new ArrayList<OrderDto>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,10 +82,8 @@ public class SpringDataJaxb {
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class OrderDto {
|
||||
|
||||
@XmlAttribute
|
||||
String property;
|
||||
@XmlAttribute
|
||||
Direction direction;
|
||||
@XmlAttribute String property;
|
||||
@XmlAttribute Direction direction;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,9 +95,7 @@ public class SpringDataJaxb {
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class PageDto extends ResourceSupport {
|
||||
|
||||
@XmlAnyElement
|
||||
@XmlElementWrapper(name = "content")
|
||||
List<Object> content;
|
||||
@XmlAnyElement @XmlElementWrapper(name = "content") List<Object> content;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +106,7 @@ public class SpringDataJaxb {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static <T, S> List<T> unmarshal(Collection<S> source, XmlAdapter<S, T> adapter) throws Exception {
|
||||
public static <T, S> List<T> unmarshal(Collection<S> source, XmlAdapter<S, T> adapter) {
|
||||
|
||||
Assert.notNull(adapter);
|
||||
|
||||
@@ -122,8 +115,13 @@ public class SpringDataJaxb {
|
||||
}
|
||||
|
||||
List<T> result = new ArrayList<T>(source.size());
|
||||
|
||||
for (S element : source) {
|
||||
result.add(adapter.unmarshal(element));
|
||||
try {
|
||||
result.add(adapter.unmarshal(element));
|
||||
} catch (Exception o_O) {
|
||||
throw new RuntimeException(o_O);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -136,7 +134,7 @@ public class SpringDataJaxb {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static <T, S> List<S> marshal(Iterable<T> source, XmlAdapter<S, T> adapter) throws Exception {
|
||||
public static <T, S> List<S> marshal(Iterable<T> source, XmlAdapter<S, T> adapter) {
|
||||
|
||||
Assert.notNull(adapter);
|
||||
|
||||
@@ -145,9 +143,15 @@ public class SpringDataJaxb {
|
||||
}
|
||||
|
||||
List<S> result = new ArrayList<S>();
|
||||
|
||||
for (T element : source) {
|
||||
result.add(adapter.marshal(element));
|
||||
try {
|
||||
result.add(adapter.marshal(element));
|
||||
} catch (Exception o_O) {
|
||||
throw new RuntimeException(o_O);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user