@Test public void testGetNewestVersion() { List<FileVersion> versions = new ArrayList<FileVersion>(); versions.add(new FileVersion(0, 123, System.currentTimeMillis(), new ArrayList<MetaChunk>())); versions.add(new FileVersion(1, 123, System.currentTimeMillis(), new ArrayList<MetaChunk>())); versions.add(new FileVersion(2, 123, System.currentTimeMillis() - 1000 * 60, new ArrayList<MetaChunk>())); MetaFileSmall metaFileSmall = new MetaFileSmall(keys.getPublic(), versions, keys); FileVersion newestVersion = metaFileSmall.getNewestVersion(); Assert.assertEquals(2, newestVersion.getIndex()); }
public FileVersion getNewestVersion() { if (versions == null || versions.isEmpty()) { return null; } return Collections.max(versions, new Comparator<FileVersion>() { @Override public int compare(FileVersion o1, FileVersion o2) { return new Integer(o1.getIndex()).compareTo(o2.getIndex()); } }); }
MetaFileSmall extends BaseMetaFile { public FileVersion getNewestVersion() { if (versions == null || versions.isEmpty()) { return null; } return Collections.max(versions, new Comparator<FileVersion>() { @Override public int compare(FileVersion o1, FileVersion o2) { return new Integer(o1.getIndex()).compareTo(o2.getIndex()); } }); } }
MetaFileSmall extends BaseMetaFile { public FileVersion getNewestVersion() { if (versions == null || versions.isEmpty()) { return null; } return Collections.max(versions, new Comparator<FileVersion>() { @Override public int compare(FileVersion o1, FileVersion o2) { return new Integer(o1.getIndex()).compareTo(o2.getIndex()); } }); } MetaFileSmall(PublicKey id, List<FileVersion> versions, KeyPair chunkKey); }
MetaFileSmall extends BaseMetaFile { public FileVersion getNewestVersion() { if (versions == null || versions.isEmpty()) { return null; } return Collections.max(versions, new Comparator<FileVersion>() { @Override public int compare(FileVersion o1, FileVersion o2) { return new Integer(o1.getIndex()).compareTo(o2.getIndex()); } }); } MetaFileSmall(PublicKey id, List<FileVersion> versions, KeyPair chunkKey); List<FileVersion> getVersions(); KeyPair getChunkKey(); BigInteger getTotalSize(); FileVersion getNewestVersion(); FileVersion getVersionByIndex(int index); }
MetaFileSmall extends BaseMetaFile { public FileVersion getNewestVersion() { if (versions == null || versions.isEmpty()) { return null; } return Collections.max(versions, new Comparator<FileVersion>() { @Override public int compare(FileVersion o1, FileVersion o2) { return new Integer(o1.getIndex()).compareTo(o2.getIndex()); } }); } MetaFileSmall(PublicKey id, List<FileVersion> versions, KeyPair chunkKey); List<FileVersion> getVersions(); KeyPair getChunkKey(); BigInteger getTotalSize(); FileVersion getNewestVersion(); FileVersion getVersionByIndex(int index);  }