Example usage for org.apache.commons.lang3.builder DiffBuilder DiffBuilder

List of usage examples for org.apache.commons.lang3.builder DiffBuilder DiffBuilder

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder DiffBuilder DiffBuilder.

Prototype

public DiffBuilder(final Object lhs, final Object rhs, final ToStringStyle style) 

Source Link

Document

Constructs a builder for the specified objects with the specified style.

Usage

From source file:com.infinities.skyport.compute.entity.patch.SnapshotPatchBuilder.java

@Override
public DiffResult diff(Snapshot old, Snapshot updated) {
    DiffResult diff = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("sizeInGb", old.getSizeInGb(), updated.getSizeInGb())
            .append("snapshotTimestamp", old.getSnapshotTimestamp(), updated.getSnapshotTimestamp())
            .append("currentState", old.getCurrentState(), updated.getCurrentState())
            .append("description", old.getDescription(), updated.getDescription())
            .append("name", old.getName(), updated.getName())
            .append("owner", old.getOwner(), updated.getOwner())
            .append("progress", old.getProgress(), updated.getProgress())
            .append("providerSnapshotId", old.getProviderSnapshotId(), updated.getProviderSnapshotId())
            .append("regionId", old.getRegionId(), updated.getRegionId())
            .append("tags", old.getTags(), updated.getTags())
            .append("visibleScope", old.getVisibleScope(), updated.getVisibleScope())
            .append("volumeId", old.getVolumeId(), updated.getVolumeId()).build();
    return diff;/*  w  w  w . j  av  a2 s  . c o m*/
}

From source file:com.infinities.skyport.compute.entity.patch.VolumePatchBuilder.java

@Override
public DiffResult diff(Volume old, Volume updated) {
    DiffResult diff = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("creationTimestamp", old.getCreationTimestamp(), updated.getCreationTimestamp())
            .append("iops", old.getIops(), updated.getIops())
            .append("currentState", old.getCurrentState(), updated.getCurrentState())
            .append("description", old.getDescription(), updated.getDescription())
            .append("deviceId", old.getDeviceId(), updated.getDeviceId())
            .append("format", old.getFormat(), updated.getFormat())
            .append("guestOperatingSystem", old.getGuestOperatingSystem(), updated.getGuestOperatingSystem())
            .append("mediaLink", old.getMediaLink(), updated.getMediaLink())
            .append("name", old.getName(), updated.getName())
            .append("providerDataCenterId", old.getProviderDataCenterId(), updated.getProviderDataCenterId())
            .append("providerProductId", old.getProviderProductId(), updated.getProviderProductId())
            .append("providerRegionId", old.getProviderRegionId(), updated.getProviderRegionId())
            .append("providerSnapshotId", old.getProviderSnapshotId(), updated.getProviderSnapshotId())
            .append("providerVirtualMachineId", old.getProviderVirtualMachineId(),
                    updated.getProviderVirtualMachineId())
            .append("providerVlanId", old.getProviderVlanId(), updated.getProviderVlanId())
            .append("providerVolumeId", old.getProviderVolumeId(), updated.getProviderVolumeId())
            .append("size", old.getSize(), updated.getSize()).append("tags", old.getTags(), updated.getTags())
            .append("deleteOnVirtualMachineTermination", old.isDeleteOnVirtualMachineTermination(),
                    updated.isDeleteOnVirtualMachineTermination())
            .append("type", old.getType(), updated.getType())
            .append("rootVolume", old.isRootVolume(), updated.isRootVolume()).build();
    return diff;/*from  ww  w .  j  a v a 2 s . co m*/
}

From source file:com.infinities.skyport.compute.entity.patch.MachineImagePatchBuilder.java

@Override
public DiffResult diff(MachineImage old, MachineImage updated) {
    DiffResult diff = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("creationTimestamp", old.getCreationTimestamp(), updated.getCreationTimestamp())
            .append("minimumDiskSizeGb", old.getMinimumDiskSizeGb(), updated.getMinimumDiskSizeGb())
            .append("architecture", old.getArchitecture(), updated.getArchitecture())
            .append("currentState", old.getCurrentState(), updated.getCurrentState())
            .append("description", old.getDescription(), updated.getDescription())
            .append("imageClass", old.getImageClass(), updated.getImageClass())
            .append("kernelImageId", old.getKernelImageId(), updated.getKernelImageId())
            .append("name", old.getName(), updated.getName())
            .append("platform", old.getPlatform(), updated.getPlatform())
            .append("providerDataCenterId", old.getProviderDataCenterId(), updated.getProviderDataCenterId())
            .append("providerMachineImageId", old.getProviderMachineImageId(),
                    updated.getProviderMachineImageId())
            .append("providerMetadata", old.getProviderMetadata(), updated.getProviderMetadata())
            .append("providerOwnerId", old.getProviderOwnerId(), updated.getProviderOwnerId())
            .append("providerRegionId", old.getProviderRegionId(), updated.getProviderRegionId())
            .append("software", old.getSoftware(), updated.getSoftware())
            .append("storageFormat", old.getStorageFormat(), updated.getStorageFormat())
            .append("tags", old.getTags(), updated.getTags()).append("type", old.getType(), updated.getType())
            .append("visibleScope", old.getVisibleScope(), updated.getVisibleScope())
            .append("volumes", old.getVolumes(), updated.getVolumes()).build();
    return diff;/*from w  w  w .  j  a v  a 2s .com*/
}

From source file:com.infinities.skyport.compute.entity.patch.VirtualMachineProductPatchBuilder.java

@Override
public DiffResult diff(VirtualMachineProduct old, VirtualMachineProduct updated) {
    DiffResult diff = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("cpuCount", old.getCpuCount(), updated.getCpuCount())
            .append("standardHourlyRate", old.getStandardHourlyRate(), updated.getStandardHourlyRate())
            .append("architectures", old.getArchitectures(), updated.getArchitectures())
            .append("dataCenterId", old.getDataCenterId(), updated.getDataCenterId())
            .append("description", old.getDescription(), updated.getDescription())
            .append("name", old.getName(), updated.getName())
            .append("providerMetadata", old.getProviderMetadata(), updated.getProviderMetadata())
            .append("providerProductId", old.getProviderProductId(), updated.getProviderProductId())
            .append("ramSize", old.getRamSize(), updated.getRamSize())
            .append("rootVolumeSize", old.getRootVolumeSize(), updated.getRootVolumeSize())
            .append("status", old.getStatus(), updated.getStatus())
            .append("visibleScope", old.getVisibleScope(), updated.getVisibleScope()).build();
    return diff;/*from   w ww . j  a  v a 2  s.c om*/
}

From source file:com.infinities.skyport.compute.entity.patch.VirtualMachinePatchBuilder.java

@Override
public DiffResult diff(VirtualMachine old, VirtualMachine updated) {
    DiffResult diff = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("providerVirtualMachineId", old.getProviderVirtualMachineId(),
                    updated.getProviderVirtualMachineId())
            .append("providerVmStatus", old.getProviderVmStatus(), updated.getProviderVmStatus())
            .append("affinityGroupId", old.getAffinityGroupId(), updated.getAffinityGroupId())
            .append("architecture", old.getArchitecture(), updated.getArchitecture())
            .append("clientRequestToken", old.getClientRequestToken(), updated.getClientRequestToken())
            .append("clonable", old.isClonable(), updated.isClonable())
            .append("creationTimestamp", old.getCreationTimestamp(), updated.getCreationTimestamp())
            .append("currentState", old.getCurrentState(), updated.getCurrentState())
            .append("description", old.getDescription(), updated.getDescription())
            .append("imagable", old.isImagable(), updated.isImagable())
            .append("ioOptimized", old.isIoOptimized(), updated.isIoOptimized())
            .append("ipForwardingAllowed", old.isIpForwardingAllowed(), updated.isIpForwardingAllowed())
            .append("lastBootTimestamp", old.getLastBootTimestamp(), updated.getLastBootTimestamp())
            .append("lastPauseTimestamp", old.getLastPauseTimestamp(), updated.getLastPauseTimestamp())
            .append("lifecycle", old.getLifecycle(), updated.getLifecycle())
            .append("name", old.getName(), updated.getName())
            .append("pausable", old.isPausable(), updated.isPausable())
            .append("persistent", old.isPersistent(), updated.isPersistent())
            .append("platform", old.getPlatform(), updated.getPlatform())
            .append("productId", old.getProductId(), updated.getProductId())
            .append("providerAssignedIpAddressId", old.getProviderAssignedIpAddressId(),
                    updated.getProviderAssignedIpAddressId())
            .append("providerDataCenterId", old.getProviderDataCenterId(), updated.getProviderDataCenterId())
            .append("providerHostStatus", old.getProviderHostStatus(), updated.getProviderHostStatus())
            .append("providerKernelImageId", old.getProviderKernelImageId(), updated.getProviderKernelImageId())
            .append("providerKeypairId", old.getProviderKeypairId(), updated.getProviderKeypairId())
            .append("providerMachineImageId", old.getProviderMachineImageId(),
                    updated.getProviderMachineImageId())
            .append("providerOwnerId", old.getProviderOwnerId(), updated.getProviderOwnerId())
            .append("providerRamdiskImageId", old.getProviderRamdiskImageId(),
                    updated.getProviderRamdiskImageId())
            .append("providerRegionId", old.getProviderRegionId(), updated.getProviderRegionId())
            .append("providerRoleId", old.getProviderRoleId(), updated.getProviderRoleId())
            .append("providerSubnetId", old.getProviderSubnetId(), updated.getProviderSubnetId())
            .append("providerVlanId", old.getProviderVlanId(), updated.getProviderVlanId())
            .append("rebootable", old.isRebootable(), updated.isRebootable())
            .append("resourcePoolId", old.getResourcePoolId(), updated.getResourcePoolId())
            .append("rootPassword", old.getRootPassword(), updated.getRootPassword())
            .append("rootUser", old.getRootUser(), updated.getRootUser())
            .append("spotRequestId", old.getSpotRequestId(), updated.getSpotRequestId())
            .append("stateReasonMessage", old.getStateReasonMessage(), updated.getStateReasonMessage())
            .append("terminationTimestamp", old.getTerminationTimestamp(), updated.getTerminationTimestamp())
            .append("visibleScope", old.getVisibleScope(), updated.getVisibleScope())
            .append("labels", old.getLabels(), updated.getLabels())
            .append("privateAddresses", old.getPrivateAddresses(), updated.getPrivateAddresses())
            .append("privateDnsAddress", old.getPrivateDnsAddress(), updated.getPrivateDnsAddress())
            .append("providerFirewallIds", old.getProviderFirewallIds(), updated.getProviderFirewallIds())
            .append("providerNetworkInterfaceIds", old.getProviderNetworkInterfaceIds(),
                    updated.getProviderNetworkInterfaceIds())
            .append("providerShellKeyIds", old.getProviderShellKeyIds(), updated.getProviderShellKeyIds())
            .append("publicAddresses", old.getPublicAddresses(), updated.getPublicAddresses())
            .append("publicDnsAddress", old.getPublicDnsAddress(), updated.getPublicDnsAddress())
            .append("tags", old.getTags(), updated.getTags())
            .append("volumes", old.getVolumes(), updated.getVolumes()).build();
    return diff;/*from w w w.j av a 2s  .  c  o m*/
}

From source file:com.infinities.skyport.compute.entity.patch.VolumeProductPatchBuilder.java

@Override
public DiffResult diff(VolumeProduct old, VolumeProduct updated) {
    float oldMaxIopsRatio = old.getMaxIopsRatio() == null ? 0 : old.getMaxIopsRatio().floatValue();
    float updatedMaxIopsRatio = updated.getMaxIopsRatio() == null ? 0 : updated.getMaxIopsRatio().floatValue();
    DiffResult diff = new DiffBuilder(new VolumeProductProxy(old), new VolumeProductProxy(updated),
            ToStringStyle.SHORT_PREFIX_STYLE).append("maxIopsRatio", oldMaxIopsRatio, updatedMaxIopsRatio)
                    .append("maxVolumeSize", old.getMaxVolumeSize(), updated.getMaxVolumeSize())
                    .append("minVolumeSize", old.getMinVolumeSize(), updated.getMinVolumeSize()).build();
    return diff;/*from   w w w . j a v  a2s .  c o  m*/
}

From source file:com.infinities.skyport.cache.secondlevel.PatchHandlerTest.java

@SuppressWarnings("unchecked")
@Test//from  w  w w  .j a  v a 2s .  c o  m
public void testHandleInvocationObjectOnEntitiesRefreshedMethodObjectArray() throws Throwable {
    MockPatchListener proxy = new MockPatchListener();
    final Mock added = new Mock();
    added.setId("id");
    added.setName("name");
    final Mock updated = new Mock();
    updated.setId("id2");
    updated.setName("name2");
    final Mock old = new Mock();
    old.setId("id2");
    old.setName("old");
    final Mock removed = new Mock();
    removed.setId("id3");
    removed.setName("name3");
    final List<Mock> newEntries = new ArrayList<Mock>();
    newEntries.add(added);
    newEntries.add(updated);
    final Set<String> cacheKeys = new HashSet<String>();
    cacheKeys.add("id2");
    cacheKeys.add("id3");
    Method method = MockPatchListener.class.getMethod("onEntitiesRefreshed", RefreshedEvent.class);
    final RefreshedEvent<Mock> event = context.mock(RefreshedEvent.class);
    final DiffResult result = new DiffBuilder(old, updated, ToStringStyle.SHORT_PREFIX_STYLE).build();
    context.checking(new Expectations() {

        {
            exactly(1).of(event).getNewEntries();
            will(returnValue(newEntries));
            exactly(1).of(cache).get("id");
            will(returnValue(null));
            exactly(1).of(cache).get("id2");
            will(returnValue(old));
            exactly(1).of(cache).get("id3");
            will(returnValue(removed));
            exactly(1).of(comparator).compare(old, updated);
            will(returnValue(-1));
            exactly(1).of(patchBuilder).diff(old, updated);
            will(returnValue(result));
            exactly(1).of(cache).keySet();
            will(returnValue(cacheKeys));
            exactly(1).of(cache).clear();

        }
    });
    context.checking(new Expectations() {

        {
            exactly(1).of(cache).putAll(with(any(Map.class)));
            will(new CustomAction("check cache") {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    Map<String, Mock> map = (Map<String, Mock>) invocation.getParameter(0);
                    Assert.assertEquals(2, map.size());
                    Assert.assertEquals(added, map.get(added.getId()));
                    Assert.assertEquals(updated, map.get(updated.getId()));
                    return null;
                }

            });
        }
    });
    context.checking(new Expectations() {

        {
            exactly(1).of(event).getConfigid();
            will(returnValue("id"));
            exactly(1).of(inner).onChanged(with(any(SuccessEvent.class)));
            will(new CustomAction("check removed event") {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    SuccessEvent<Mock> event = (SuccessEvent<Mock>) invocation.getParameter(0);
                    Assert.assertEquals(1, event.getEntries().size());
                    Assert.assertEquals(removed, event.getEntries().iterator().next());
                    Assert.assertEquals("id", event.getConfigid());
                    Assert.assertEquals(Type.REMOVED, event.getType());
                    return null;
                }

            });
        }
    });
    context.checking(new Expectations() {

        {
            exactly(1).of(event).getConfigid();
            will(returnValue("id"));
            exactly(1).of(inner).onChanged(with(any(SuccessEvent.class)));
            will(new CustomAction("check added event") {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    SuccessEvent<Mock> event = (SuccessEvent<Mock>) invocation.getParameter(0);
                    Assert.assertEquals(1, event.getEntries().size());
                    Assert.assertEquals(added, event.getEntries().iterator().next());
                    Assert.assertEquals("id", event.getConfigid());
                    Assert.assertEquals(Type.ADDED, event.getType());
                    return null;
                }

            });
        }
    });
    context.checking(new Expectations() {

        {
            exactly(1).of(event).getConfigid();
            will(returnValue("id"));
            exactly(1).of(inner).onChanged(with(any(SuccessEvent.class)));
            will(new CustomAction("check modified event") {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    SuccessEvent<Mock> event = (SuccessEvent<Mock>) invocation.getParameter(0);
                    Assert.assertEquals(1, event.getEntries().size());
                    Assert.assertEquals(updated, event.getEntries().iterator().next());
                    Assert.assertEquals("id", event.getConfigid());
                    Assert.assertEquals(Type.MODIFIED, event.getType());
                    Assert.assertEquals(1, event.getPatchs().size());
                    Assert.assertEquals(result, event.getPatchs().get(updated.getId()));
                    return null;
                }

            });
        }
    });
    context.checking(new Expectations() {

        {
            exactly(1).of(event).getConfigid();
            will(returnValue("id"));
            exactly(1).of(inner).onChanged(with(any(SuccessEvent.class)));
            will(new CustomAction("check refresh event") {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    SuccessEvent<Mock> event = (SuccessEvent<Mock>) invocation.getParameter(0);
                    Assert.assertEquals(2, event.getEntries().size());
                    Assert.assertEquals("id", event.getConfigid());
                    Assert.assertEquals(Type.REFRESHED, event.getType());
                    return null;
                }

            });
        }
    });
    handler.handleInvocation(proxy, method, new Object[] { event });
}