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, TimeUnit.MILLISECONDS)
.maxIdle(maxIdle, TimeUnit.MILLISECONDS)
.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);