if (lifespan > -1 && maxIdle < 0) return new MortalCacheEntry(key, value, lifespan, created);
if (lifespan < 0 && maxIdle > -1) return new TransientCacheEntry(key, value, maxIdle, lastUsed);
return new TransientMortalCacheEntry(key, value, maxIdle, lifespan, lastUsed, created);
} else {
// If no metadata passed, assumed embedded metadata
Metadata metadata = new EmbeddedMetadata.Builder()
.lifespan(lifespan).maxIdle(maxIdle).version(version).build();
if (lifespan < 0 && maxIdle < 0) return new MetadataImmortalCacheEntry(key, value, metadata);
if (lifespan > -1 && maxIdle < 0) return new MetadataMortalCacheEntry(key, value, metadata, created);
if (lifespan < 0 && maxIdle > -1) return new MetadataTransientCacheEntry(key, value, metadata, lastUsed);
return new MetadataTransientMortalCacheEntry(key, value, metadata, lastUsed, created);