diff options
author | Simon Rettberg | 2015-08-14 15:31:12 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-14 15:31:12 +0200 |
commit | 19688656134b288fd981730544dde303c9c3afd9 (patch) | |
tree | 99ee404d2f08e46c024318d95169495d9b9258e3 /src/main/java/org/openslx/thrifthelper/Comparators.java | |
parent | Use connection pool in thrift manager, allow getting explicit sat connection (diff) | |
download | master-sync-shared-19688656134b288fd981730544dde303c9c3afd9.tar.gz master-sync-shared-19688656134b288fd981730544dde303c9c3afd9.tar.xz master-sync-shared-19688656134b288fd981730544dde303c9c3afd9.zip |
Thrift api changes
Diffstat (limited to 'src/main/java/org/openslx/thrifthelper/Comparators.java')
-rw-r--r-- | src/main/java/org/openslx/thrifthelper/Comparators.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/thrifthelper/Comparators.java b/src/main/java/org/openslx/thrifthelper/Comparators.java new file mode 100644 index 0000000..5580cf6 --- /dev/null +++ b/src/main/java/org/openslx/thrifthelper/Comparators.java @@ -0,0 +1,78 @@ +package org.openslx.thrifthelper; + +import java.util.Comparator; + +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; +import org.openslx.bwlp.thrift.iface.ImageVersionDetails; +import org.openslx.bwlp.thrift.iface.OperatingSystem; +import org.openslx.bwlp.thrift.iface.Organization; +import org.openslx.bwlp.thrift.iface.Virtualizer; + +/** + * A bunch of comparators for thrift classes. They will compare on what would be considered the + * identifier ("primary key") of a struct, unless stated otherwise. + */ +public class Comparators +{ + + public static final Comparator<ImageVersionDetails> imageVersionDetails = new Comparator<ImageVersionDetails>() { + @Override + public int compare( ImageVersionDetails o1, ImageVersionDetails o2 ) + { + if ( o1 == null || o1.versionId == null ) + return o2 == null || o2.versionId == null ? 0 : 1; + if ( o2 == null || o2.versionId == null ) + return -1; + return o1.versionId.compareTo( o2.versionId ); + } + }; + + public static final Comparator<ImageSummaryRead> imageSummaryRead = new Comparator<ImageSummaryRead>() { + @Override + public int compare( ImageSummaryRead o1, ImageSummaryRead o2 ) + { + if ( o1 == null || o1.imageBaseId == null ) + return o2 == null || o2.imageBaseId == null ? 0 : 1; + if ( o2 == null || o2.imageBaseId == null ) + return -1; + return o1.imageBaseId.compareTo( o2.imageBaseId ); + } + }; + + public static final Comparator<OperatingSystem> operatingSystem = new Comparator<OperatingSystem>() { + @Override + public int compare( OperatingSystem o1, OperatingSystem o2 ) + { + if ( o1 == null ) + return o2 == null ? 0 : 1; + if ( o2 == null ) + return -1; + return o1.osId - o2.osId; + } + }; + + public static final Comparator<Virtualizer> virtualizer = new Comparator<Virtualizer>() { + @Override + public int compare( Virtualizer o1, Virtualizer o2 ) + { + if ( o1 == null || o1.virtId == null ) + return o2 == null || o2.virtId == null ? 0 : 1; + if ( o2 == null || o2.virtId == null ) + return -1; + return o1.virtId.compareTo( o2.virtId ); + } + }; + + public static final Comparator<Organization> organization = new Comparator<Organization>() { + @Override + public int compare( Organization o1, Organization o2 ) + { + if ( o1 == null || o1.organizationId == null ) + return o2 == null || o2.organizationId == null ? 0 : 1; + if ( o2 == null || o2.organizationId == null ) + return -1; + return o1.organizationId.compareTo( o2.organizationId ); + } + }; + +} |