Explicit type can be replaced by <>

Issue: SPR-13188
This commit is contained in:
Stephane Nicoll
2016-07-05 17:00:26 +02:00
parent 3096888c7d
commit 00d2606b00
1044 changed files with 3972 additions and 3893 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -278,7 +278,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests<CastorMarshal
* @throws Exception if any error occurs during xpath evaluation
*/
private void assertXpathEvaluatesTo(String msg, String expected, String xpath, String xmlDoc) throws Exception {
Map<String, String> namespaces = new HashMap<String, String>();
Map<String, String> namespaces = new HashMap<>();
namespaces.put("tns", "http://samples.springframework.org/flight");
namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -198,7 +198,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests<CastorMar
@Test
public void unmarshalStreamSourceWithXmlOptions() throws Exception {
final AtomicReference<XMLReader> result = new AtomicReference<XMLReader>();
final AtomicReference<XMLReader> result = new AtomicReference<>();
CastorMarshaller marshaller = new CastorMarshaller() {
@Override
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource) {
@@ -225,7 +225,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests<CastorMar
@Test
public void unmarshalSaxSourceWithXmlOptions() throws Exception {
final AtomicReference<XMLReader> result = new AtomicReference<XMLReader>();
final AtomicReference<XMLReader> result = new AtomicReference<>();
CastorMarshaller marshaller = new CastorMarshaller() {
@Override
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -191,7 +191,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
marshaller.supports(method.getGenericReturnType()));
marshaller.setSupportJaxbElementClass(true);
JAXBElement<FlightType> flightTypeJAXBElement = new JAXBElement<FlightType>(new QName("http://springframework.org", "flight"), FlightType.class,
JAXBElement<FlightType> flightTypeJAXBElement = new JAXBElement<>(new QName("http://springframework.org", "flight"), FlightType.class,
new FlightType());
assertTrue("Jaxb2Marshaller does not support JAXBElement<FlightsType>", marshaller.supports(flightTypeJAXBElement.getClass()));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -30,31 +30,31 @@ public class Primitives {
// following methods are used to test support for primitives
public JAXBElement<Boolean> primitiveBoolean() {
return new JAXBElement<Boolean>(NAME, Boolean.class, true);
return new JAXBElement<>(NAME, Boolean.class, true);
}
public JAXBElement<Byte> primitiveByte() {
return new JAXBElement<Byte>(NAME, Byte.class, (byte)42);
return new JAXBElement<>(NAME, Byte.class, (byte) 42);
}
public JAXBElement<Short> primitiveShort() {
return new JAXBElement<Short>(NAME, Short.class, (short)42);
return new JAXBElement<>(NAME, Short.class, (short) 42);
}
public JAXBElement<Integer> primitiveInteger() {
return new JAXBElement<Integer>(NAME, Integer.class, 42);
return new JAXBElement<>(NAME, Integer.class, 42);
}
public JAXBElement<Long> primitiveLong() {
return new JAXBElement<Long>(NAME, Long.class, 42L);
return new JAXBElement<>(NAME, Long.class, 42L);
}
public JAXBElement<Double> primitiveDouble() {
return new JAXBElement<Double>(NAME, Double.class, 42D);
return new JAXBElement<>(NAME, Double.class, 42D);
}
public JAXBElement<byte[]> primitiveByteArray() {
return new JAXBElement<byte[]>(NAME, byte[].class, new byte[]{42});
return new JAXBElement<>(NAME, byte[].class, new byte[] {42});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -62,57 +62,57 @@ public class StandardClasses {
java.util.UUID
*/
public JAXBElement<String> standardClassString() {
return new JAXBElement<String>(NAME, String.class, "42");
return new JAXBElement<>(NAME, String.class, "42");
}
public JAXBElement<BigInteger> standardClassBigInteger() {
return new JAXBElement<BigInteger>(NAME, BigInteger.class, new BigInteger("42"));
return new JAXBElement<>(NAME, BigInteger.class, new BigInteger("42"));
}
public JAXBElement<BigDecimal> standardClassBigDecimal() {
return new JAXBElement<BigDecimal>(NAME, BigDecimal.class, new BigDecimal("42.0"));
return new JAXBElement<>(NAME, BigDecimal.class, new BigDecimal("42.0"));
}
public JAXBElement<Calendar> standardClassCalendar() {
return new JAXBElement<Calendar>(NAME, Calendar.class, Calendar.getInstance());
return new JAXBElement<>(NAME, Calendar.class, Calendar.getInstance());
}
public JAXBElement<GregorianCalendar> standardClassGregorianCalendar() {
return new JAXBElement<GregorianCalendar>(NAME, GregorianCalendar.class, (GregorianCalendar)Calendar.getInstance());
return new JAXBElement<>(NAME, GregorianCalendar.class, (GregorianCalendar) Calendar.getInstance());
}
public JAXBElement<Date> standardClassDate() {
return new JAXBElement<Date>(NAME, Date.class, new Date());
return new JAXBElement<>(NAME, Date.class, new Date());
}
public JAXBElement<QName> standardClassQName() {
return new JAXBElement<QName>(NAME, QName.class, NAME);
return new JAXBElement<>(NAME, QName.class, NAME);
}
public JAXBElement<URI> standardClassURI() {
return new JAXBElement<URI>(NAME, URI.class, URI.create("http://springframework.org"));
return new JAXBElement<>(NAME, URI.class, URI.create("http://springframework.org"));
}
public JAXBElement<XMLGregorianCalendar> standardClassXMLGregorianCalendar() throws DatatypeConfigurationException {
XMLGregorianCalendar calendar =
factory.newXMLGregorianCalendar((GregorianCalendar) Calendar.getInstance());
return new JAXBElement<XMLGregorianCalendar>(NAME, XMLGregorianCalendar.class, calendar);
return new JAXBElement<>(NAME, XMLGregorianCalendar.class, calendar);
}
public JAXBElement<Duration> standardClassDuration() {
Duration duration = factory.newDuration(42000);
return new JAXBElement<Duration>(NAME, Duration.class, duration);
return new JAXBElement<>(NAME, Duration.class, duration);
}
public JAXBElement<Image> standardClassImage() throws IOException {
Image image = ImageIO.read(getClass().getResourceAsStream("spring-ws.png"));
return new JAXBElement<Image>(NAME, Image.class, image);
return new JAXBElement<>(NAME, Image.class, image);
}
public JAXBElement<DataHandler> standardClassDataHandler() {
DataSource dataSource = new URLDataSource(getClass().getResource("spring-ws.png"));
DataHandler dataHandler = new DataHandler(dataSource);
return new JAXBElement<DataHandler>(NAME, DataHandler.class, dataHandler);
return new JAXBElement<>(NAME, DataHandler.class, dataHandler);
}
/* The following should work according to the spec, but doesn't on the JAXB2 implementation including in JDK 1.6.0_17
@@ -123,7 +123,7 @@ public class StandardClasses {
*/
public JAXBElement<UUID> standardClassUUID() {
return new JAXBElement<UUID>(NAME, UUID.class, UUID.randomUUID());
return new JAXBElement<>(NAME, UUID.class, UUID.randomUUID());
}
}

View File

@@ -1,4 +1,20 @@
/*
* Copyright 2002-2016 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.oxm.jaxb;
import javax.xml.bind.JAXBElement;
@@ -11,6 +27,6 @@ public class XmlRegObjectFactory {
@XmlElementDecl(name = "brand-airplane")
public JAXBElement<Airplane> createAirplane(Airplane airplane) {
return new JAXBElement<Airplane>(new QName("brand-airplane"), Airplane.class, null, airplane);
return new JAXBElement<>(new QName("brand-airplane"), Airplane.class, null, airplane);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -21,7 +21,7 @@ import java.util.List;
public class Flights {
protected List<FlightType> flightList = new ArrayList<FlightType>();
protected List<FlightType> flightList = new ArrayList<>();
public void addFlight(FlightType flight) {
flightList.add(flight);

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2002-2016 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.oxm.xstream;
import java.util.ArrayList;
@@ -5,9 +21,9 @@ import java.util.List;
public class Flights {
private List<Flight> flights = new ArrayList<Flight>();
private List<Flight> flights = new ArrayList<>();
private List<String> strings = new ArrayList<String>();
private List<String> strings = new ArrayList<>();
public List<Flight> getFlights() {
return flights;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -74,7 +74,7 @@ public class XStreamMarshallerTests {
@Before
public void createMarshaller() throws Exception {
marshaller = new XStreamMarshaller();
Map<String, String> aliases = new HashMap<String, String>();
Map<String, String> aliases = new HashMap<>();
aliases.put("flight", Flight.class.getName());
marshaller.setAliases(aliases);
flight = new Flight();
@@ -231,7 +231,7 @@ public class XStreamMarshallerTests {
@Test
@Ignore("Fails on JDK 8 build 108")
public void aliasesByTypeStringClassMap() throws Exception {
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
Map<String, Class<?>> aliases = new HashMap<>();
aliases.put("flight", Flight.class);
FlightSubclass flight = new FlightSubclass();
flight.setFlightNumber(42);
@@ -245,7 +245,7 @@ public class XStreamMarshallerTests {
@Test
@Ignore("Fails on JDK 8 build 108")
public void aliasesByTypeStringStringMap() throws Exception {
Map<String, String> aliases = new HashMap<String, String>();
Map<String, String> aliases = new HashMap<>();
aliases.put("flight", Flight.class.getName());
FlightSubclass flight = new FlightSubclass();
flight.setFlightNumber(42);
@@ -282,7 +282,7 @@ public class XStreamMarshallerTests {
flights.getFlights().add(flight);
flights.getStrings().add("42");
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
Map<String, Class<?>> aliases = new HashMap<>();
aliases.put("flight", Flight.class);
aliases.put("flights", Flights.class);
marshaller.setAliases(aliases);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -49,7 +49,7 @@ public class XStreamUnmarshallerTests {
@Before
public void createUnmarshaller() throws Exception {
unmarshaller = new XStreamMarshaller();
Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
Map<String, Class<?>> aliases = new HashMap<>();
aliases.put("flight", Flight.class);
unmarshaller.setAliases(aliases);
}