@Test public void nothingToExtract() { NestedAttributesMap attributes = new NestedAttributesMap(P_ATTRIBUTES, Maps.<String, Object>newHashMap()); Asset asset = mock(Asset.class); when(asset.attributes()).thenReturn(attributes); CacheInfo cacheInfo = CacheInfo.extractFromAsset(asset); assertThat(cacheInfo, nullValue()); }
@Nullable public static CacheInfo extractFromAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); final DateTime lastVerified = toDateTime(cache.get(LAST_VERIFIED, Date.class)); if (lastVerified == null) { return null; } final String cacheToken = cache.get(CACHE_TOKEN, String.class); return new CacheInfo(lastVerified, cacheToken); }
CacheInfo { @Nullable public static CacheInfo extractFromAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); final DateTime lastVerified = toDateTime(cache.get(LAST_VERIFIED, Date.class)); if (lastVerified == null) { return null; } final String cacheToken = cache.get(CACHE_TOKEN, String.class); return new CacheInfo(lastVerified, cacheToken); } }
CacheInfo { @Nullable public static CacheInfo extractFromAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); final DateTime lastVerified = toDateTime(cache.get(LAST_VERIFIED, Date.class)); if (lastVerified == null) { return null; } final String cacheToken = cache.get(CACHE_TOKEN, String.class); return new CacheInfo(lastVerified, cacheToken); } CacheInfo(final DateTime lastVerified, @Nullable final String cacheToken); }
CacheInfo { @Nullable public static CacheInfo extractFromAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); final DateTime lastVerified = toDateTime(cache.get(LAST_VERIFIED, Date.class)); if (lastVerified == null) { return null; } final String cacheToken = cache.get(CACHE_TOKEN, String.class); return new CacheInfo(lastVerified, cacheToken); } CacheInfo(final DateTime lastVerified, @Nullable final String cacheToken); DateTime getLastVerified(); @Nullable String getCacheToken(); boolean isInvalidated(); @Override String toString(); @Nullable static CacheInfo extractFromAsset(final Asset asset); @Nullable static CacheInfo extractFromAsset(final NestedAttributesMap attributes); static void applyToAsset(final Asset asset, final CacheInfo cacheInfo); static boolean invalidateAsset(final Asset asset); }
CacheInfo { @Nullable public static CacheInfo extractFromAsset(final Asset asset) { checkNotNull(asset); final NestedAttributesMap cache = asset.attributes().child(CACHE); final DateTime lastVerified = toDateTime(cache.get(LAST_VERIFIED, Date.class)); if (lastVerified == null) { return null; } final String cacheToken = cache.get(CACHE_TOKEN, String.class); return new CacheInfo(lastVerified, cacheToken); } CacheInfo(final DateTime lastVerified, @Nullable final String cacheToken); DateTime getLastVerified(); @Nullable String getCacheToken(); boolean isInvalidated(); @Override String toString(); @Nullable static CacheInfo extractFromAsset(final Asset asset); @Nullable static CacheInfo extractFromAsset(final NestedAttributesMap attributes); static void applyToAsset(final Asset asset, final CacheInfo cacheInfo); static boolean invalidateAsset(final Asset asset); @VisibleForTesting
  static final String CACHE; @VisibleForTesting
  static final String CACHE_TOKEN; @VisibleForTesting
  static final String LAST_VERIFIED; @VisibleForTesting
  static final String INVALIDATED; }