Remove now obsolete javax.usb copy constructors.

This commit is contained in:
Klaus Reimer 2014-02-16 13:00:06 +01:00
parent d810ce467e
commit d1e34aeae4
8 changed files with 47 additions and 129 deletions

View File

@ -76,24 +76,11 @@ public final class SimpleUsbConfigurationDescriptor extends SimpleUsbDescriptor
}
/**
* Copy constructor.
* Construct from a libusb4java configuration descriptor.
*
* @param descriptor
* The descriptor from which to copy the data.
*/
public SimpleUsbConfigurationDescriptor(
final UsbConfigurationDescriptor descriptor)
{
this(descriptor.bLength(),
descriptor.bDescriptorType(),
descriptor.wTotalLength(),
descriptor.bNumInterfaces(),
descriptor.bConfigurationValue(),
descriptor.iConfiguration(),
descriptor.bmAttributes(),
descriptor.bMaxPower());
}
public SimpleUsbConfigurationDescriptor(ConfigDescriptor descriptor)
{
this(descriptor.bLength(),

View File

@ -115,29 +115,11 @@ public final class SimpleUsbDeviceDescriptor extends SimpleUsbDescriptor
}
/**
* Copy constructor.
* Construct from a libusb4java device descriptor.
*
* @param descriptor
* The descriptor from which to copy the data.
*/
public SimpleUsbDeviceDescriptor(final UsbDeviceDescriptor descriptor)
{
this(descriptor.bLength(),
descriptor.bDescriptorType(),
descriptor.bcdUSB(),
descriptor.bDeviceClass(),
descriptor.bDeviceSubClass(),
descriptor.bDeviceProtocol(),
descriptor.bMaxPacketSize0(),
descriptor.idVendor(),
descriptor.idProduct(),
descriptor.bcdDevice(),
descriptor.iManufacturer(),
descriptor.iProduct(),
descriptor.iSerialNumber(),
descriptor.bNumConfigurations());
}
public SimpleUsbDeviceDescriptor(DeviceDescriptor descriptor)
{
this(descriptor.bLength(),

View File

@ -64,21 +64,11 @@ public final class SimpleUsbEndpointDescriptor extends SimpleUsbDescriptor
}
/**
* Copy constructor.
* Construct from a libusb4java endpoint descriptor.
*
* @param descriptor
* The descriptor from which to copy the data.
*/
public SimpleUsbEndpointDescriptor(final UsbEndpointDescriptor descriptor)
{
this(descriptor.bLength(),
descriptor.bDescriptorType(),
descriptor.bEndpointAddress(),
descriptor.bmAttributes(),
descriptor.wMaxPacketSize(),
descriptor.bInterval());
}
public SimpleUsbEndpointDescriptor(EndpointDescriptor descriptor)
{
this(descriptor.bLength(),

View File

@ -83,24 +83,11 @@ public final class SimpleUsbInterfaceDescriptor extends SimpleUsbDescriptor
}
/**
* Copy constructor.
* Construct from a libusb4java interface descriptor.
*
* @param descriptor
* The descriptor from which to copy the data.
*/
public SimpleUsbInterfaceDescriptor(final UsbInterfaceDescriptor descriptor)
{
this(descriptor.bLength(),
descriptor.bDescriptorType(),
descriptor.bInterfaceNumber(),
descriptor.bAlternateSetting(),
descriptor.bNumEndpoints(),
descriptor.bInterfaceClass(),
descriptor.bInterfaceSubClass(),
descriptor.bInterfaceProtocol(),
descriptor.iInterface());
}
public SimpleUsbInterfaceDescriptor(InterfaceDescriptor descriptor)
{
this(descriptor.bLength(),

View File

@ -8,7 +8,6 @@ package org.usb4java.descriptors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import org.junit.BeforeClass;
@ -64,18 +63,6 @@ public class SimpleUsbConfigurationDescriptorTest
CONFIGURATION_VALUE, CONFIGURATION, ATTRIBUTES, MAX_POWER);
}
/**
* Tests the copy constructor.
*/
@Test
public void testCopyConstructor()
{
final SimpleUsbConfigurationDescriptor copy =
new SimpleUsbConfigurationDescriptor(descriptor);
assertNotSame(copy, descriptor);
assertEquals(copy, descriptor);
}
/**
* Tests the {@link SimpleUsbConfigurationDescriptor#bLength()} method.
*/
@ -160,8 +147,10 @@ public class SimpleUsbConfigurationDescriptorTest
{
final int code = descriptor.hashCode();
assertEquals(code, descriptor.hashCode());
assertEquals(code,
new SimpleUsbConfigurationDescriptor(descriptor).hashCode());
assertEquals(code, new SimpleUsbConfigurationDescriptor(
LENGTH, DESCRIPTOR_TYPE, TOTAL_LENGTH, NUM_INTERFACES,
CONFIGURATION_VALUE, CONFIGURATION, ATTRIBUTES,
MAX_POWER).hashCode());
}
/**
@ -174,7 +163,8 @@ public class SimpleUsbConfigurationDescriptorTest
assertFalse(descriptor.equals(new Object()));
assertTrue(descriptor.equals(descriptor));
assertTrue(descriptor.equals(new SimpleUsbConfigurationDescriptor(
descriptor)));
LENGTH, DESCRIPTOR_TYPE, TOTAL_LENGTH, NUM_INTERFACES,
CONFIGURATION_VALUE, CONFIGURATION, ATTRIBUTES, MAX_POWER)));
assertFalse(descriptor.equals(new SimpleUsbConfigurationDescriptor(
WRONG, DESCRIPTOR_TYPE, TOTAL_LENGTH, NUM_INTERFACES,
CONFIGURATION_VALUE, CONFIGURATION, ATTRIBUTES, MAX_POWER)));
@ -209,7 +199,10 @@ public class SimpleUsbConfigurationDescriptorTest
{
assertEquals(descriptor.toString(), descriptor.toString());
assertEquals(descriptor.toString(),
new SimpleUsbConfigurationDescriptor(descriptor).toString());
new SimpleUsbConfigurationDescriptor(
LENGTH, DESCRIPTOR_TYPE, TOTAL_LENGTH, NUM_INTERFACES,
CONFIGURATION_VALUE, CONFIGURATION, ATTRIBUTES,
MAX_POWER).toString());
assertNotEquals(descriptor.toString(),
new SimpleUsbConfigurationDescriptor(
WRONG, DESCRIPTOR_TYPE, TOTAL_LENGTH, NUM_INTERFACES,

View File

@ -8,7 +8,6 @@ package org.usb4java.descriptors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import org.junit.BeforeClass;
@ -81,18 +80,6 @@ public class SimpleUsbDeviceDescriptorTest
MANUFACTURER, PRODUCT, SERIAL_NUMBER, NUM_CONFIGURATIONS);
}
/**
* Tests the copy constructor.
*/
@Test
public void testCopyConstructor()
{
final SimpleUsbDeviceDescriptor copy =
new SimpleUsbDeviceDescriptor(descriptor);
assertNotSame(copy, descriptor);
assertEquals(copy, descriptor);
}
/**
* Tests the {@link SimpleUsbDeviceDescriptor#bLength()} method.
*/
@ -218,8 +205,11 @@ public class SimpleUsbDeviceDescriptorTest
{
final int code = descriptor.hashCode();
assertEquals(code, descriptor.hashCode());
assertEquals(code,
new SimpleUsbDeviceDescriptor(descriptor).hashCode());
assertEquals(code,new SimpleUsbDeviceDescriptor(
LENGTH, DESCRIPTOR_TYPE, USB, DEVICE_CLASS, DEVICE_SUB_CLASS,
DEVICE_PROTOCOL, MAX_PACKET_SIZE0, ID_VENDOR, ID_PRODUCT, DEVICE,
MANUFACTURER, PRODUCT, SERIAL_NUMBER,
NUM_CONFIGURATIONS).hashCode());
}
/**
@ -232,7 +222,9 @@ public class SimpleUsbDeviceDescriptorTest
assertFalse(descriptor.equals(new Object()));
assertTrue(descriptor.equals(descriptor));
assertTrue(descriptor.equals(new SimpleUsbDeviceDescriptor(
descriptor)));
LENGTH, DESCRIPTOR_TYPE, USB, DEVICE_CLASS, DEVICE_SUB_CLASS,
DEVICE_PROTOCOL, MAX_PACKET_SIZE0, ID_VENDOR, ID_PRODUCT, DEVICE,
MANUFACTURER, PRODUCT, SERIAL_NUMBER, NUM_CONFIGURATIONS)));
assertFalse(descriptor.equals(new SimpleUsbDeviceDescriptor(
WRONG, DESCRIPTOR_TYPE, USB, DEVICE_CLASS, DEVICE_SUB_CLASS,
DEVICE_PROTOCOL, MAX_PACKET_SIZE0, ID_VENDOR, ID_PRODUCT, DEVICE,
@ -298,8 +290,11 @@ public class SimpleUsbDeviceDescriptorTest
public void testToString()
{
assertEquals(descriptor.toString(), descriptor.toString());
assertEquals(descriptor.toString(),
new SimpleUsbDeviceDescriptor(descriptor).toString());
assertEquals(descriptor.toString(), new SimpleUsbDeviceDescriptor(
LENGTH, DESCRIPTOR_TYPE, USB, DEVICE_CLASS, DEVICE_SUB_CLASS,
DEVICE_PROTOCOL, MAX_PACKET_SIZE0, ID_VENDOR, ID_PRODUCT, DEVICE,
MANUFACTURER, PRODUCT, SERIAL_NUMBER,
NUM_CONFIGURATIONS).toString());
assertNotEquals(descriptor.toString(), new SimpleUsbDeviceDescriptor(
WRONG, DESCRIPTOR_TYPE, USB, DEVICE_CLASS, DEVICE_SUB_CLASS,
DEVICE_PROTOCOL, MAX_PACKET_SIZE0, ID_VENDOR, ID_PRODUCT, DEVICE,

View File

@ -8,7 +8,6 @@ package org.usb4java.descriptors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import org.junit.BeforeClass;
@ -55,19 +54,7 @@ public class SimpleUsbEndpointDescriptorTest
LENGTH, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL);
}
/**
* Tests the copy constructor.
*/
@Test
public void testCopyConstructor()
{
final SimpleUsbEndpointDescriptor copy =
new SimpleUsbEndpointDescriptor(descriptor);
assertNotSame(copy, descriptor);
assertEquals(copy, descriptor);
}
/**
* Tests the {@link SimpleUsbEndpointDescriptor#bLength()} method.
*/
@ -130,8 +117,9 @@ public class SimpleUsbEndpointDescriptorTest
{
final int code = descriptor.hashCode();
assertEquals(code, descriptor.hashCode());
assertEquals(code,
new SimpleUsbEndpointDescriptor(descriptor).hashCode());
assertEquals(code, new SimpleUsbEndpointDescriptor(
LENGTH, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL).hashCode());
}
/**
@ -144,7 +132,8 @@ public class SimpleUsbEndpointDescriptorTest
assertFalse(descriptor.equals(new Object()));
assertTrue(descriptor.equals(descriptor));
assertTrue(descriptor.equals(new SimpleUsbEndpointDescriptor(
descriptor)));
LENGTH, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL)));
assertFalse(descriptor.equals(new SimpleUsbEndpointDescriptor(
WRONG, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL)));
@ -172,8 +161,9 @@ public class SimpleUsbEndpointDescriptorTest
public void testToString()
{
assertEquals(descriptor.toString(), descriptor.toString());
assertEquals(descriptor.toString(),
new SimpleUsbEndpointDescriptor(descriptor).toString());
assertEquals(descriptor.toString(), new SimpleUsbEndpointDescriptor(
LENGTH, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL).toString());
assertNotEquals(descriptor.toString(), new SimpleUsbEndpointDescriptor(
WRONG, DESCRIPTOR_TYPE, ENDPOINT_ADDRESS, ATTRIBUTES,
MAX_PACKET_SIZE, INTERVAL).toString());

View File

@ -8,7 +8,6 @@ package org.usb4java.descriptors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import org.junit.BeforeClass;
@ -66,18 +65,6 @@ public class SimpleUsbInterfaceDescriptorTest
INTERFACE_PROTOCOL, INTERFACE);
}
/**
* Tests the copy constructor.
*/
@Test
public void testCopyConstructor()
{
final SimpleUsbInterfaceDescriptor copy =
new SimpleUsbInterfaceDescriptor(descriptor);
assertNotSame(copy, descriptor);
assertEquals(copy, descriptor);
}
/**
* Tests the {@link SimpleUsbInterfaceDescriptor#bLength()} method.
*/
@ -170,8 +157,10 @@ public class SimpleUsbInterfaceDescriptorTest
{
final int code = descriptor.hashCode();
assertEquals(code, descriptor.hashCode());
assertEquals(code,
new SimpleUsbInterfaceDescriptor(descriptor).hashCode());
assertEquals(code, new SimpleUsbInterfaceDescriptor(
LENGTH, DESCRIPTOR_TYPE, INTERFACE_NUMBER, ALTERNATE_SETTING,
NUM_ENDPOINTS, INTERFACE_CLASS, INTERFACE_SUB_CLASS,
INTERFACE_PROTOCOL, INTERFACE).hashCode());
}
/**
@ -184,7 +173,9 @@ public class SimpleUsbInterfaceDescriptorTest
assertFalse(descriptor.equals(new Object()));
assertTrue(descriptor.equals(descriptor));
assertTrue(descriptor.equals(new SimpleUsbInterfaceDescriptor(
descriptor)));
LENGTH, DESCRIPTOR_TYPE, INTERFACE_NUMBER, ALTERNATE_SETTING,
NUM_ENDPOINTS, INTERFACE_CLASS, INTERFACE_SUB_CLASS,
INTERFACE_PROTOCOL, INTERFACE)));
assertFalse(descriptor.equals(new SimpleUsbInterfaceDescriptor(
WRONG, DESCRIPTOR_TYPE, INTERFACE_NUMBER, ALTERNATE_SETTING,
NUM_ENDPOINTS, INTERFACE_CLASS, INTERFACE_SUB_CLASS,
@ -231,7 +222,10 @@ public class SimpleUsbInterfaceDescriptorTest
{
assertEquals(descriptor.toString(), descriptor.toString());
assertEquals(descriptor.toString(),
new SimpleUsbInterfaceDescriptor(descriptor).toString());
new SimpleUsbInterfaceDescriptor(
LENGTH, DESCRIPTOR_TYPE, INTERFACE_NUMBER, ALTERNATE_SETTING,
NUM_ENDPOINTS, INTERFACE_CLASS, INTERFACE_SUB_CLASS,
INTERFACE_PROTOCOL, INTERFACE).toString());
assertNotEquals(descriptor.toString(),
new SimpleUsbInterfaceDescriptor(
WRONG, DESCRIPTOR_TYPE, INTERFACE_NUMBER, ALTERNATE_SETTING,